summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-09-05 12:24:14 +0300
committerLeif Åstrand <leif@vaadin.com>2012-09-05 12:24:14 +0300
commit8bdaf8732e660d1b9595c9d503999022320b0314 (patch)
tree9e666f8a44ce3f3c5e46a1633d79ac1586dd8f72
parentc8ba35652ebdea8c659b5fc2485690cc637da96a (diff)
downloadvaadin-framework-8bdaf8732e660d1b9595c9d503999022320b0314.tar.gz
vaadin-framework-8bdaf8732e660d1b9595c9d503999022320b0314.zip
Remove servlet and portlet request listeners (#9402)
-rw-r--r--server/src/com/vaadin/server/HttpServletRequestListener.java64
-rw-r--r--server/src/com/vaadin/server/PortletRequestListener.java66
-rw-r--r--server/src/com/vaadin/server/VaadinPortlet.java28
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java28
-rw-r--r--uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java31
5 files changed, 18 insertions, 199 deletions
diff --git a/server/src/com/vaadin/server/HttpServletRequestListener.java b/server/src/com/vaadin/server/HttpServletRequestListener.java
deleted file mode 100644
index e871dca05d..0000000000
--- a/server/src/com/vaadin/server/HttpServletRequestListener.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.server;
-
-import java.io.Serializable;
-
-import javax.servlet.Filter;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import com.vaadin.Application;
-
-/**
- * {@link Application} that implements this interface gets notified of request
- * start and end by terminal.
- * <p>
- * Interface can be used for several helper tasks including:
- * <ul>
- * <li>Opening and closing database connections
- * <li>Implementing {@link ThreadLocal}
- * <li>Setting/Getting {@link Cookie}
- * </ul>
- * <p>
- * Alternatives for implementing similar features are are Servlet {@link Filter}
- * s and {@link ApplicationContext.TransactionListener}s in Vaadin.
- *
- * @since 6.2
- * @see PortletRequestListener
- */
-public interface HttpServletRequestListener extends Serializable {
-
- /**
- * This method is called before {@link Terminal} applies the request to
- * Application.
- *
- * @param request
- * @param response
- */
- public void onRequestStart(HttpServletRequest request,
- HttpServletResponse response);
-
- /**
- * This method is called at the end of each request.
- *
- * @param request
- * @param response
- */
- public void onRequestEnd(HttpServletRequest request,
- HttpServletResponse response);
-} \ No newline at end of file
diff --git a/server/src/com/vaadin/server/PortletRequestListener.java b/server/src/com/vaadin/server/PortletRequestListener.java
deleted file mode 100644
index 4562ddf7b9..0000000000
--- a/server/src/com/vaadin/server/PortletRequestListener.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2011 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.server;
-
-import java.io.Serializable;
-
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletResponse;
-import javax.servlet.Filter;
-
-import com.vaadin.Application;
-
-/**
- * An {@link Application} that implements this interface gets notified of
- * request start and end by the terminal. It is quite similar to the
- * {@link HttpServletRequestListener}, but the parameters are Portlet specific.
- * If an Application is deployed as both a Servlet and a Portlet, one most
- * likely needs to implement both.
- * <p>
- * Only JSR 286 style Portlets are supported.
- * <p>
- * The interface can be used for several helper tasks including:
- * <ul>
- * <li>Opening and closing database connections
- * <li>Implementing {@link ThreadLocal}
- * <li>Inter-portlet communication
- * </ul>
- * <p>
- * Alternatives for implementing similar features are are Servlet {@link Filter}
- * s and {@link ApplicationContext.TransactionListener}s in Vaadin.
- *
- * @since 6.2
- * @see HttpServletRequestListener
- */
-public interface PortletRequestListener extends Serializable {
-
- /**
- * This method is called before {@link Terminal} applies the request to
- * Application.
- *
- * @param requestData
- * the {@link PortletRequest} about to change Application state
- */
- public void onRequestStart(PortletRequest request, PortletResponse response);
-
- /**
- * This method is called at the end of each request.
- *
- * @param requestData
- * the {@link PortletRequest}
- */
- public void onRequestEnd(PortletRequest request, PortletResponse response);
-} \ No newline at end of file
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java
index 3b8e7cd7ba..bf8fb5dc84 100644
--- a/server/src/com/vaadin/server/VaadinPortlet.java
+++ b/server/src/com/vaadin/server/VaadinPortlet.java
@@ -457,7 +457,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
(ResourceResponse) response);
} else {
Application application = null;
- boolean requestStarted = false;
boolean applicationRunning = false;
try {
@@ -495,16 +494,6 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
applicationContext.getBrowser().updateRequestDetails(
wrappedRequest);
- /*
- * Call application requestStart before Application.init() is
- * called (bypasses the limitation in TransactionListener)
- */
- if (application instanceof PortletRequestListener) {
- ((PortletRequestListener) application).onRequestStart(
- request, response);
- requestStarted = true;
- }
-
/* Start the newly created application */
startApplication(request, application, applicationContext);
applicationRunning = true;
@@ -605,20 +594,11 @@ public class VaadinPortlet extends GenericPortlet implements Constants {
application.closeInactiveUIs();
}
- // Notifies transaction end
- try {
- if (requestStarted) {
- ((PortletRequestListener) application).onRequestEnd(
- request, response);
-
- }
- } finally {
- CurrentInstance.clearAll();
+ CurrentInstance.clearAll();
- PortletSession session = request.getPortletSession(false);
- if (session != null) {
- requestTimer.stop(getApplicationContext(session));
- }
+ PortletSession session = request.getPortletSession(false);
+ if (session != null) {
+ requestTimer.stop(getApplicationContext(session));
}
}
}
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index af66a3496e..ba19072503 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -286,7 +286,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
}
Application application = null;
- boolean requestStarted = false;
boolean applicationRunning = false;
try {
@@ -336,16 +335,6 @@ public class VaadinServlet extends HttpServlet implements Constants {
/* Update browser information from the request */
webApplicationContext.getBrowser().updateRequestDetails(request);
- /*
- * Call application requestStart before Application.init() is called
- * (bypasses the limitation in TransactionListener)
- */
- if (application instanceof HttpServletRequestListener) {
- ((HttpServletRequestListener) application).onRequestStart(
- request, response);
- requestStarted = true;
- }
-
// Start the application if it's newly created
startApplication(request, application, webApplicationContext);
applicationRunning = true;
@@ -397,21 +386,12 @@ public class VaadinServlet extends HttpServlet implements Constants {
application.closeInactiveUIs();
}
- // Notifies transaction end
- try {
- if (requestStarted) {
- ((HttpServletRequestListener) application).onRequestEnd(
- request, response);
- }
- } finally {
- CurrentInstance.clearAll();
+ CurrentInstance.clearAll();
- HttpSession session = request.getSession(false);
- if (session != null) {
- requestTimer.stop(getApplicationContext(session));
- }
+ HttpSession session = request.getSession(false);
+ if (session != null) {
+ requestTimer.stop(getApplicationContext(session));
}
-
}
}
diff --git a/uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java b/uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
index 6d2623c199..6f21346b7d 100644
--- a/uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
+++ b/uitest/src/com/vaadin/tests/components/window/AttachShouldBeCalledForSubWindows.java
@@ -1,10 +1,7 @@
package com.vaadin.tests.components.window;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.server.HttpServletRequestListener;
+import com.vaadin.server.WrappedRequest;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.tests.util.Log;
import com.vaadin.ui.Button;
@@ -14,9 +11,9 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
+import com.vaadin.util.CurrentInstance;
-public class AttachShouldBeCalledForSubWindows extends AbstractTestCase
- implements HttpServletRequestListener {
+public class AttachShouldBeCalledForSubWindows extends AbstractTestCase {
private static final long serialVersionUID = 1L;
private Log log = new Log(20);
@@ -26,6 +23,13 @@ public class AttachShouldBeCalledForSubWindows extends AbstractTestCase
@Override
public void init() {
+ WrappedRequest request = CurrentInstance.get(WrappedRequest.class);
+ if (request.getParameter("attachMainFirst") != null) {
+ addSubWindowBeforeMainWindow = false;
+ } else {
+ addSubWindowBeforeMainWindow = true;
+ }
+
UI.LegacyWindow mainWindow = new UI.LegacyWindow() {
@Override
public void attach() {
@@ -115,19 +119,4 @@ public class AttachShouldBeCalledForSubWindows extends AbstractTestCase
return 8170;
}
- @Override
- public void onRequestStart(HttpServletRequest request,
- HttpServletResponse response) {
- if (request.getParameter("attachMainFirst") != null) {
- addSubWindowBeforeMainWindow = false;
- }
-
- }
-
- @Override
- public void onRequestEnd(HttpServletRequest request,
- HttpServletResponse response) {
- // TODO Auto-generated method stub
-
- }
}