1 package info.magnolia.cms.cache; 2 3 import info.magnolia.cms.beans.config.ContentRepository; 4 import info.magnolia.cms.core.Content; 5 import info.magnolia.cms.module.AbstractModule; 6 import info.magnolia.cms.module.InitializationException; 7 import info.magnolia.cms.module.InvalidConfigException; 8 import info.magnolia.cms.module.RegisterException; 9 import info.magnolia.cms.util.NodeDataUtil; 10 11 import org.apache.commons.lang.BooleanUtils; 12 import org.apache.commons.logging.Log; 13 import org.apache.commons.logging.LogFactory; 14 15 16 20 public class Engine extends AbstractModule { 21 22 25 private static Log log = LogFactory.getLog(Engine.class); 26 27 private CacheManager cacheManager = CacheManagerFactory.getCacheManager(); 28 29 32 public void init(Content configNode) throws InvalidConfigException, InitializationException { 33 this.cacheManager.init(configNode); 34 this.setInitialized(true); 35 } 36 37 40 public void destroy() { 41 if (this.cacheManager.isRunning()) { 42 this.cacheManager.stop(); 43 } 44 } 45 46 49 protected void onRegister(int registerState) throws RegisterException { 50 try { 52 boolean admin = BooleanUtils.toBoolean(NodeDataUtil.getString( 53 ContentRepository.CONFIG, 54 "/server/admin", 55 "true")); 56 if (admin) { 57 NodeDataUtil.getOrCreate(this.getModuleNode().getContent("config"), "active").setValue(false); 58 } 59 } 60 catch (Exception e) { 61 log.error("can't set the caches active flag properly", e); 62 } 63 } 64 65 } 66 | Popular Tags |