View Javadoc

1   package com.atlassian.plugin.servlet.descriptors;
2   
3   import com.atlassian.plugin.Permissions;
4   import com.atlassian.plugin.Plugin;
5   import com.atlassian.plugin.PluginParseException;
6   import com.atlassian.plugin.RequirePermission;
7   import com.atlassian.plugin.descriptors.AbstractModuleDescriptor;
8   import com.atlassian.plugin.module.ModuleFactory;
9   import com.atlassian.util.concurrent.NotNull;
10  import org.dom4j.Element;
11  import org.slf4j.Logger;
12  import org.slf4j.LoggerFactory;
13  
14  import javax.servlet.ServletContextListener;
15  
16  /**
17   * Provides a way for plugins to declare {@link ServletContextListener}s so they can be notified when the 
18   * {@link javax.servlet.ServletContext} is created for the plugin.  Implementors need to extend this class and implement the
19   * {#link autowireObject} method.
20   *
21   * @since 2.1.0
22   */
23  @RequirePermission(Permissions.EXECUTE_JAVA)
24  public class ServletContextListenerModuleDescriptor extends AbstractModuleDescriptor<ServletContextListener>
25  {
26      protected static final Logger log = LoggerFactory.getLogger(ServletContextListenerModuleDescriptor.class);
27  
28      /**
29       * @since 2.5.0
30       */
31      public ServletContextListenerModuleDescriptor(ModuleFactory moduleFactory)
32      {
33          super(moduleFactory);
34      }
35  
36      @Override
37      public void init(@NotNull Plugin plugin, @NotNull Element element) throws PluginParseException
38      {
39          super.init(plugin, element);
40          checkPermissions();
41      }
42  
43      @Override
44      public ServletContextListener getModule()
45      {
46          return moduleFactory.createModule(moduleClassName, this);
47      }
48  
49  }