@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 + "/"
*
* @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());
}
/**
* @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 {
return;
}
- VaadinServletSession vaadinSession = null;
+ VaadinServiceSession vaadinSession = null;
try {
// If a duplicate "close application" URL is received for an
}
// Find out the service session this request is related to
- vaadinSession = (VaadinServletSession) getService()
- .findVaadinSession(request);
+ vaadinSession = getService().findVaadinSession(request);
if (vaadinSession == null) {
return;
}
return (VaadinServletResponse) VaadinService.getCurrentResponse();
}
- @Override
- protected VaadinServiceSession createVaadinSession(VaadinRequest request)
- throws ServiceException {
- return new VaadinServletSession(this);
- }
-
@Override
public String getServiceName() {
return getServlet().getServletName();
+++ /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 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();
- }
-
-}
session.invalidate();
}
+ @Override
+ public String getId() {
+ return session.getId();
+ }
+
}
public void invalidate() {
session.invalidate();
}
+
+ @Override
+ public String getId() {
+ return session.getId();
+ }
}
* @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();
}
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;
}));
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);
}
protected String getSessionId() {
- return ((VaadinServletSession) getContext()).getHttpSession().getId();
+ return getContext().getSession().getId();
}
@Override