1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package org.struts.velocity.demo.util;
27
28 import javax.servlet.ServletException;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32 import org.apache.struts.action.ActionServlet;
33 import org.apache.struts.action.PlugIn;
34 import org.apache.struts.config.ModuleConfig;
35 import org.strutsit.architecture.hivemind.StrutsHive;
36 import org.strutsit.examples.service.PropertyService;
37
38 /***
39 * Initplugin must be called after the StrutsHivePlugin is called, because
40 * StrutsHivePlugin initializes the database connection.
41 *
42 * @author <a href="mailto:wolff@struts-it.de">Manfred Wolff </a>
43 * @since JDK 1.4
44 * @version $Revision: 1.6 $
45 */
46
47 public class InitPlugin implements PlugIn {
48
49
50 private static final Log log = LogFactory.getLog(InitPlugin.class);
51
52 /***
53 * Inits the plugin
54 */
55 public void init(ActionServlet actionServlet, ModuleConfig moduleConfig)
56 throws ServletException {
57
58 if (log.isTraceEnabled()) {
59 log.trace("init -> START");
60 }
61
62
63 StrutsHive hive = (StrutsHive) actionServlet.getServletContext()
64 .getAttribute(StrutsHive.STRUTSHIVE_REGISTRY);
65
66
67 Object o = null;
68 try {
69 o = hive.lookup("org.strutsit.examples.service.PropertyService",
70 org.strutsit.examples.service.PropertyService.class);
71 } catch (Throwable e) {
72 log.error(e);
73 }
74
75
76 PropertyService pservice = (PropertyService) o;
77
78 pservice.init();
79
80
81 if (log.isTraceEnabled()) {
82 log.trace("init -> END");
83 }
84 }
85
86 /***
87 * Will be called, if the servlet cointainer goes down.
88 */
89 public void destroy() {
90
91 }
92
93 }