KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > mail > Engine


1 package info.magnolia.cms.mail;
2
3 import info.magnolia.cms.core.Content;
4 import info.magnolia.cms.module.AbstractModule;
5 import info.magnolia.cms.module.InitializationException;
6 import info.magnolia.cms.module.InvalidConfigException;
7
8 import javax.jcr.RepositoryException;
9
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
12
13
14 /**
15  * @author <a HREF="mailto:niko@macnica.com">Nicolas Modrzyk</a>
16  */

17 public class Engine extends AbstractModule {
18
19     public static final String JavaDoc SERVER_MAIL_CONFIG = "smtp";
20
21     public static final String JavaDoc MAIL_TEMPLATES_PATH = "templates";
22
23     static final Logger log = LoggerFactory.getLogger(Engine.class);
24
25     /**
26      * Init cache manager
27      */

28     public void init(Content configNode) throws InvalidConfigException, InitializationException {
29         try {
30             Content smtpNode = configNode.getContent(SERVER_MAIL_CONFIG);
31             Content templateNode = configNode.getContent(MAIL_TEMPLATES_PATH);
32             log.info("Loading mail server settings");
33             MgnlMailFactory.getInstance().register(smtpNode);
34             log.info("Loading mail templates");
35             MgnlMailFactory.getInstance().register(templateNode);
36             this.setInitialized(true);
37         }
38         catch (RepositoryException e) {
39             log.error("Missing configuration for mail. Module is not properly initialized");
40         }
41     }
42 }
43
Popular Tags