KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > module > admininterface > AbstractAdminModule


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

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 /**
34  * Default implementation. registers dialogs , paragraphs, ...
35  * @author philipp
36  */

37 public abstract class AbstractAdminModule extends AbstractModule {
38
39     /**
40      * Logger
41      */

42     protected Logger log = LoggerFactory.getLogger(getClass());
43
44     /**
45      * The node containing the configuration for this module
46      */

47     private Content configNode;
48
49     /**
50      * Initialize the module. Registers the dialogs, paragraphs and templates of this modules. Calls the abstract onInit
51      * method.
52      * @throws InitializationException
53      */

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 JavaDoc e) {
74             throw new InitializationException("can't initialize module [" + this.getName() + "]", e);
75         }
76     }
77
78     /**
79      * @param nodeName
80      * @param manager
81      */

82     private void initEntry(String JavaDoc nodeName, ObservedManager manager) {
83         Content node = ContentUtil.getCaseInsensitive(moduleNode, nodeName);
84         if (node != null) {
85             manager.register(node);
86         }
87     }
88
89     /**
90      * Template pattern. Implement to perfome somem module specific stuff
91      */

92     protected abstract void onInit() throws InitializationException;
93
94     /**
95      * @return Returns the config node of the modules node.
96      */

97     public Content getConfigNode() {
98         return this.configNode;
99     }
100
101     /**
102      * @param configNode The configNode to set.
103      */

104     protected void setConfigNode(Content configNode) {
105         this.configNode = configNode;
106     }
107
108 }
109
Popular Tags