From 73f50d5027288b4358880a638911bec276384a34 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 7 Sep 2012 10:07:42 +0300 Subject: Redesign to make session inited in Application.init (#9402) --- .../vaadin/launcher/ApplicationRunnerServlet.java | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'uitest/src/com') diff --git a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java index 029bebd9c9..df7c9c5db9 100644 --- a/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java +++ b/uitest/src/com/vaadin/launcher/ApplicationRunnerServlet.java @@ -111,28 +111,32 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { } @Override - protected VaadinServletSession createApplication(HttpServletRequest request) + protected boolean shouldCreateApplication(WrappedHttpServletRequest request) throws ServletException { + try { + return Application.class.isAssignableFrom(getClassToRun()); + } catch (ClassNotFoundException e) { + throw new ServletException(e); + } + } + + @Override + protected void onVaadinSessionStarted(WrappedHttpServletRequest request, + VaadinServletSession session) throws ServletException { try { final Class classToRun = getClassToRun(); if (UI.class.isAssignableFrom(classToRun)) { - VaadinServletSession application = new VaadinServletSession(); - application.addUIProvider(new AbstractUIProvider() { + session.addUIProvider(new AbstractUIProvider() { @Override - public Class getUIClass( - WrappedRequest request) { + public Class getUIClass(WrappedRequest request) { return (Class) classToRun; } }); - return application; } else if (Application.class.isAssignableFrom(classToRun)) { - return super.createApplication(request); + // Avoid using own UIProvider for legacy Application } else if (UIProvider.class.isAssignableFrom(classToRun)) { - VaadinServletSession application = new VaadinServletSession(); - application - .addUIProvider((UIProvider) classToRun.newInstance()); - return application; + session.addUIProvider((UIProvider) classToRun.newInstance()); } else { throw new ServletException(classToRun.getCanonicalName() + " is neither an Application nor a UI"); @@ -148,6 +152,7 @@ public class ApplicationRunnerServlet extends LegacyVaadinServlet { + getApplicationRunnerApplicationClassName(request))); } + super.onVaadinSessionStarted(request, session); } private String getApplicationRunnerApplicationClassName( -- cgit v1.2.3