[252618] Servlet, Listener and Filter wizards now work on Java EE 6 Projects.
They will generate only annotated metadata.
diff --git a/plugins/org.eclipse.jst.j2ee.web/.externalToolBuilders/org.eclipse.emf.codegen.JETBuilder.launch b/plugins/org.eclipse.jst.j2ee.web/.externalToolBuilders/org.eclipse.emf.codegen.JETBuilder.launch
deleted file mode 100644
index ca1988c..0000000
--- a/plugins/org.eclipse.jst.j2ee.web/.externalToolBuilders/org.eclipse.emf.codegen.JETBuilder.launch
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
-<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.emf.codegen.JETBuilder"/>
-<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
-<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
-</launchConfiguration>
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee.web/.project b/plugins/org.eclipse.jst.j2ee.web/.project
index 93eec33..a7cf375 100644
--- a/plugins/org.eclipse.jst.j2ee.web/.project
+++ b/plugins/org.eclipse.jst.j2ee.web/.project
@@ -6,13 +6,8 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
- <triggers>full,incremental,</triggers>
+ <name>org.eclipse.emf.codegen.JETBuilder</name>
<arguments>
- <dictionary>
- <key>LaunchConfigHandle</key>
- <value><project>/.externalToolBuilders/org.eclipse.emf.codegen.JETBuilder.launch</value>
- </dictionary>
</arguments>
</buildCommand>
<buildCommand>
diff --git a/plugins/org.eclipse.jst.j2ee.web/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.jst.j2ee.web/.settings/org.eclipse.jdt.core.prefs
index b4b7cd9..26842ca 100644
--- a/plugins/org.eclipse.jst.j2ee.web/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/org.eclipse.jst.j2ee.web/.settings/org.eclipse.jdt.core.prefs
@@ -1,95 +1,97 @@
-#Wed Jun 10 12:11:14 EDT 2009
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=error
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
-org.eclipse.jdt.core.compiler.problem.unusedLocal=error
-org.eclipse.jdt.core.compiler.problem.emptyStatement=error
-org.eclipse.jdt.core.compiler.problem.unusedLabel=error
-org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.incompatibleJDKLevel=ignore
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+#Thu Feb 18 13:56:30 EET 2010
+eclipse.preferences.version=1
+instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=error
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error
-org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
-org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error
-org.eclipse.jdt.core.builder.invalidClasspath=abort
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error
-org.eclipse.jdt.core.codeComplete.argumentSuffixes=
-org.eclipse.jdt.core.codeComplete.argumentPrefixes=
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=error
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.source=1.5
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.builder.duplicateResourceTask=warning
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
-org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error
-eclipse.preferences.version=1
-org.eclipse.jdt.core.incompleteClasspath=error
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
-org.eclipse.jdt.core.compiler.problem.deadCode=error
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeUncheckedExceptions=disabled
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.codeComplete.fieldPrefixes=
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=warning
org.eclipse.jdt.core.circularClasspath=error
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=
org.eclipse.jdt.core.codeComplete.fieldSuffixes=
-org.eclipse.jdt.core.codeComplete.localSuffixes=
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=error
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
org.eclipse.jdt.core.codeComplete.localPrefixes=
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.codeComplete.localSuffixes=
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
+org.eclipse.jdt.core.compiler.problem.deadCode=error
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=error
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=error
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=error
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=error
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=error
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=error
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=error
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=error
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeUncheckedExceptions=disabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLabel=error
+org.eclipse.jdt.core.compiler.problem.unusedLocal=error
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/plugins/org.eclipse.jst.j2ee.web/templates/_class.template b/plugins/org.eclipse.jst.j2ee.web/templates/_class.template
index 4248810..17fc58a 100644
--- a/plugins/org.eclipse.jst.j2ee.web/templates/_class.template
+++ b/plugins/org.eclipse.jst.j2ee.web/templates/_class.template
@@ -29,7 +29,7 @@
}
for (int i = 0; i < interfaces.size(); i++) {
- String INTERFACE = (String) interfaces.get(i);
+ String INTERFACE = interfaces.get(i);
if (i > 0) {
%>,
<%
diff --git a/plugins/org.eclipse.jst.j2ee.web/templates/filter_classHeader.template b/plugins/org.eclipse.jst.j2ee.web/templates/filter_classHeader.template
index 443461b..28ac258 100644
--- a/plugins/org.eclipse.jst.j2ee.web/templates/filter_classHeader.template
+++ b/plugins/org.eclipse.jst.j2ee.web/templates/filter_classHeader.template
@@ -59,4 +59,11 @@
}
}
%>
- */
\ No newline at end of file
+ */
+ <%
+ if ("3.0".equals(model.getJavaEEVersion())) {
+%>
+@WebFilter<%=model.getJavaEE6AnnotationParameters()%>
+<%
+}
+%>
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee.web/templates/listener_classHeader.template b/plugins/org.eclipse.jst.j2ee.web/templates/listener_classHeader.template
index 30c28e0..73ff422 100644
--- a/plugins/org.eclipse.jst.j2ee.web/templates/listener_classHeader.template
+++ b/plugins/org.eclipse.jst.j2ee.web/templates/listener_classHeader.template
@@ -8,4 +8,11 @@
<%
}
%>
- */
\ No newline at end of file
+ */
+ <%
+ if ("3.0".equals(model.getJavaEEVersion())) {
+%>
+@WebListener
+<%
+}
+%>
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee.web/templates/servlet_classHeader.template b/plugins/org.eclipse.jst.j2ee.web/templates/servlet_classHeader.template
index 4fd0707..7dfbc22 100644
--- a/plugins/org.eclipse.jst.j2ee.web/templates/servlet_classHeader.template
+++ b/plugins/org.eclipse.jst.j2ee.web/templates/servlet_classHeader.template
@@ -45,4 +45,11 @@
}
}
%>
- */
\ No newline at end of file
+ */
+ <%
+ if ("3.0".equals(model.getJavaEEVersion())) {
+%>
+@WebServlet<%=model.getJavaEE6AnnotationParameters()%>
+<%
+}
+%>
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/AddWebClassOperation.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/AddWebClassOperation.java
index 6270f23..830a9c7 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/AddWebClassOperation.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/AddWebClassOperation.java
@@ -14,6 +14,7 @@
import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.CLASS_NAME;
import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.GENERATE_DD;
import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS;
+import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.REGISTER_IN_WEB_XML;
import java.lang.reflect.InvocationTargetException;
@@ -67,7 +68,7 @@
qualifiedClassName = createClass();
// If the filter is not annotated, generate the filter metadata for the DD
- if (!model.getBooleanProperty(USE_ANNOTATIONS))
+ if (!model.getBooleanProperty(USE_ANNOTATIONS) && model.getBooleanProperty(REGISTER_IN_WEB_XML))
{
if (model.getBooleanProperty(GENERATE_DD))
{
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateFilterTemplateModel.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateFilterTemplateModel.java
index 3343612..8df18c0 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateFilterTemplateModel.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateFilterTemplateModel.java
@@ -23,12 +23,14 @@
import static org.eclipse.jst.j2ee.web.IServletConstants.METHOD_DESTROY;
import static org.eclipse.jst.j2ee.web.IServletConstants.METHOD_DO_FILTER;
import static org.eclipse.jst.j2ee.web.IServletConstants.METHOD_INIT;
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_ANNOTATION_INIT_PARAM;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_FILTER_CHAIN;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_FILTER_CONFIG;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_IO_EXCEPTION;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_EXCEPTION;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_RESPONSE;
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_WEB_FILTER;
import java.util.ArrayList;
import java.util.Collection;
@@ -65,6 +67,12 @@
collection.add(QUALIFIED_IO_EXCEPTION);
collection.add(QUALIFIED_SERVLET_EXCEPTION);
}
+ if (SERVLET_3.equals(getJavaEEVersion())){
+ collection.add(QUALIFIED_WEB_FILTER);
+ if (getInitParams()!= null && getInitParams().size()>0){
+ collection.add(QUALIFIED_ANNOTATION_INIT_PARAM);
+ }
+ }
return collection;
}
@@ -167,5 +175,46 @@
return unimplementedMethods;
}
+
+ public String getJavaEE6AnnotationParameters(){
+ String result = "("; //$NON-NLS-1$
+ List<IFilterMappingItem> filterMappings = getFilterMappings();
+ if (filterMappings != null && filterMappings.size()>0 && hasUrlMapping(filterMappings)){
+ result+="urlPatterns={"; //$NON-NLS-1$
+ for (IFilterMappingItem filterMapItem : filterMappings) {
+ result+="\""+filterMapItem.getName()+"\","; //$NON-NLS-1$//$NON-NLS-2$
+ }
+ result = result.substring(0, result.length()-1);
+ result+='}';
+
+ }
+ List<String[]> initParams = getInitParams();
+ if (initParams != null && initParams.size()>0){
+ if (result.length() > 1){
+ result+=", "; //$NON-NLS-1$
+ }
+ result+="initParams={"; //$NON-NLS-1$
+ for (String[] iParams : initParams) {
+ result+=generateInitParamAnnotation(iParams[0], iParams[1]) + ","; //$NON-NLS-1$
+ }
+ result = result.substring(0, result.length()-1);
+ result+="}"; //$NON-NLS-1$
+ }
+ result+=")"; //$NON-NLS-1$
+ return result.length() > 2 ? result : ""; //$NON-NLS-1$
+ }
+
+ private boolean hasUrlMapping(List<IFilterMappingItem> filterMappings) {
+ for (IFilterMappingItem filterMapItem : filterMappings) {
+ if (filterMapItem.isUrlPatternType()){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private String generateInitParamAnnotation(String name, String value){
+ return "@WebInitParam(name=\""+name+"\", value=\""+value+"\")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
}
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateListenerTemplateModel.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateListenerTemplateModel.java
index f4324f3..0bad932 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateListenerTemplateModel.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateListenerTemplateModel.java
@@ -24,6 +24,7 @@
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_EVENT;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_LISTENER;
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_WEB_LISTENER;
import java.util.Collection;
import java.util.List;
@@ -76,6 +77,10 @@
collection.add(QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_EVENT);
}
+ if (SERVLET_3.equals(getJavaEEVersion())){
+ collection.add(QUALIFIED_WEB_LISTENER);
+ }
+
return collection;
}
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateServletTemplateModel.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateServletTemplateModel.java
index d57c1ad..8130ea5 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateServletTemplateModel.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateServletTemplateModel.java
@@ -60,6 +60,8 @@
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_EXCEPTION;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_RESPONSE;
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_WEB_SERVLET;
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_ANNOTATION_INIT_PARAM;
import static org.eclipse.jst.j2ee.web.IServletConstants.SERVICE_SIGNATURE;
import static org.eclipse.jst.j2ee.web.IServletConstants.SERVLET_INIT_SIGNATURE;
@@ -118,6 +120,16 @@
collection.add(QUALIFIED_IO_EXCEPTION);
}
+ if (SERVLET_3.equals(getJavaEEVersion())){
+ collection.add(QUALIFIED_WEB_SERVLET);
+ if (getInitParams()!= null && getInitParams().size()>0){
+ collection.add(QUALIFIED_ANNOTATION_INIT_PARAM);
+ }
+
+
+
+ }
+
return collection;
}
@@ -287,5 +299,43 @@
return unimplementedMethods;
}
+
+ public String getJavaEE6AnnotationParameters(){
+ String result = "(";
+ if (!getClassName().equals(getServletName())){
+ result+="name=\""+getServletName()+"\"";
+ }
+ List<String[]> servletMappings = getServletMappings();
+ if (servletMappings != null && servletMappings.size()>0){
+ if (result.length() > 1){
+ result+=", ";
+ }
+ result+="urlPatterns={";
+ for (String[] strings : servletMappings) {
+ result+="\""+strings[0]+"\",";
+ }
+ result = result.substring(0, result.length()-1);
+ result+='}';
+
+ }
+ List<String[]> initParams = getInitParams();
+ if (initParams != null && initParams.size()>0){
+ if (result.length() > 1){
+ result+=", ";
+ }
+ result+="initParams={";
+ for (String[] iParams : initParams) {
+ result+=generateInitParamAnnotation(iParams[0], iParams[1]) + ",";
+ }
+ result = result.substring(0, result.length()-1);
+ result+="}";
+ }
+ result+=")";
+ return result.length() > 2 ? result : ""; //$NON-NLS-1$
+ }
+
+ private String generateInitParamAnnotation(String name, String value){
+ return "@WebInitParam(name=\""+name+"\", value=\""+value+"\")";
+ }
}
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateWebClassTemplateModel.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateWebClassTemplateModel.java
index aaa08c3..63eccaa 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateWebClassTemplateModel.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/CreateWebClassTemplateModel.java
@@ -14,6 +14,7 @@
import static org.eclipse.jst.j2ee.application.internal.operations.IAnnotationsDataModel.USE_ANNOTATIONS;
import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DESCRIPTION;
import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DISPLAY_NAME;
+import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.JAVA_EE_VERSION;
import org.eclipse.jst.j2ee.internal.common.operations.CreateJavaEEArtifactTemplateModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
@@ -21,6 +22,8 @@
public class CreateWebClassTemplateModel extends
CreateJavaEEArtifactTemplateModel {
+ public static final String SERVLET_3 = "3.0"; //$NON-NLS-1$
+
public CreateWebClassTemplateModel(IDataModel dataModel) {
super(dataModel);
}
@@ -36,5 +39,9 @@
public boolean isAnnotated() {
return dataModel.getBooleanProperty(USE_ANNOTATIONS);
}
+
+ public String getJavaEEVersion() {
+ return dataModel.getStringProperty(JAVA_EE_VERSION);
+ }
}
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/FilterTemplate.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/FilterTemplate.java
index d01da3f..569b5d8 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/FilterTemplate.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/FilterTemplate.java
@@ -14,65 +14,66 @@
return result;
}
- public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; //$NON-NLS-1$
- protected final String TEXT_1 = "package "; //$NON-NLS-1$
- protected final String TEXT_2 = ";"; //$NON-NLS-1$
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "package ";
+ protected final String TEXT_2 = ";";
protected final String TEXT_3 = NL;
- protected final String TEXT_4 = NL + "import "; //$NON-NLS-1$
- protected final String TEXT_5 = ";"; //$NON-NLS-1$
+ protected final String TEXT_4 = NL + "import ";
+ protected final String TEXT_5 = ";";
protected final String TEXT_6 = NL;
protected final String TEXT_7 = NL;
- protected final String TEXT_8 = "/**" + NL + " * Servlet Filter implementation class "; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_9 = NL + " *" + NL + " * @web.filter" + NL + " * name=\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_10 = "\"" + NL + " * display-name=\""; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_11 = "\""; //$NON-NLS-1$
- protected final String TEXT_12 = NL + " * description=\""; //$NON-NLS-1$
- protected final String TEXT_13 = "\""; //$NON-NLS-1$
- protected final String TEXT_14 = NL + " *" + NL + " * @web.filter-mapping"; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_15 = NL + " * url-pattern=\""; //$NON-NLS-1$
- protected final String TEXT_16 = "\""; //$NON-NLS-1$
- protected final String TEXT_17 = NL + " * servlet-name=\""; //$NON-NLS-1$
- protected final String TEXT_18 = "\""; //$NON-NLS-1$
- protected final String TEXT_19 = NL + " * dispatcher=\""; //$NON-NLS-1$
- protected final String TEXT_20 = "\""; //$NON-NLS-1$
- protected final String TEXT_21 = NL + " *" + NL + " * @web.filter-init-param" + NL + " * name=\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_22 = "\"" + NL + " * value=\""; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_23 = "\""; //$NON-NLS-1$
- protected final String TEXT_24 = NL + " * description=\""; //$NON-NLS-1$
- protected final String TEXT_25 = "\""; //$NON-NLS-1$
- protected final String TEXT_26 = NL + " */"; //$NON-NLS-1$
- protected final String TEXT_27 = NL + "public "; //$NON-NLS-1$
- protected final String TEXT_28 = "abstract "; //$NON-NLS-1$
- protected final String TEXT_29 = "final "; //$NON-NLS-1$
- protected final String TEXT_30 = "class "; //$NON-NLS-1$
- protected final String TEXT_31 = " extends "; //$NON-NLS-1$
- protected final String TEXT_32 = " implements "; //$NON-NLS-1$
- protected final String TEXT_33 = ", "; //$NON-NLS-1$
- protected final String TEXT_34 = " {"; //$NON-NLS-1$
- protected final String TEXT_35 = NL + NL + " /**" + NL + " * Default constructor. " + NL + " */" + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- protected final String TEXT_36 = "() {" + NL + " // TODO Auto-generated constructor stub" + NL + " }"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_37 = NL + " " + NL + " /**" + NL + " * @see "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_38 = "#"; //$NON-NLS-1$
- protected final String TEXT_39 = "("; //$NON-NLS-1$
- protected final String TEXT_40 = ")" + NL + " */" + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_41 = "("; //$NON-NLS-1$
- protected final String TEXT_42 = ") {" + NL + " super("; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_43 = ");" + NL + " // TODO Auto-generated constructor stub" + NL + " }"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_44 = NL + NL + "\t/**" + NL + " * @see "; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_45 = "#"; //$NON-NLS-1$
- protected final String TEXT_46 = "("; //$NON-NLS-1$
- protected final String TEXT_47 = ")" + NL + " */" + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_48 = " "; //$NON-NLS-1$
- protected final String TEXT_49 = "("; //$NON-NLS-1$
- protected final String TEXT_50 = ") {" + NL + " // TODO Auto-generated method stub"; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_51 = NL + "\t\t\treturn "; //$NON-NLS-1$
- protected final String TEXT_52 = ";"; //$NON-NLS-1$
- protected final String TEXT_53 = NL + " }"; //$NON-NLS-1$
- protected final String TEXT_54 = NL + NL + "\t/**" + NL + "\t * @see Filter#destroy()" + NL + "\t */" + NL + "\tpublic void destroy() {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_55 = NL + NL + "\t/**" + NL + "\t * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)" + NL + "\t */" + NL + "\tpublic void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t\t// place your code here" + NL + "" + NL + "\t\t// pass the request along the filter chain" + NL + "\t\tchain.doFilter(request, response);" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
- protected final String TEXT_56 = NL + NL + "\t/**" + NL + "\t * @see Filter#init(FilterConfig)" + NL + "\t */" + NL + "\tpublic void init(FilterConfig fConfig) throws ServletException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_57 = NL + NL + "}"; //$NON-NLS-1$
- protected final String TEXT_58 = NL;
+ protected final String TEXT_8 = "/**" + NL + " * Servlet Filter implementation class ";
+ protected final String TEXT_9 = NL + " *" + NL + " * @web.filter" + NL + " * name=\"";
+ protected final String TEXT_10 = "\"" + NL + " * display-name=\"";
+ protected final String TEXT_11 = "\"";
+ protected final String TEXT_12 = NL + " * description=\"";
+ protected final String TEXT_13 = "\"";
+ protected final String TEXT_14 = NL + " *" + NL + " * @web.filter-mapping";
+ protected final String TEXT_15 = NL + " * url-pattern=\"";
+ protected final String TEXT_16 = "\"";
+ protected final String TEXT_17 = NL + " * servlet-name=\"";
+ protected final String TEXT_18 = "\"";
+ protected final String TEXT_19 = NL + " * dispatcher=\"";
+ protected final String TEXT_20 = "\"";
+ protected final String TEXT_21 = NL + " *" + NL + " * @web.filter-init-param" + NL + " * name=\"";
+ protected final String TEXT_22 = "\"" + NL + " * value=\"";
+ protected final String TEXT_23 = "\"";
+ protected final String TEXT_24 = NL + " * description=\"";
+ protected final String TEXT_25 = "\"";
+ protected final String TEXT_26 = NL + " */";
+ protected final String TEXT_27 = NL + "@WebFilter";
+ protected final String TEXT_28 = NL + "public ";
+ protected final String TEXT_29 = "abstract ";
+ protected final String TEXT_30 = "final ";
+ protected final String TEXT_31 = "class ";
+ protected final String TEXT_32 = " extends ";
+ protected final String TEXT_33 = " implements ";
+ protected final String TEXT_34 = ", ";
+ protected final String TEXT_35 = " {";
+ protected final String TEXT_36 = NL + NL + " /**" + NL + " * Default constructor. " + NL + " */" + NL + " public ";
+ protected final String TEXT_37 = "() {" + NL + " // TODO Auto-generated constructor stub" + NL + " }";
+ protected final String TEXT_38 = NL + " " + NL + " /**" + NL + " * @see ";
+ protected final String TEXT_39 = "#";
+ protected final String TEXT_40 = "(";
+ protected final String TEXT_41 = ")" + NL + " */" + NL + " public ";
+ protected final String TEXT_42 = "(";
+ protected final String TEXT_43 = ") {" + NL + " super(";
+ protected final String TEXT_44 = ");" + NL + " // TODO Auto-generated constructor stub" + NL + " }";
+ protected final String TEXT_45 = NL + NL + "\t/**" + NL + " * @see ";
+ protected final String TEXT_46 = "#";
+ protected final String TEXT_47 = "(";
+ protected final String TEXT_48 = ")" + NL + " */" + NL + " public ";
+ protected final String TEXT_49 = " ";
+ protected final String TEXT_50 = "(";
+ protected final String TEXT_51 = ") {" + NL + " // TODO Auto-generated method stub";
+ protected final String TEXT_52 = NL + "\t\t\treturn ";
+ protected final String TEXT_53 = ";";
+ protected final String TEXT_54 = NL + " }";
+ protected final String TEXT_55 = NL + NL + "\t/**" + NL + "\t * @see Filter#destroy()" + NL + "\t */" + NL + "\tpublic void destroy() {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_56 = NL + NL + "\t/**" + NL + "\t * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)" + NL + "\t */" + NL + "\tpublic void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t\t// place your code here" + NL + "" + NL + "\t\t// pass the request along the filter chain" + NL + "\t\tchain.doFilter(request, response);" + NL + "\t}";
+ protected final String TEXT_57 = NL + NL + "\t/**" + NL + "\t * @see Filter#init(FilterConfig)" + NL + "\t */" + NL + "\tpublic void init(FilterConfig fConfig) throws ServletException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_58 = NL + NL + "}";
+ protected final String TEXT_59 = NL;
public String generate(Object argument)
{
@@ -176,32 +177,40 @@
}
stringBuffer.append(TEXT_26);
+
+ if ("3.0".equals(model.getJavaEEVersion())) {
+
+ stringBuffer.append(TEXT_27);
+ stringBuffer.append(model.getJavaEE6AnnotationParameters());
+
+}
+
if (model.isPublic()) {
- stringBuffer.append(TEXT_27);
+ stringBuffer.append(TEXT_28);
}
if (model.isAbstract()) {
- stringBuffer.append(TEXT_28);
+ stringBuffer.append(TEXT_29);
}
if (model.isFinal()) {
- stringBuffer.append(TEXT_29);
+ stringBuffer.append(TEXT_30);
}
- stringBuffer.append(TEXT_30);
+ stringBuffer.append(TEXT_31);
stringBuffer.append( model.getClassName() );
String superClass = model.getSuperclassName();
if (superClass != null && superClass.length() > 0) {
- stringBuffer.append(TEXT_31);
+ stringBuffer.append(TEXT_32);
stringBuffer.append( superClass );
}
@@ -209,7 +218,7 @@
List<String> interfaces = model.getInterfaces();
if ( interfaces.size() > 0) {
- stringBuffer.append(TEXT_32);
+ stringBuffer.append(TEXT_33);
}
@@ -217,7 +226,7 @@
String INTERFACE = interfaces.get(i);
if (i > 0) {
- stringBuffer.append(TEXT_33);
+ stringBuffer.append(TEXT_34);
}
@@ -225,13 +234,13 @@
}
- stringBuffer.append(TEXT_34);
+ stringBuffer.append(TEXT_35);
if (!model.hasEmptySuperclassConstructor()) {
- stringBuffer.append(TEXT_35);
- stringBuffer.append( model.getClassName() );
stringBuffer.append(TEXT_36);
+ stringBuffer.append( model.getClassName() );
+ stringBuffer.append(TEXT_37);
}
@@ -240,19 +249,19 @@
for (Constructor constructor : constructors) {
if (constructor.isPublic() || constructor.isProtected()) {
- stringBuffer.append(TEXT_37);
- stringBuffer.append( model.getSuperclassName() );
stringBuffer.append(TEXT_38);
stringBuffer.append( model.getSuperclassName() );
stringBuffer.append(TEXT_39);
- stringBuffer.append( constructor.getParamsForJavadoc() );
+ stringBuffer.append( model.getSuperclassName() );
stringBuffer.append(TEXT_40);
- stringBuffer.append( model.getClassName() );
+ stringBuffer.append( constructor.getParamsForJavadoc() );
stringBuffer.append(TEXT_41);
- stringBuffer.append( constructor.getParamsForDeclaration() );
+ stringBuffer.append( model.getClassName() );
stringBuffer.append(TEXT_42);
- stringBuffer.append( constructor.getParamsForCall() );
+ stringBuffer.append( constructor.getParamsForDeclaration() );
stringBuffer.append(TEXT_43);
+ stringBuffer.append( constructor.getParamsForCall() );
+ stringBuffer.append(TEXT_44);
}
}
@@ -262,45 +271,45 @@
if (model.shouldImplementAbstractMethods()) {
for (Method method : model.getUnimplementedMethods()) {
- stringBuffer.append(TEXT_44);
- stringBuffer.append( method.getContainingJavaClass() );
stringBuffer.append(TEXT_45);
- stringBuffer.append( method.getName() );
+ stringBuffer.append( method.getContainingJavaClass() );
stringBuffer.append(TEXT_46);
- stringBuffer.append( method.getParamsForJavadoc() );
- stringBuffer.append(TEXT_47);
- stringBuffer.append( method.getReturnType() );
- stringBuffer.append(TEXT_48);
stringBuffer.append( method.getName() );
+ stringBuffer.append(TEXT_47);
+ stringBuffer.append( method.getParamsForJavadoc() );
+ stringBuffer.append(TEXT_48);
+ stringBuffer.append( method.getReturnType() );
stringBuffer.append(TEXT_49);
- stringBuffer.append( method.getParamsForDeclaration() );
+ stringBuffer.append( method.getName() );
stringBuffer.append(TEXT_50);
+ stringBuffer.append( method.getParamsForDeclaration() );
+ stringBuffer.append(TEXT_51);
String defaultReturnValue = method.getDefaultReturnValue();
if (defaultReturnValue != null) {
- stringBuffer.append(TEXT_51);
- stringBuffer.append( defaultReturnValue );
stringBuffer.append(TEXT_52);
+ stringBuffer.append( defaultReturnValue );
+ stringBuffer.append(TEXT_53);
}
- stringBuffer.append(TEXT_53);
+ stringBuffer.append(TEXT_54);
}
}
if (model.shouldGenDestroy()) {
- stringBuffer.append(TEXT_54);
- }
- if (model.shouldGenDoFilter()) {
stringBuffer.append(TEXT_55);
}
- if (model.shouldGenInit()) {
+ if (model.shouldGenDoFilter()) {
stringBuffer.append(TEXT_56);
}
+ if (model.shouldGenInit()) {
stringBuffer.append(TEXT_57);
+ }
stringBuffer.append(TEXT_58);
+ stringBuffer.append(TEXT_59);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/INewWebClassDataModelProperties.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/INewWebClassDataModelProperties.java
index c40d486..5650d41 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/INewWebClassDataModelProperties.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/INewWebClassDataModelProperties.java
@@ -31,4 +31,15 @@
*/
public static final String USE_EXISTING_CLASS = "NewServletClassDataModel.USE_EXISTING_CLASS"; //$NON-NLS-1$
+ /**
+ * Optional, boolean property used to specify whether or not to generate artifacts in web.xml
+ */
+ public static final String REGISTER_IN_WEB_XML = "NewServletClassDataModel.REGISTER_IN_WEB_XML"; //$NON-NLS-1$
+
+ /**
+ * Optional, boolean property used to specify whether or not to generate artifacts in web.xml
+ */
+ public static final String JAVA_EE_VERSION = "NewServletClassDataModel.JAVA_EE_VERSION"; //$NON-NLS-1$
+
+
}
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/ListenerTemplate.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/ListenerTemplate.java
index 5c0f5bd..3e2358a 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/ListenerTemplate.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/ListenerTemplate.java
@@ -14,47 +14,48 @@
return result;
}
- public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; //$NON-NLS-1$
- protected final String TEXT_1 = "package "; //$NON-NLS-1$
- protected final String TEXT_2 = ";"; //$NON-NLS-1$
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "package ";
+ protected final String TEXT_2 = ";";
protected final String TEXT_3 = NL;
- protected final String TEXT_4 = NL + "import "; //$NON-NLS-1$
- protected final String TEXT_5 = ";"; //$NON-NLS-1$
+ protected final String TEXT_4 = NL + "import ";
+ protected final String TEXT_5 = ";";
protected final String TEXT_6 = NL;
protected final String TEXT_7 = NL;
- protected final String TEXT_8 = "/**" + NL + " * Application Lifecycle Listener implementation class "; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_9 = NL + " *"; //$NON-NLS-1$
- protected final String TEXT_10 = NL + " * @web.listener"; //$NON-NLS-1$
- protected final String TEXT_11 = NL + " */"; //$NON-NLS-1$
- protected final String TEXT_12 = NL + "public "; //$NON-NLS-1$
- protected final String TEXT_13 = "abstract "; //$NON-NLS-1$
- protected final String TEXT_14 = "final "; //$NON-NLS-1$
- protected final String TEXT_15 = "class "; //$NON-NLS-1$
- protected final String TEXT_16 = " extends "; //$NON-NLS-1$
- protected final String TEXT_17 = " implements "; //$NON-NLS-1$
- protected final String TEXT_18 = ", "; //$NON-NLS-1$
- protected final String TEXT_19 = " {"; //$NON-NLS-1$
- protected final String TEXT_20 = NL + NL + " /**" + NL + " * Default constructor. " + NL + " */" + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- protected final String TEXT_21 = "() {" + NL + " // TODO Auto-generated constructor stub" + NL + " }"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_22 = NL + " " + NL + " /**" + NL + " * @see "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_23 = "#"; //$NON-NLS-1$
- protected final String TEXT_24 = "("; //$NON-NLS-1$
- protected final String TEXT_25 = ")" + NL + " */" + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_26 = "("; //$NON-NLS-1$
- protected final String TEXT_27 = ") {" + NL + " super("; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_28 = ");" + NL + " // TODO Auto-generated constructor stub" + NL + " }"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_29 = NL + NL + "\t/**" + NL + " * @see "; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_30 = "#"; //$NON-NLS-1$
- protected final String TEXT_31 = "("; //$NON-NLS-1$
- protected final String TEXT_32 = ")" + NL + " */" + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_33 = " "; //$NON-NLS-1$
- protected final String TEXT_34 = "("; //$NON-NLS-1$
- protected final String TEXT_35 = ") {" + NL + " // TODO Auto-generated method stub"; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_36 = NL + "\t\t\treturn "; //$NON-NLS-1$
- protected final String TEXT_37 = ";"; //$NON-NLS-1$
- protected final String TEXT_38 = NL + " }"; //$NON-NLS-1$
- protected final String TEXT_39 = NL + "\t" + NL + "}"; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_40 = NL;
+ protected final String TEXT_8 = "/**" + NL + " * Application Lifecycle Listener implementation class ";
+ protected final String TEXT_9 = NL + " *";
+ protected final String TEXT_10 = NL + " * @web.listener";
+ protected final String TEXT_11 = NL + " */";
+ protected final String TEXT_12 = NL + "@WebListener";
+ protected final String TEXT_13 = NL + "public ";
+ protected final String TEXT_14 = "abstract ";
+ protected final String TEXT_15 = "final ";
+ protected final String TEXT_16 = "class ";
+ protected final String TEXT_17 = " extends ";
+ protected final String TEXT_18 = " implements ";
+ protected final String TEXT_19 = ", ";
+ protected final String TEXT_20 = " {";
+ protected final String TEXT_21 = NL + NL + " /**" + NL + " * Default constructor. " + NL + " */" + NL + " public ";
+ protected final String TEXT_22 = "() {" + NL + " // TODO Auto-generated constructor stub" + NL + " }";
+ protected final String TEXT_23 = NL + " " + NL + " /**" + NL + " * @see ";
+ protected final String TEXT_24 = "#";
+ protected final String TEXT_25 = "(";
+ protected final String TEXT_26 = ")" + NL + " */" + NL + " public ";
+ protected final String TEXT_27 = "(";
+ protected final String TEXT_28 = ") {" + NL + " super(";
+ protected final String TEXT_29 = ");" + NL + " // TODO Auto-generated constructor stub" + NL + " }";
+ protected final String TEXT_30 = NL + NL + "\t/**" + NL + " * @see ";
+ protected final String TEXT_31 = "#";
+ protected final String TEXT_32 = "(";
+ protected final String TEXT_33 = ")" + NL + " */" + NL + " public ";
+ protected final String TEXT_34 = " ";
+ protected final String TEXT_35 = "(";
+ protected final String TEXT_36 = ") {" + NL + " // TODO Auto-generated method stub";
+ protected final String TEXT_37 = NL + "\t\t\treturn ";
+ protected final String TEXT_38 = ";";
+ protected final String TEXT_39 = NL + " }";
+ protected final String TEXT_40 = NL + "\t" + NL + "}";
+ protected final String TEXT_41 = NL;
public String generate(Object argument)
{
@@ -96,32 +97,39 @@
}
stringBuffer.append(TEXT_11);
+
+ if ("3.0".equals(model.getJavaEEVersion())) {
+
+ stringBuffer.append(TEXT_12);
+
+}
+
if (model.isPublic()) {
- stringBuffer.append(TEXT_12);
+ stringBuffer.append(TEXT_13);
}
if (model.isAbstract()) {
- stringBuffer.append(TEXT_13);
+ stringBuffer.append(TEXT_14);
}
if (model.isFinal()) {
- stringBuffer.append(TEXT_14);
+ stringBuffer.append(TEXT_15);
}
- stringBuffer.append(TEXT_15);
+ stringBuffer.append(TEXT_16);
stringBuffer.append( model.getClassName() );
String superClass = model.getSuperclassName();
if (superClass != null && superClass.length() > 0) {
- stringBuffer.append(TEXT_16);
+ stringBuffer.append(TEXT_17);
stringBuffer.append( superClass );
}
@@ -129,7 +137,7 @@
List<String> interfaces = model.getInterfaces();
if ( interfaces.size() > 0) {
- stringBuffer.append(TEXT_17);
+ stringBuffer.append(TEXT_18);
}
@@ -137,7 +145,7 @@
String INTERFACE = interfaces.get(i);
if (i > 0) {
- stringBuffer.append(TEXT_18);
+ stringBuffer.append(TEXT_19);
}
@@ -145,13 +153,13 @@
}
- stringBuffer.append(TEXT_19);
+ stringBuffer.append(TEXT_20);
if (!model.hasEmptySuperclassConstructor()) {
- stringBuffer.append(TEXT_20);
- stringBuffer.append( model.getClassName() );
stringBuffer.append(TEXT_21);
+ stringBuffer.append( model.getClassName() );
+ stringBuffer.append(TEXT_22);
}
@@ -160,19 +168,19 @@
for (Constructor constructor : constructors) {
if (constructor.isPublic() || constructor.isProtected()) {
- stringBuffer.append(TEXT_22);
- stringBuffer.append( model.getSuperclassName() );
stringBuffer.append(TEXT_23);
stringBuffer.append( model.getSuperclassName() );
stringBuffer.append(TEXT_24);
- stringBuffer.append( constructor.getParamsForJavadoc() );
+ stringBuffer.append( model.getSuperclassName() );
stringBuffer.append(TEXT_25);
- stringBuffer.append( model.getClassName() );
+ stringBuffer.append( constructor.getParamsForJavadoc() );
stringBuffer.append(TEXT_26);
- stringBuffer.append( constructor.getParamsForDeclaration() );
+ stringBuffer.append( model.getClassName() );
stringBuffer.append(TEXT_27);
- stringBuffer.append( constructor.getParamsForCall() );
+ stringBuffer.append( constructor.getParamsForDeclaration() );
stringBuffer.append(TEXT_28);
+ stringBuffer.append( constructor.getParamsForCall() );
+ stringBuffer.append(TEXT_29);
}
}
@@ -182,36 +190,36 @@
if (model.shouldImplementAbstractMethods()) {
for (Method method : model.getUnimplementedMethods()) {
- stringBuffer.append(TEXT_29);
- stringBuffer.append( method.getContainingJavaClass() );
stringBuffer.append(TEXT_30);
- stringBuffer.append( method.getName() );
+ stringBuffer.append( method.getContainingJavaClass() );
stringBuffer.append(TEXT_31);
- stringBuffer.append( method.getParamsForJavadoc() );
- stringBuffer.append(TEXT_32);
- stringBuffer.append( method.getReturnType() );
- stringBuffer.append(TEXT_33);
stringBuffer.append( method.getName() );
+ stringBuffer.append(TEXT_32);
+ stringBuffer.append( method.getParamsForJavadoc() );
+ stringBuffer.append(TEXT_33);
+ stringBuffer.append( method.getReturnType() );
stringBuffer.append(TEXT_34);
- stringBuffer.append( method.getParamsForDeclaration() );
+ stringBuffer.append( method.getName() );
stringBuffer.append(TEXT_35);
+ stringBuffer.append( method.getParamsForDeclaration() );
+ stringBuffer.append(TEXT_36);
String defaultReturnValue = method.getDefaultReturnValue();
if (defaultReturnValue != null) {
- stringBuffer.append(TEXT_36);
- stringBuffer.append( defaultReturnValue );
stringBuffer.append(TEXT_37);
+ stringBuffer.append( defaultReturnValue );
+ stringBuffer.append(TEXT_38);
}
- stringBuffer.append(TEXT_38);
+ stringBuffer.append(TEXT_39);
}
}
- stringBuffer.append(TEXT_39);
stringBuffer.append(TEXT_40);
+ stringBuffer.append(TEXT_41);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewWebClassDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewWebClassDataModelProvider.java
index 474740f..c075a1b 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewWebClassDataModelProvider.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewWebClassDataModelProvider.java
@@ -19,6 +19,8 @@
import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties.SUPERCLASS;
import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DESCRIPTION;
import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.DISPLAY_NAME;
+import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.JAVA_EE_VERSION;
+import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.REGISTER_IN_WEB_XML;
import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS;
import java.io.File;
@@ -26,6 +28,8 @@
import java.util.Set;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
@@ -34,9 +38,12 @@
import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil;
import org.eclipse.jst.j2ee.internal.common.operations.NewJavaClassDataModelProvider;
import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.j2ee.web.project.facet.WebFacetUtils;
+import org.eclipse.wst.common.componentcore.internal.util.FacetedProjectUtilities;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
+import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
/**
* The NewWebClassDataModelProvider is a subclass of
@@ -128,11 +135,12 @@
public Set getPropertyNames() {
// Add web artifact specific properties defined in this data model
Set propertyNames = super.getPropertyNames();
-
+ propertyNames.add(REGISTER_IN_WEB_XML);
propertyNames.add(DISPLAY_NAME);
propertyNames.add(DESCRIPTION);
propertyNames.add(USE_EXISTING_CLASS);
propertyNames.add(USE_ANNOTATIONS);
+ propertyNames.add(JAVA_EE_VERSION);
return propertyNames;
}
@@ -161,11 +169,34 @@
return Boolean.FALSE;
else if (propertyName.equals(CONSTRUCTOR))
return hasSuperClass();
-
+ else if (propertyName.equals(REGISTER_IN_WEB_XML)){
+ return !isJavaEE6Project();
+ } else if (JAVA_EE_VERSION.equals(propertyName)){
+ return getJavaEEVersion();
+ }
// Otherwise check super for default value for property
return super.getDefaultProperty(propertyName);
}
+ @SuppressWarnings("restriction")
+ public boolean isJavaEE6Project() {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getStringProperty(PROJECT_NAME));
+ if (project != null && project.isAccessible()){
+ try {
+ return FacetedProjectFramework.hasProjectFacet(project, WebFacetUtils.WEB_FACET.getId(), WebFacetUtils.WEB_30.getVersionString());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ @SuppressWarnings("restriction")
+ public String getJavaEEVersion() {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getStringProperty(PROJECT_NAME));
+ return FacetedProjectUtilities.getProjectFacetVersion(project, WebFacetUtils.WEB_FACET.getId()).getVersionString();
+ }
+
/**
* Subclasses may extend this method to add their own specific behavior when
* a certain property in the data model hierarchy is set. this method does
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/ServletTemplate.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/ServletTemplate.java
index e398e57..0d548fb 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/ServletTemplate.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/ServletTemplate.java
@@ -14,71 +14,72 @@
return result;
}
- public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; //$NON-NLS-1$
- protected final String TEXT_1 = "package "; //$NON-NLS-1$
- protected final String TEXT_2 = ";"; //$NON-NLS-1$
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "package ";
+ protected final String TEXT_2 = ";";
protected final String TEXT_3 = NL;
- protected final String TEXT_4 = NL + "import "; //$NON-NLS-1$
- protected final String TEXT_5 = ";"; //$NON-NLS-1$
+ protected final String TEXT_4 = NL + "import ";
+ protected final String TEXT_5 = ";";
protected final String TEXT_6 = NL;
protected final String TEXT_7 = NL;
- protected final String TEXT_8 = "/**" + NL + " * Servlet implementation class "; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_9 = NL + " *" + NL + " * @web.servlet" + NL + " * name=\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_10 = "\"" + NL + " * display-name=\""; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_11 = "\""; //$NON-NLS-1$
- protected final String TEXT_12 = NL + " * description=\""; //$NON-NLS-1$
- protected final String TEXT_13 = "\""; //$NON-NLS-1$
- protected final String TEXT_14 = NL + " *" + NL + " * @web.servlet-mapping" + NL + " * url-pattern=\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_15 = "\""; //$NON-NLS-1$
- protected final String TEXT_16 = NL + " *" + NL + " * @web.servlet-init-param" + NL + " * name=\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_17 = "\"" + NL + " * value=\""; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_18 = "\""; //$NON-NLS-1$
- protected final String TEXT_19 = NL + " * description=\""; //$NON-NLS-1$
- protected final String TEXT_20 = "\""; //$NON-NLS-1$
- protected final String TEXT_21 = NL + " */"; //$NON-NLS-1$
- protected final String TEXT_22 = NL + "public "; //$NON-NLS-1$
- protected final String TEXT_23 = "abstract "; //$NON-NLS-1$
- protected final String TEXT_24 = "final "; //$NON-NLS-1$
- protected final String TEXT_25 = "class "; //$NON-NLS-1$
- protected final String TEXT_26 = " extends "; //$NON-NLS-1$
- protected final String TEXT_27 = " implements "; //$NON-NLS-1$
- protected final String TEXT_28 = ", "; //$NON-NLS-1$
- protected final String TEXT_29 = " {"; //$NON-NLS-1$
- protected final String TEXT_30 = NL + "\tprivate static final long serialVersionUID = 1L;"; //$NON-NLS-1$
- protected final String TEXT_31 = NL + NL + " /**" + NL + " * Default constructor. " + NL + " */" + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- protected final String TEXT_32 = "() {" + NL + " // TODO Auto-generated constructor stub" + NL + " }"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_33 = NL + " " + NL + " /**" + NL + " * @see "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_34 = "#"; //$NON-NLS-1$
- protected final String TEXT_35 = "("; //$NON-NLS-1$
- protected final String TEXT_36 = ")" + NL + " */" + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_37 = "("; //$NON-NLS-1$
- protected final String TEXT_38 = ") {" + NL + " super("; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_39 = ");" + NL + " // TODO Auto-generated constructor stub" + NL + " }"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_40 = NL + NL + "\t/**" + NL + " * @see "; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_41 = "#"; //$NON-NLS-1$
- protected final String TEXT_42 = "("; //$NON-NLS-1$
- protected final String TEXT_43 = ")" + NL + " */" + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- protected final String TEXT_44 = " "; //$NON-NLS-1$
- protected final String TEXT_45 = "("; //$NON-NLS-1$
- protected final String TEXT_46 = ") {" + NL + " // TODO Auto-generated method stub"; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_47 = NL + "\t\t\treturn "; //$NON-NLS-1$
- protected final String TEXT_48 = ";"; //$NON-NLS-1$
- protected final String TEXT_49 = NL + " }"; //$NON-NLS-1$
- protected final String TEXT_50 = NL + NL + "\t/**" + NL + "\t * @see Servlet#init(ServletConfig)" + NL + "\t */" + NL + "\tpublic void init(ServletConfig config) throws ServletException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_51 = NL + NL + "\t/**" + NL + "\t * @see Servlet#destroy()" + NL + "\t */" + NL + "\tpublic void destroy() {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_52 = NL + NL + "\t/**" + NL + "\t * @see Servlet#getServletConfig()" + NL + "\t */" + NL + "\tpublic ServletConfig getServletConfig() {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t\treturn null;" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- protected final String TEXT_53 = NL + NL + "\t/**" + NL + "\t * @see Servlet#getServletInfo()" + NL + "\t */" + NL + "\tpublic String getServletInfo() {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t\treturn null; " + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- protected final String TEXT_54 = NL + NL + "\t/**" + NL + "\t * @see Servlet#service(ServletRequest request, ServletResponse response)" + NL + "\t */" + NL + "\tpublic void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_55 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)" + NL + "\t */" + NL + "\tprotected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_56 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)" + NL + "\t */" + NL + "\tprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_57 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)" + NL + "\t */" + NL + "\tprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_58 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doPut(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_59 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doDelete(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_60 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doHead(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_61 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doOptions(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_62 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doTrace(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doTrace(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- protected final String TEXT_63 = NL + NL + "}"; //$NON-NLS-1$
- protected final String TEXT_64 = NL;
+ protected final String TEXT_8 = "/**" + NL + " * Servlet implementation class ";
+ protected final String TEXT_9 = NL + " *" + NL + " * @web.servlet" + NL + " * name=\"";
+ protected final String TEXT_10 = "\"" + NL + " * display-name=\"";
+ protected final String TEXT_11 = "\"";
+ protected final String TEXT_12 = NL + " * description=\"";
+ protected final String TEXT_13 = "\"";
+ protected final String TEXT_14 = NL + " *" + NL + " * @web.servlet-mapping" + NL + " * url-pattern=\"";
+ protected final String TEXT_15 = "\"";
+ protected final String TEXT_16 = NL + " *" + NL + " * @web.servlet-init-param" + NL + " * name=\"";
+ protected final String TEXT_17 = "\"" + NL + " * value=\"";
+ protected final String TEXT_18 = "\"";
+ protected final String TEXT_19 = NL + " * description=\"";
+ protected final String TEXT_20 = "\"";
+ protected final String TEXT_21 = NL + " */";
+ protected final String TEXT_22 = NL + "@WebServlet";
+ protected final String TEXT_23 = NL + "public ";
+ protected final String TEXT_24 = "abstract ";
+ protected final String TEXT_25 = "final ";
+ protected final String TEXT_26 = "class ";
+ protected final String TEXT_27 = " extends ";
+ protected final String TEXT_28 = " implements ";
+ protected final String TEXT_29 = ", ";
+ protected final String TEXT_30 = " {";
+ protected final String TEXT_31 = NL + "\tprivate static final long serialVersionUID = 1L;";
+ protected final String TEXT_32 = NL + NL + " /**" + NL + " * Default constructor. " + NL + " */" + NL + " public ";
+ protected final String TEXT_33 = "() {" + NL + " // TODO Auto-generated constructor stub" + NL + " }";
+ protected final String TEXT_34 = NL + " " + NL + " /**" + NL + " * @see ";
+ protected final String TEXT_35 = "#";
+ protected final String TEXT_36 = "(";
+ protected final String TEXT_37 = ")" + NL + " */" + NL + " public ";
+ protected final String TEXT_38 = "(";
+ protected final String TEXT_39 = ") {" + NL + " super(";
+ protected final String TEXT_40 = ");" + NL + " // TODO Auto-generated constructor stub" + NL + " }";
+ protected final String TEXT_41 = NL + NL + "\t/**" + NL + " * @see ";
+ protected final String TEXT_42 = "#";
+ protected final String TEXT_43 = "(";
+ protected final String TEXT_44 = ")" + NL + " */" + NL + " public ";
+ protected final String TEXT_45 = " ";
+ protected final String TEXT_46 = "(";
+ protected final String TEXT_47 = ") {" + NL + " // TODO Auto-generated method stub";
+ protected final String TEXT_48 = NL + "\t\t\treturn ";
+ protected final String TEXT_49 = ";";
+ protected final String TEXT_50 = NL + " }";
+ protected final String TEXT_51 = NL + NL + "\t/**" + NL + "\t * @see Servlet#init(ServletConfig)" + NL + "\t */" + NL + "\tpublic void init(ServletConfig config) throws ServletException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_52 = NL + NL + "\t/**" + NL + "\t * @see Servlet#destroy()" + NL + "\t */" + NL + "\tpublic void destroy() {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_53 = NL + NL + "\t/**" + NL + "\t * @see Servlet#getServletConfig()" + NL + "\t */" + NL + "\tpublic ServletConfig getServletConfig() {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t\treturn null;" + NL + "\t}";
+ protected final String TEXT_54 = NL + NL + "\t/**" + NL + "\t * @see Servlet#getServletInfo()" + NL + "\t */" + NL + "\tpublic String getServletInfo() {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t\treturn null; " + NL + "\t}";
+ protected final String TEXT_55 = NL + NL + "\t/**" + NL + "\t * @see Servlet#service(ServletRequest request, ServletResponse response)" + NL + "\t */" + NL + "\tpublic void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_56 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)" + NL + "\t */" + NL + "\tprotected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_57 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)" + NL + "\t */" + NL + "\tprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_58 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)" + NL + "\t */" + NL + "\tprotected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_59 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doPut(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_60 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doDelete(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_61 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doHead(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_62 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doOptions(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_63 = NL + NL + "\t/**" + NL + "\t * @see HttpServlet#doTrace(HttpServletRequest, HttpServletResponse)" + NL + "\t */" + NL + "\tprotected void doTrace(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {" + NL + "\t\t// TODO Auto-generated method stub" + NL + "\t}";
+ protected final String TEXT_64 = NL + NL + "}";
+ protected final String TEXT_65 = NL;
public String generate(Object argument)
{
@@ -163,32 +164,40 @@
}
stringBuffer.append(TEXT_21);
+
+ if ("3.0".equals(model.getJavaEEVersion())) {
+
+ stringBuffer.append(TEXT_22);
+ stringBuffer.append(model.getJavaEE6AnnotationParameters());
+
+}
+
if (model.isPublic()) {
- stringBuffer.append(TEXT_22);
+ stringBuffer.append(TEXT_23);
}
if (model.isAbstract()) {
- stringBuffer.append(TEXT_23);
+ stringBuffer.append(TEXT_24);
}
if (model.isFinal()) {
- stringBuffer.append(TEXT_24);
+ stringBuffer.append(TEXT_25);
}
- stringBuffer.append(TEXT_25);
+ stringBuffer.append(TEXT_26);
stringBuffer.append( model.getClassName() );
String superClass = model.getSuperclassName();
if (superClass != null && superClass.length() > 0) {
- stringBuffer.append(TEXT_26);
+ stringBuffer.append(TEXT_27);
stringBuffer.append( superClass );
}
@@ -196,7 +205,7 @@
List<String> interfaces = model.getInterfaces();
if ( interfaces.size() > 0) {
- stringBuffer.append(TEXT_27);
+ stringBuffer.append(TEXT_28);
}
@@ -204,7 +213,7 @@
String INTERFACE = interfaces.get(i);
if (i > 0) {
- stringBuffer.append(TEXT_28);
+ stringBuffer.append(TEXT_29);
}
@@ -212,20 +221,20 @@
}
- stringBuffer.append(TEXT_29);
+ stringBuffer.append(TEXT_30);
if (model.isGenericServletSuperclass()) {
- stringBuffer.append(TEXT_30);
+ stringBuffer.append(TEXT_31);
}
if (!model.hasEmptySuperclassConstructor()) {
- stringBuffer.append(TEXT_31);
- stringBuffer.append( model.getClassName() );
stringBuffer.append(TEXT_32);
+ stringBuffer.append( model.getClassName() );
+ stringBuffer.append(TEXT_33);
}
@@ -234,19 +243,19 @@
for (Constructor constructor : constructors) {
if (constructor.isPublic() || constructor.isProtected()) {
- stringBuffer.append(TEXT_33);
- stringBuffer.append( model.getSuperclassName() );
stringBuffer.append(TEXT_34);
stringBuffer.append( model.getSuperclassName() );
stringBuffer.append(TEXT_35);
- stringBuffer.append( constructor.getParamsForJavadoc() );
+ stringBuffer.append( model.getSuperclassName() );
stringBuffer.append(TEXT_36);
- stringBuffer.append( model.getClassName() );
+ stringBuffer.append( constructor.getParamsForJavadoc() );
stringBuffer.append(TEXT_37);
- stringBuffer.append( constructor.getParamsForDeclaration() );
+ stringBuffer.append( model.getClassName() );
stringBuffer.append(TEXT_38);
- stringBuffer.append( constructor.getParamsForCall() );
+ stringBuffer.append( constructor.getParamsForDeclaration() );
stringBuffer.append(TEXT_39);
+ stringBuffer.append( constructor.getParamsForCall() );
+ stringBuffer.append(TEXT_40);
}
}
@@ -256,75 +265,75 @@
if (model.shouldImplementAbstractMethods()) {
for (Method method : model.getUnimplementedMethods()) {
- stringBuffer.append(TEXT_40);
- stringBuffer.append( method.getContainingJavaClass() );
stringBuffer.append(TEXT_41);
- stringBuffer.append( method.getName() );
+ stringBuffer.append( method.getContainingJavaClass() );
stringBuffer.append(TEXT_42);
- stringBuffer.append( method.getParamsForJavadoc() );
- stringBuffer.append(TEXT_43);
- stringBuffer.append( method.getReturnType() );
- stringBuffer.append(TEXT_44);
stringBuffer.append( method.getName() );
+ stringBuffer.append(TEXT_43);
+ stringBuffer.append( method.getParamsForJavadoc() );
+ stringBuffer.append(TEXT_44);
+ stringBuffer.append( method.getReturnType() );
stringBuffer.append(TEXT_45);
- stringBuffer.append( method.getParamsForDeclaration() );
+ stringBuffer.append( method.getName() );
stringBuffer.append(TEXT_46);
+ stringBuffer.append( method.getParamsForDeclaration() );
+ stringBuffer.append(TEXT_47);
String defaultReturnValue = method.getDefaultReturnValue();
if (defaultReturnValue != null) {
- stringBuffer.append(TEXT_47);
- stringBuffer.append( defaultReturnValue );
stringBuffer.append(TEXT_48);
+ stringBuffer.append( defaultReturnValue );
+ stringBuffer.append(TEXT_49);
}
- stringBuffer.append(TEXT_49);
+ stringBuffer.append(TEXT_50);
}
}
if (model.shouldGenInit()) {
- stringBuffer.append(TEXT_50);
- }
- if (model.shouldGenDestroy()) {
stringBuffer.append(TEXT_51);
}
- if (model.shouldGenGetServletConfig()) {
+ if (model.shouldGenDestroy()) {
stringBuffer.append(TEXT_52);
}
- if (model.shouldGenGetServletInfo()) {
+ if (model.shouldGenGetServletConfig()) {
stringBuffer.append(TEXT_53);
}
- if (model.shouldGenService() && !model.isHttpServletSuperclass()) {
+ if (model.shouldGenGetServletInfo()) {
stringBuffer.append(TEXT_54);
}
- if (model.shouldGenService() && model.isHttpServletSuperclass()) {
+ if (model.shouldGenService() && !model.isHttpServletSuperclass()) {
stringBuffer.append(TEXT_55);
}
- if (model.shouldGenDoGet()) {
+ if (model.shouldGenService() && model.isHttpServletSuperclass()) {
stringBuffer.append(TEXT_56);
}
- if (model.shouldGenDoPost()) {
+ if (model.shouldGenDoGet()) {
stringBuffer.append(TEXT_57);
}
- if (model.shouldGenDoPut()) {
+ if (model.shouldGenDoPost()) {
stringBuffer.append(TEXT_58);
}
- if (model.shouldGenDoDelete()) {
+ if (model.shouldGenDoPut()) {
stringBuffer.append(TEXT_59);
}
- if (model.shouldGenDoHead()) {
+ if (model.shouldGenDoDelete()) {
stringBuffer.append(TEXT_60);
}
- if (model.shouldGenDoOptions()) {
+ if (model.shouldGenDoHead()) {
stringBuffer.append(TEXT_61);
}
- if (model.shouldGenDoTrace()) {
+ if (model.shouldGenDoOptions()) {
stringBuffer.append(TEXT_62);
}
+ if (model.shouldGenDoTrace()) {
stringBuffer.append(TEXT_63);
+ }
stringBuffer.append(TEXT_64);
+ stringBuffer.append(TEXT_65);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/web/IServletConstants.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/web/IServletConstants.java
index ce76423..23fca09 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/web/IServletConstants.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/web/IServletConstants.java
@@ -18,6 +18,12 @@
public static final String QUALIFIED_GENERIC_SERVLET = "javax.servlet.GenericServlet"; //$NON-NLS-1$
public static final String QUALIFIED_HTTP_SERVLET = "javax.servlet.http.HttpServlet"; //$NON-NLS-1$
+ public static final String QUALIFIED_WEB_SERVLET = "javax.servlet.annotation.WebServlet"; //$NON-NLS-1$
+ public static final String QUALIFIED_WEB_LISTENER = "javax.servlet.annotation.WebListener"; //$NON-NLS-1$
+ public static final String QUALIFIED_WEB_FILTER = "javax.servlet.annotation.WebFilter"; //$NON-NLS-1$
+ public static final String QUALIFIED_ANNOTATION_INIT_PARAM = "javax.servlet.annotation.WebInitParam"; //$NON-NLS-1$
+
+
public static final String QUALIFIED_SERVLET_EXCEPTION = "javax.servlet.ServletException"; //$NON-NLS-1$
public static final String QUALIFIED_SERVLET_CONFIG = "javax.servlet.ServletConfig"; //$NON-NLS-1$
public static final String QUALIFIED_SERVLET_REQUEST = "javax.servlet.ServletRequest"; //$NON-NLS-1$