1 13 14 package info.magnolia.module.admininterface; 15 16 import info.magnolia.cms.beans.config.ObservedManager; 17 import info.magnolia.cms.beans.config.ParagraphManager; 18 import info.magnolia.cms.beans.config.ShutdownManager; 19 import info.magnolia.cms.beans.config.TemplateManager; 20 import info.magnolia.cms.beans.config.TemplateRendererManager; 21 import info.magnolia.cms.beans.config.VirtualURIManager; 22 import info.magnolia.cms.core.Content; 23 import info.magnolia.cms.gui.dialog.ControlsManager; 24 import info.magnolia.cms.module.AbstractModule; 25 import info.magnolia.cms.module.InitializationException; 26 import info.magnolia.cms.util.ContentUtil; 27 import info.magnolia.commands.CommandsManager; 28 29 import org.slf4j.Logger; 30 import org.slf4j.LoggerFactory; 31 32 33 37 public abstract class AbstractAdminModule extends AbstractModule { 38 39 42 protected Logger log = LoggerFactory.getLogger(getClass()); 43 44 47 private Content configNode; 48 49 54 public final void init(Content configNode) throws InitializationException { 55 this.setConfigNode(configNode); 56 try { 57 58 initEntry("virtualURIMapping", VirtualURIManager.getInstance()); 59 initEntry("templates", TemplateManager.getInstance()); 60 initEntry("renderers", TemplateRendererManager.getInstance()); 61 initEntry("paragraphs", ParagraphManager.getInstance()); 62 initEntry("dialogs", DialogHandlerManager.getInstance()); 63 initEntry("controls", ControlsManager.getInstance()); 64 initEntry("pages", PageHandlerManager.getInstance()); 65 initEntry("trees", TreeHandlerManager.getInstance()); 66 initEntry("commands", CommandsManager.getInstance()); 67 initEntry("shutdown", ShutdownManager.getInstance()); 68 69 onInit(); 70 71 this.setInitialized(true); 72 } 73 catch (Exception e) { 74 throw new InitializationException("can't initialize module [" + this.getName() + "]", e); 75 } 76 } 77 78 82 private void initEntry(String nodeName, ObservedManager manager) { 83 Content node = ContentUtil.getCaseInsensitive(moduleNode, nodeName); 84 if (node != null) { 85 manager.register(node); 86 } 87 } 88 89 92 protected abstract void onInit() throws InitializationException; 93 94 97 public Content getConfigNode() { 98 return this.configNode; 99 } 100 101 104 protected void setConfigNode(Content configNode) { 105 this.configNode = configNode; 106 } 107 108 } 109 | Popular Tags |