PageRenderTime 30ms CodeModel.GetById 13ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

/plugin-module-codegen-engine/src/main/java/com/atlassian/plugins/codegen/modules/common/servlet/ServletContextListenerModuleCreator.java

https://bitbucket.org/mmeinhold/amps
Java | 59 lines | 43 code | 10 blank | 6 comment | 1 complexity | 5923b4b15d9f4af736721dc08c89a5d7 MD5 | raw file
 1package com.atlassian.plugins.codegen.modules.common.servlet;
 2
 3import com.atlassian.plugins.codegen.PluginProjectChangeset;
 4import com.atlassian.plugins.codegen.annotations.*;
 5import com.atlassian.plugins.codegen.modules.AbstractPluginModuleCreator;
 6
 7import static com.atlassian.plugins.codegen.modules.Dependencies.HTTPCLIENT_TEST;
 8import static com.atlassian.plugins.codegen.modules.Dependencies.MOCKITO_TEST;
 9import static com.atlassian.plugins.codegen.modules.Dependencies.SERVLET_API;
10
11/**
12 * @since 3.6
13 */
14@RefAppPluginModuleCreator
15@JiraPluginModuleCreator
16@ConfluencePluginModuleCreator
17@BambooPluginModuleCreator
18@StashPluginModuleCreator
19public class ServletContextListenerModuleCreator extends AbstractPluginModuleCreator<ServletContextListenerProperties>
20{
21
22    public static final String MODULE_NAME = "Servlet Context Listener";
23    private static final String TEMPLATE_PREFIX = "templates/common/servlet/listener/";
24
25    //stub
26    private static final String CLASS_TEMPLATE = TEMPLATE_PREFIX + "ServletContextListener.java.vtl";
27    private static final String UNIT_TEST_TEMPLATE = TEMPLATE_PREFIX + "ServletContextListenerTest.java.vtl";
28
29    //examples
30    private static final String EXAMPLE_CLASS_TEMPLATE = TEMPLATE_PREFIX + "Example" + CLASS_TEMPLATE;
31
32    private static final String PLUGIN_MODULE_TEMPLATE = TEMPLATE_PREFIX + "servlet-context-listener-plugin.xml.vtl";
33
34    @Override
35    public PluginProjectChangeset createModule(ServletContextListenerProperties props) throws Exception
36    {
37        PluginProjectChangeset ret = new PluginProjectChangeset()
38            .with(SERVLET_API,
39                  HTTPCLIENT_TEST,
40                  MOCKITO_TEST)
41            .with(createModule(props, PLUGIN_MODULE_TEMPLATE));
42
43        if (props.includeExamples())
44        {
45            return ret.with(createClass(props, EXAMPLE_CLASS_TEMPLATE));
46        }
47        else
48        {
49            return ret.with(createClassAndTests(props, CLASS_TEMPLATE, UNIT_TEST_TEMPLATE));
50            // context listener is too complex to func test without a known servlet
51        }
52    }
53    
54    @Override
55    public String getModuleName()
56    {
57        return MODULE_NAME;
58    }
59}