Change-Id: I0e25ba1a6d258b8601c009f6dc062b3f4bd3dbcetags/7.0.0.beta3
@@ -110,8 +110,9 @@ public class CommunicationManager extends AbstractCommunicationManager { | |||
@Override | |||
protected InputStream getThemeResourceAsStream(UI uI, String themeName, | |||
String resource) { | |||
VaadinServletSession session = (VaadinServletSession) uI.getSession(); | |||
ServletContext servletContext = session.getHttpSession() | |||
VaadinServletService service = (VaadinServletService) uI.getSession() | |||
.getService(); | |||
ServletContext servletContext = service.getServlet() | |||
.getServletContext(); | |||
return servletContext.getResourceAsStream("/" | |||
+ VaadinServlet.THEME_DIRECTORY_PATH + themeName + "/" |
@@ -361,11 +361,18 @@ public class GAEVaadinServlet extends VaadinServlet { | |||
* | |||
* @param request | |||
*/ | |||
private void cleanSession(HttpServletRequest request) { | |||
HttpSession session = request.getSession(false); | |||
if (session != null) { | |||
session.removeAttribute(VaadinServletSession.class.getName()); | |||
private void cleanSession(VaadinServletRequest request) { | |||
// Should really be replaced with a session storage API... | |||
WrappedSession wrappedSession = request.getWrappedSession(false); | |||
if (wrappedSession == null) { | |||
return; | |||
} | |||
VaadinServiceSession serviceSession = VaadinServiceSession | |||
.getForSession(getService(), wrappedSession); | |||
if (serviceSession == null) { | |||
return; | |||
} | |||
serviceSession.removeFromSession(getService()); | |||
} | |||
/** |
@@ -437,8 +437,10 @@ public abstract class VaadinService implements Serializable { | |||
* @throws ServletException | |||
* @throws MalformedURLException | |||
*/ | |||
protected abstract VaadinServiceSession createVaadinSession( | |||
VaadinRequest request) throws ServiceException; | |||
protected VaadinServiceSession createVaadinSession(VaadinRequest request) | |||
throws ServiceException { | |||
return new VaadinServiceSession(this); | |||
} | |||
private void onVaadinSessionStarted(VaadinRequest request, | |||
VaadinServiceSession session) throws ServiceException { |
@@ -232,7 +232,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
return; | |||
} | |||
VaadinServletSession vaadinSession = null; | |||
VaadinServiceSession vaadinSession = null; | |||
try { | |||
// If a duplicate "close application" URL is received for an | |||
@@ -254,8 +254,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
} | |||
// Find out the service session this request is related to | |||
vaadinSession = (VaadinServletSession) getService() | |||
.findVaadinSession(request); | |||
vaadinSession = getService().findVaadinSession(request); | |||
if (vaadinSession == null) { | |||
return; | |||
} |
@@ -185,12 +185,6 @@ public class VaadinServletService extends VaadinService { | |||
return (VaadinServletResponse) VaadinService.getCurrentResponse(); | |||
} | |||
@Override | |||
protected VaadinServiceSession createVaadinSession(VaadinRequest request) | |||
throws ServiceException { | |||
return new VaadinServletSession(this); | |||
} | |||
@Override | |||
public String getServiceName() { | |||
return getServlet().getServletName(); |
@@ -1,57 +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 javax.servlet.http.HttpSession; | |||
import javax.servlet.http.HttpSessionBindingListener; | |||
/** | |||
* Web application context for Vaadin applications. | |||
* | |||
* This is automatically added as a {@link HttpSessionBindingListener} when | |||
* added to a {@link HttpSession}. | |||
* | |||
* @author Vaadin Ltd. | |||
* @since 3.1 | |||
* | |||
* @deprecated might be refactored or removed before 7.0.0 | |||
*/ | |||
@Deprecated | |||
@SuppressWarnings("serial") | |||
public class VaadinServletSession extends VaadinServiceSession { | |||
/** | |||
* Create a servlet service session for the given servlet service | |||
* | |||
* @param service | |||
* the servlet service to which the new session belongs | |||
*/ | |||
public VaadinServletSession(VaadinServletService service) { | |||
super(service); | |||
} | |||
/** | |||
* Gets the http-session application is running in. | |||
* | |||
* @return HttpSession this application context resides in. | |||
*/ | |||
public HttpSession getHttpSession() { | |||
WrappedSession session = getSession(); | |||
return ((WrappedHttpSession) session).getHttpSession(); | |||
} | |||
} |
@@ -88,4 +88,9 @@ public class WrappedHttpSession implements WrappedSession { | |||
session.invalidate(); | |||
} | |||
@Override | |||
public String getId() { | |||
return session.getId(); | |||
} | |||
} |
@@ -74,4 +74,9 @@ public class WrappedPortletSession implements WrappedSession { | |||
public void invalidate() { | |||
session.invalidate(); | |||
} | |||
@Override | |||
public String getId() { | |||
return session.getId(); | |||
} | |||
} |
@@ -86,4 +86,11 @@ public interface WrappedSession { | |||
* @see PortletSession#invalidate() | |||
*/ | |||
public void invalidate(); | |||
/** | |||
* Gets a string with a unique identifier for the session. | |||
* | |||
* @return a unique session id string | |||
*/ | |||
public String getId(); | |||
} |
@@ -1,7 +1,6 @@ | |||
package com.vaadin.tests.applicationcontext; | |||
import com.vaadin.server.VaadinService; | |||
import com.vaadin.server.VaadinServletSession; | |||
import com.vaadin.tests.components.AbstractTestCase; | |||
import com.vaadin.tests.util.Log; | |||
import com.vaadin.ui.Button; | |||
@@ -30,15 +29,13 @@ public class ChangeSessionId extends AbstractTestCase { | |||
})); | |||
setMainWindow(mainWindow); | |||
loginButton.addListener(new ClickListener() { | |||
loginButton.addClickListener(new ClickListener() { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
VaadinServletSession context = ((VaadinServletSession) getContext()); | |||
String oldSessionId = context.getHttpSession().getId(); | |||
context.getService().reinitializeSession( | |||
VaadinService.getCurrentRequest()); | |||
String newSessionId = context.getHttpSession().getId(); | |||
String oldSessionId = getSessionId(); | |||
VaadinService.reinitializeSession(VaadinService | |||
.getCurrentRequest()); | |||
String newSessionId = getSessionId(); | |||
if (oldSessionId.equals(newSessionId)) { | |||
log.log("FAILED! Both old and new session id is " | |||
+ newSessionId); | |||
@@ -57,7 +54,7 @@ public class ChangeSessionId extends AbstractTestCase { | |||
} | |||
protected String getSessionId() { | |||
return ((VaadinServletSession) getContext()).getHttpSession().getId(); | |||
return getContext().getSession().getId(); | |||
} | |||
@Override |