1 package com.atlassian.plugin.servlet.descriptors;
2
3 import javax.servlet.ServletContextListener;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7
8 import com.atlassian.plugin.AutowireCapablePlugin;
9 import com.atlassian.plugin.descriptors.AbstractModuleDescriptor;
10
11
12
13
14
15
16
17
18 public abstract class ServletContextListenerModuleDescriptor extends AbstractModuleDescriptor<ServletContextListener>
19 {
20 protected static final Log log = LogFactory.getLog(ServletContextListenerModuleDescriptor.class);
21
22 @Override
23 public ServletContextListener getModule()
24 {
25 ServletContextListener obj = null;
26 try
27 {
28
29 if (plugin instanceof AutowireCapablePlugin)
30 obj = ((AutowireCapablePlugin)plugin).autowire(getModuleClass());
31 else
32 {
33 obj = getModuleClass().newInstance();
34 autowireObject(obj);
35 }
36 }
37 catch (InstantiationException e)
38 {
39 log.error("Error instantiating: " + getModuleClass(), e);
40 }
41 catch (IllegalAccessException e)
42 {
43 log.error("Error accessing: " + getModuleClass(), e);
44 }
45 return obj;
46 }
47
48
49
50
51 protected abstract void autowireObject(Object obj);
52 }