diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-09-18 15:49:18 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-09-18 17:00:39 +0300 |
commit | 25b1dd3c3257e59a6a5ac9554d2a5ad8ea707f6a (patch) | |
tree | d46a2c9634f149ca2e66181b5ba21f1bde28aa2c /uitest/src/com/vaadin/launcher | |
parent | 83a0a0c124e22fdd832f367d79e7d8a0f5605084 (diff) | |
download | vaadin-framework-25b1dd3c3257e59a6a5ac9554d2a5ad8ea707f6a.tar.gz vaadin-framework-25b1dd3c3257e59a6a5ac9554d2a5ad8ea707f6a.zip |
Replace onVaadinSessionStarted with a listener (#9635)
Diffstat (limited to 'uitest/src/com/vaadin/launcher')
-rw-r--r-- | uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index 032957bffc..f31b17333a 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -33,8 +33,11 @@ import com.vaadin.LegacyApplication; import com.vaadin.server.AbstractUIProvider; import com.vaadin.server.DeploymentConfiguration; import com.vaadin.server.LegacyVaadinServlet; +import com.vaadin.server.ServiceException; import com.vaadin.server.UIProvider; -import com.vaadin.server.VaadinServletSession; +import com.vaadin.server.VaadinSession; +import com.vaadin.server.VaadinSessionInitializationListener; +import com.vaadin.server.VaadinSessionInitializeEvent; import com.vaadin.server.WrappedHttpServletRequest; import com.vaadin.server.WrappedRequest; import com.vaadin.tests.components.TestBase; @@ -69,6 +72,21 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { } } + @Override + protected void servletInitialized() { + super.servletInitialized(); + getVaadinService().addVaadinSessionInitializationListener( + new VaadinSessionInitializationListener() { + @Override + public void vaadinSessionInitialized( + VaadinSessionInitializeEvent event) + throws ServiceException { + onVaadinSessionStarted(event.getRequest(), + event.getVaadinSession()); + } + }); + } + private void addDirectories(File parent, LinkedHashSet<String> packages, String parentPackage) { packages.add(parentPackage); @@ -120,9 +138,8 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { } } - @Override - protected void onVaadinSessionStarted(WrappedHttpServletRequest request, - VaadinServletSession session) throws ServletException { + protected void onVaadinSessionStarted(WrappedRequest request, + VaadinSession session) throws ServiceException { try { final Class<?> classToRun = getClassToRun(); if (UI.class.isAssignableFrom(classToRun)) { @@ -138,21 +155,20 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { } else if (UIProvider.class.isAssignableFrom(classToRun)) { session.addUIProvider((UIProvider) classToRun.newInstance()); } else { - throw new ServletException(classToRun.getCanonicalName() + throw new ServiceException(classToRun.getCanonicalName() + " is neither an Application nor a UI"); } } catch (final IllegalAccessException e) { - throw new ServletException(e); + throw new ServiceException(e); } catch (final InstantiationException e) { - throw new ServletException(e); + throw new ServiceException(e); } catch (final ClassNotFoundException e) { - throw new ServletException( + throw new ServiceException( new InstantiationException( "Failed to load application class: " - + getApplicationRunnerApplicationClassName(request))); + + getApplicationRunnerApplicationClassName(WrappedHttpServletRequest + .cast(request)))); } - - super.onVaadinSessionStarted(request, session); } private String getApplicationRunnerApplicationClassName( |