View Javadoc

1   package com.atlassian.plugin.servlet.descriptors;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.dom4j.Element;
5   
6   import com.atlassian.plugin.Plugin;
7   import com.atlassian.plugin.PluginParseException;
8   import com.atlassian.plugin.descriptors.AbstractModuleDescriptor;
9   
10  /**
11   * Allows plugin developers to specify init parameters they would like added to the plugin local {@link javax.servlet.ServletContext}.
12   *
13   * @since 2.1.0
14   */
15  public class ServletContextParamModuleDescriptor extends AbstractModuleDescriptor<Void>
16  {
17      private String paramName;
18      private String paramValue;
19      
20      @Override
21      public void init(Plugin plugin, Element element) throws PluginParseException
22      {
23          super.init(plugin, element);
24          
25          paramName = element.elementTextTrim("param-name");
26          if (StringUtils.isEmpty(paramName))
27              throw new IllegalArgumentException("param-name must be specified");
28          
29          paramValue = element.elementTextTrim("param-value");
30          if (StringUtils.isEmpty(paramValue))
31              throw new IllegalArgumentException("param-value must be specified");
32      }
33  
34      public String getParamName()
35      {
36          return paramName;
37      }
38  
39      public String getParamValue()
40      {
41          return paramValue;
42      }
43  
44      @Override
45      public Void getModule()
46      {
47          return null;
48      }
49  }