+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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
(ResourceResponse) response);
} else {
Application application = null;
- boolean requestStarted = false;
boolean applicationRunning = false;
try {
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;
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));
}
}
}
}
Application application = null;
- boolean requestStarted = false;
boolean applicationRunning = false;
try {
/* 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;
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));
}
-
}
}
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;
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);
@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() {
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
-
- }
}