PageRenderTime 27ms CodeModel.GetById 11ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/plugin-module-codegen-maven-client/src/main/java/com/atlassian/maven/plugins/amps/codegen/prompter/common/servlet/ServletModulePrompter.java

https://bitbucket.org/mmeinhold/amps
Java | 57 lines | 41 code | 13 blank | 3 comment | 1 complexity | e771ae427b09f3320eaf4c568e2c8907 MD5 | raw file
 1package com.atlassian.maven.plugins.amps.codegen.prompter.common.servlet;
 2
 3import java.util.Map;
 4
 5import com.atlassian.maven.plugins.amps.codegen.annotations.ModuleCreatorClass;
 6import com.atlassian.maven.plugins.amps.codegen.prompter.AbstractModulePrompter;
 7import com.atlassian.plugins.codegen.modules.PluginModuleLocation;
 8import com.atlassian.plugins.codegen.modules.common.servlet.ServletModuleCreator;
 9import com.atlassian.plugins.codegen.modules.common.servlet.ServletProperties;
10import com.atlassian.plugins.codegen.util.ClassnameUtil;
11
12import org.codehaus.plexus.components.interactivity.Prompter;
13import org.codehaus.plexus.components.interactivity.PrompterException;
14
15/**
16 * @since 3.6
17 */
18@ModuleCreatorClass(ServletModuleCreator.class)
19public class ServletModulePrompter extends AbstractModulePrompter<ServletProperties>
20{
21
22    public ServletModulePrompter(Prompter prompter)
23    {
24        super(prompter);
25
26    }
27
28    @Override
29    public ServletProperties promptForBasicProperties(PluginModuleLocation moduleLocation) throws PrompterException
30    {
31        String className = promptJavaClassname("Enter New Classname", "MyServlet");
32        String packageName = promptJavaPackagename("Enter Package Name", getDefaultBasePackage() + ".servlet");
33
34        return new ServletProperties(ClassnameUtil.fullyQualifiedName(packageName, className));
35    }
36
37    @Override
38    public void promptForAdvancedProperties(ServletProperties props, PluginModuleLocation moduleLocation) throws PrompterException
39    {
40        props.setUrlPattern(getUrlPatternFromUser("/" + props.getClassId().getName()
41                .toLowerCase()));
42
43        Map<String, String> initParams = promptForParams("Add Init-Param?");
44        if (initParams.size() > 0)
45        {
46            props.setInitParams(initParams);
47        }
48    }
49
50    private String getUrlPatternFromUser(String defaultVal) throws PrompterException
51    {
52        String pattern = promptNotBlank("URL Pattern", defaultVal);
53
54        return pattern;
55    }
56
57}