Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Anderson2014-01-29 04:20:39 +0000
committerCarl Anderson2014-01-29 04:20:39 +0000
commitb255f13493313554e1f622c08f3d52ebf4b9aaaf (patch)
tree05dfb8b46cbea2593ad8aec6f64d72826b32ed01 /plugins
parentb8d27017c5a7fbd6773deedf74e60c2a1e7be27d (diff)
downloadwebtools.javaee-b255f13493313554e1f622c08f3d52ebf4b9aaaf.tar.gz
webtools.javaee-b255f13493313554e1f622c08f3d52ebf4b9aaaf.tar.xz
webtools.javaee-b255f13493313554e1f622c08f3d52ebf4b9aaaf.zip
[426508] Support Servlet 3.1 Listeners in new Listener wizardv201401290400
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.jst.j2ee.web/templates/_methods.template5
-rw-r--r--plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/ListenerTemplate.java39
-rw-r--r--plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewListenerClassDataModelProvider.java6
-rw-r--r--plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/web/IServletConstants.java2
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/BinaryMethod.java25
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/Method.java8
-rw-r--r--plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/SourceMethod.java21
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/property_files/web_ui.properties2
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/WEBUIMessages.java2
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizardPage.java24
-rw-r--r--plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/IWebWizardConstants.java3
11 files changed, 120 insertions, 17 deletions
diff --git a/plugins/org.eclipse.jst.j2ee.web/templates/_methods.template b/plugins/org.eclipse.jst.j2ee.web/templates/_methods.template
index 5fe3d10d2..a424ce623 100644
--- a/plugins/org.eclipse.jst.j2ee.web/templates/_methods.template
+++ b/plugins/org.eclipse.jst.j2ee.web/templates/_methods.template
@@ -6,8 +6,9 @@
/**
* @see <%= method.getContainingJavaClass() %>#<%= method.getName() %>(<%= method.getParamsForJavadoc() %>)
*/
- public <%= method.getReturnType() %> <%= method.getName() %>(<%= method.getParamsForDeclaration() %>) {
- // TODO Auto-generated method stub
+ public <%= method.getReturnType() %> <%= method.getName() %>(<%= method.getParamsForDeclaration() %>) <% if (!method.getExceptions().isEmpty()){ %>throws <%=method.getExceptions()%> {
+ <%}else {%> { <% } %>
+ // TODO Auto-generated method stub
<%
String defaultReturnValue = method.getDefaultReturnValue();
if (defaultReturnValue != null) {
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 b28544bd1..cc7014b9c 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 SAP AG and others.
+ * Copyright (c) 2007, 2014 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* This class has been generated from a javajet template.
*******************************************************************************/
+
package org.eclipse.jst.j2ee.internal.web.operations;
import java.util.*;
@@ -59,12 +60,16 @@ public class ListenerTemplate
protected final String TEXT_33 = ")" + NL + " */" + NL + " public "; //$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 + " // TODO Auto-generated method stub"; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_37 = NL + "\t\t\treturn "; //$NON-NLS-1$
- protected final String TEXT_38 = ";"; //$NON-NLS-1$
- protected final String TEXT_39 = NL + " }"; //$NON-NLS-1$
- protected final String TEXT_40 = NL + "\t" + NL + "}"; //$NON-NLS-1$ //$NON-NLS-2$
- protected final String TEXT_41 = NL;
+ protected final String TEXT_36 = ") "; //$NON-NLS-1$
+ protected final String TEXT_37 = "throws "; //$NON-NLS-1$
+ protected final String TEXT_38 = " { "; //$NON-NLS-1$
+ protected final String TEXT_39 = " { "; //$NON-NLS-1$
+ protected final String TEXT_40 = NL + " // TODO Auto-generated method stub"; //$NON-NLS-1$
+ protected final String TEXT_41 = NL + "\t\t\treturn "; //$NON-NLS-1$
+ protected final String TEXT_42 = ";"; //$NON-NLS-1$
+ protected final String TEXT_43 = NL + " }"; //$NON-NLS-1$
+ protected final String TEXT_44 = NL + "\t" + NL + "}"; //$NON-NLS-1$ //$NON-NLS-2$
+ protected final String TEXT_45 = NL;
public String generate(Object argument)
{
@@ -107,7 +112,7 @@ public class ListenerTemplate
stringBuffer.append(TEXT_11);
- if ("3.0".equals(model.getJavaEEVersion()) || "3.1".equals(model.getJavaEEVersion())) { //$NON-NLS-1$ //$NON-NLS-2$
+ if ("3.0".equals(model.getJavaEEVersion()) || "3.1".equals(model.getJavaEEVersion())) { //$NON-NLS-1$ //$NON-NLS-2$
stringBuffer.append(TEXT_12);
@@ -212,23 +217,31 @@ public class ListenerTemplate
stringBuffer.append(TEXT_35);
stringBuffer.append( method.getParamsForDeclaration() );
stringBuffer.append(TEXT_36);
+ if (!method.getExceptions().isEmpty()){
+ stringBuffer.append(TEXT_37);
+ stringBuffer.append(method.getExceptions());
+ stringBuffer.append(TEXT_38);
+ }else {
+ stringBuffer.append(TEXT_39);
+ }
+ stringBuffer.append(TEXT_40);
String defaultReturnValue = method.getDefaultReturnValue();
if (defaultReturnValue != null) {
- stringBuffer.append(TEXT_37);
+ stringBuffer.append(TEXT_41);
stringBuffer.append( defaultReturnValue );
- stringBuffer.append(TEXT_38);
+ stringBuffer.append(TEXT_42);
}
- stringBuffer.append(TEXT_39);
+ stringBuffer.append(TEXT_43);
}
}
- stringBuffer.append(TEXT_40);
- stringBuffer.append(TEXT_41);
+ stringBuffer.append(TEXT_44);
+ stringBuffer.append(TEXT_45);
return stringBuffer.toString();
}
}
diff --git a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewListenerClassDataModelProvider.java b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewListenerClassDataModelProvider.java
index bfe6dac15..4e96df9ec 100644
--- a/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewListenerClassDataModelProvider.java
+++ b/plugins/org.eclipse.jst.j2ee.web/web/org/eclipse/jst/j2ee/internal/web/operations/NewListenerClassDataModelProvider.java
@@ -15,11 +15,13 @@ import static org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataM
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_ACTIVATION_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_ATTRIBUTE_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_BINDING_LISTENER;
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_ID_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_CONTEXT_ATTRIBUTE_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_CONTEXT_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_LISTENER;
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_ASYNC_EVENT_LISTENER;
import static org.eclipse.jst.j2ee.internal.web.operations.INewWebClassDataModelProperties.USE_EXISTING_CLASS;
import java.util.List;
@@ -72,8 +74,10 @@ public class NewListenerClassDataModelProvider extends
QUALIFIED_HTTP_SESSION_ATTRIBUTE_LISTENER,
QUALIFIED_HTTP_SESSION_ACTIVATION_LISTENER,
QUALIFIED_HTTP_SESSION_BINDING_LISTENER,
+ QUALIFIED_HTTP_SESSION_ID_LISTENER,
QUALIFIED_SERVLET_REQUEST_LISTENER,
- QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER
+ QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER,
+ QUALIFIED_SERVLET_REQUEST_ASYNC_EVENT_LISTENER
};
/**
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 07dd594c3..79a6d95aa 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
@@ -50,6 +50,8 @@ public interface IServletConstants {
public static final String QUALIFIED_SERVLET_REQUEST_EVENT = "javax.servlet.ServletRequestEvent"; //$NON-NLS-1$
public static final String QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER = "javax.servlet.ServletRequestAttributeListener"; //$NON-NLS-1$
public static final String QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_EVENT = "javax.servlet.ServletRequestAttributeEvent"; //$NON-NLS-1$
+ public static final String QUALIFIED_HTTP_SESSION_ID_LISTENER = "javax.servlet.http.HttpSessionIdListener";//$NON-NLS-1$
+ public static final String QUALIFIED_SERVLET_REQUEST_ASYNC_EVENT_LISTENER = "javax.servlet.AsyncListener";//$NON-NLS-1$
public static final String METHOD_INIT = "init"; //$NON-NLS-1$
public static final String METHOD_DESTROY = "destroy"; //$NON-NLS-1$
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/BinaryMethod.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/BinaryMethod.java
index b9e10ea6e..0a3104da5 100644
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/BinaryMethod.java
+++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/BinaryMethod.java
@@ -136,6 +136,31 @@ public class BinaryMethod implements Method {
return result;
}
+
+
+ /**
+ * @see Method#getExceptions()
+ */
+
+ public String getExceptions(){
+ StringBuffer exceptions = new StringBuffer();
+ try {
+ String[] exceptionTypes = method.getExceptionTypes();
+ for (int i=0; i<exceptionTypes.length; i++){
+ exceptions.append(Signature.toString(exceptionTypes[i]));
+ if (i < exceptionTypes.length - 1)
+ exceptions.append(", "); //$NON-NLS-1$
+ }
+
+ } catch (JavaModelException e) {
+ org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin.logError(e);
+ }
+
+ return exceptions.toString();
+
+ }
+
+
/**
* @see Object#equals(Object)
*/
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/Method.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/Method.java
index ddfcfcc39..1aff6d23f 100644
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/Method.java
+++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/Method.java
@@ -113,5 +113,13 @@ public interface Method {
* types.
*/
public Collection<String> getParameterImports();
+
+
+ /**
+ * Returns a list of exceptions thrown by the method
+ * @return a <code>List</code> of String representation of the exception
+ * types.
+ */
+ public String getExceptions();
}
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/SourceMethod.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/SourceMethod.java
index af0e16d7f..d67899ae8 100644
--- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/SourceMethod.java
+++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/operations/SourceMethod.java
@@ -140,6 +140,27 @@ public class SourceMethod implements Method {
return result;
}
+
+ /**
+ * @see Method#getExceptions()
+ */
+
+ public String getExceptions(){
+ StringBuffer exceptions = new StringBuffer();
+ List exceptionTypes = method.thrownExceptions();
+
+ for (int i=0; i<exceptionTypes.size(); i++){
+ exceptions.append(exceptionTypes.get(i));
+ if (i < exceptionTypes.size() - 1)
+ exceptions.append(", "); //$NON-NLS-1$
+ }
+
+ return exceptions.toString();
+ }
+
+
+
+
/**
* @see Object#equals(Object)
*/
diff --git a/plugins/org.eclipse.jst.servlet.ui/property_files/web_ui.properties b/plugins/org.eclipse.jst.servlet.ui/property_files/web_ui.properties
index 24e7c0e95..4bc6d6a42 100644
--- a/plugins/org.eclipse.jst.servlet.ui/property_files/web_ui.properties
+++ b/plugins/org.eclipse.jst.servlet.ui/property_files/web_ui.properties
@@ -85,6 +85,8 @@ ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_H=C&hanges to attributes
ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G=Chan&ges to attributes
ADD_LISTENER_WIZARD_SESSION_MIGRATION=Session &migration
ADD_LISTENER_WIZARD_OBJECT_BINDING=&Object binding
+ADD_LISTENER_WIZARD_OBJECT_SESSION_ID=Cha&nges to id
+ADD_LISTENER_WIZARD_ASYNC_EVENTS=Async &events
ADD_BUTTON_LABEL=Add...
ADD_BUTTON_LABEL_A=&Add...
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/WEBUIMessages.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/WEBUIMessages.java
index 2ac066c31..f34c07561 100644
--- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/WEBUIMessages.java
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/plugin/WEBUIMessages.java
@@ -152,6 +152,8 @@ public class WEBUIMessages extends NLS {
public static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G;
public static String ADD_LISTENER_WIZARD_SESSION_MIGRATION;
public static String ADD_LISTENER_WIZARD_OBJECT_BINDING;
+ public static String ADD_LISTENER_WIZARD_OBJECT_SESSION_ID;
+ public static String ADD_LISTENER_WIZARD_ASYNC_EVENTS;
public static String DISPATCHER_REQUEST;
public static String DISPATCHER_FORWARD;
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizardPage.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizardPage.java
index 057b5e8ba..12d8119fe 100644
--- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizardPage.java
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/AddListenerWizardPage.java
@@ -20,6 +20,8 @@ import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_CONTE
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_CONTEXT_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER;
import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_LISTENER;
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_HTTP_SESSION_ID_LISTENER;
+import static org.eclipse.jst.j2ee.web.IServletConstants.QUALIFIED_SERVLET_REQUEST_ASYNC_EVENT_LISTENER;
import static org.eclipse.jst.servlet.ui.internal.wizard.IWebWizardConstants.*;
import java.util.ArrayList;
@@ -28,6 +30,7 @@ import java.util.List;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jst.j2ee.internal.web.operations.INewServletClassDataModelProperties;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -127,6 +130,17 @@ public class AddListenerWizardPage extends DataModelWizardPage {
ADD_LISTENER_WIZARD_OBJECT_BINDING,
QUALIFIED_HTTP_SESSION_BINDING_LISTENER,
INTERFACES);
+
+ String javaEEVersion = model.getStringProperty(INewServletClassDataModelProperties.JAVA_EE_VERSION);
+ if("3.1".equals(javaEEVersion)){ //$NON-NLS-1$
+ createEventListenerRow(group,
+ ADD_LISTENER_WIZARD_OBJECT_SESSION_ID,
+ QUALIFIED_HTTP_SESSION_ID_LISTENER,
+ INTERFACES);
+ }
+
+
+
}
private void createServletRequestEvents(Composite parent) {
@@ -141,8 +155,18 @@ public class AddListenerWizardPage extends DataModelWizardPage {
ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G,
QUALIFIED_SERVLET_REQUEST_ATTRIBUTE_LISTENER,
INTERFACES);
+
+ String javaEEVersion = model.getStringProperty(INewServletClassDataModelProperties.JAVA_EE_VERSION);
+ if("3.1".equals(javaEEVersion)){ //$NON-NLS-1$
+ createEventListenerRow(group,
+ ADD_LISTENER_WIZARD_ASYNC_EVENTS,
+ QUALIFIED_SERVLET_REQUEST_ASYNC_EVENT_LISTENER,
+ INTERFACES);
+ }
+
}
+
private Group createGroup(Composite parent, String text) {
Group group = new Group(parent, SWT.NONE);
diff --git a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/IWebWizardConstants.java b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/IWebWizardConstants.java
index d38886165..e534e0a77 100644
--- a/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/IWebWizardConstants.java
+++ b/plugins/org.eclipse.jst.servlet.ui/servlet_ui/org/eclipse/jst/servlet/ui/internal/wizard/IWebWizardConstants.java
@@ -81,7 +81,8 @@ public interface IWebWizardConstants {
public final static String ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G = WEBUIMessages.ADD_LISTENER_WIZARD_CHANGES_TO_ATTRIBUTES_G;
public final static String ADD_LISTENER_WIZARD_SESSION_MIGRATION = WEBUIMessages.ADD_LISTENER_WIZARD_SESSION_MIGRATION;
public final static String ADD_LISTENER_WIZARD_OBJECT_BINDING = WEBUIMessages.ADD_LISTENER_WIZARD_OBJECT_BINDING;
-
+ public final static String ADD_LISTENER_WIZARD_OBJECT_SESSION_ID = WEBUIMessages.ADD_LISTENER_WIZARD_OBJECT_SESSION_ID;
+ public final static String ADD_LISTENER_WIZARD_ASYNC_EVENTS = WEBUIMessages.ADD_LISTENER_WIZARD_ASYNC_EVENTS;
// common
public final static String ADD_BUTTON_LABEL = WEBUIMessages.ADD_BUTTON_LABEL;
public final static String ADD_BUTTON_LABEL_A = WEBUIMessages.ADD_BUTTON_LABEL_A;

Back to the top