diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-04-25 15:32:50 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-04-25 17:52:17 +0000 |
commit | ddf73a0fce1e943b3aacf7e0791504c841ce3800 (patch) | |
tree | b00e6f10fc16d6e6114d2313e6f51414b3e1534e /server/src/com | |
parent | f73da53c7d8d950952fb1a0c8469bca7ca5d9386 (diff) | |
download | vaadin-framework-ddf73a0fce1e943b3aacf7e0791504c841ce3800.tar.gz vaadin-framework-ddf73a0fce1e943b3aacf7e0791504c841ce3800.zip |
Pass ServletConfig to atmosphere init (#11716)
Furthermore, the exception that might get thrown from there is passed up
through the call stack until it can be handled in a sensible way.
Change-Id: I4a741b5ad4d9216255932c2328b49e73e92df2f4
Diffstat (limited to 'server/src/com')
6 files changed, 52 insertions, 15 deletions
diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index 12c68e8673..b383878f28 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -250,7 +250,11 @@ public class VaadinPortlet extends GenericPortlet implements Constants, } DeploymentConfiguration deploymentConfiguration = createDeploymentConfiguration(initParameters); - vaadinService = createPortletService(deploymentConfiguration); + try { + vaadinService = createPortletService(deploymentConfiguration); + } catch (ServiceException e) { + throw new PortletException("Could not initialized VaadinPortlet", e); + } // Sets current service even though there are no request and response vaadinService.setCurrentInstances(null, null); @@ -269,8 +273,12 @@ public class VaadinPortlet extends GenericPortlet implements Constants, } protected VaadinPortletService createPortletService( - DeploymentConfiguration deploymentConfiguration) { - return new VaadinPortletService(this, deploymentConfiguration); + DeploymentConfiguration deploymentConfiguration) + throws ServiceException { + VaadinPortletService service = new VaadinPortletService(this, + deploymentConfiguration); + service.init(); + return service; } /** diff --git a/server/src/com/vaadin/server/VaadinPortletService.java b/server/src/com/vaadin/server/VaadinPortletService.java index 05ce8626c5..2eca07dd4a 100644 --- a/server/src/com/vaadin/server/VaadinPortletService.java +++ b/server/src/com/vaadin/server/VaadinPortletService.java @@ -39,7 +39,8 @@ public class VaadinPortletService extends VaadinService { private final VaadinPortlet portlet; public VaadinPortletService(VaadinPortlet portlet, - DeploymentConfiguration deploymentConfiguration) { + DeploymentConfiguration deploymentConfiguration) + throws ServiceException { super(deploymentConfiguration); this.portlet = portlet; @@ -55,7 +56,8 @@ public class VaadinPortletService extends VaadinService { } @Override - protected List<RequestHandler> createRequestHandlers() { + protected List<RequestHandler> createRequestHandlers() + throws ServiceException { List<RequestHandler> handlers = super.createRequestHandlers(); handlers.add(new PortletUIInitHandler()); diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 11060c6f73..a4520e77e2 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -101,7 +101,7 @@ public abstract class VaadinService implements Serializable { private ClassLoader classLoader; - private final Iterable<RequestHandler> requestHandlers; + private Iterable<RequestHandler> requestHandlers; /** * Keeps track of whether a warning about missing push support has already @@ -135,11 +135,20 @@ public abstract class VaadinService implements Serializable { + classLoaderName, e); } } + } + /** + * Initializes this service. The service should be initialized before it is + * used. + * + * @since 7.1 + * @throws ServiceException + * if a problem occurs when creating the service + */ + public void init() throws ServiceException { List<RequestHandler> handlers = createRequestHandlers(); Collections.reverse(handlers); requestHandlers = Collections.unmodifiableCollection(handlers); - } /** @@ -150,8 +159,11 @@ public abstract class VaadinService implements Serializable { * predefined handler. * * @return The list of request handlers used by this service. + * @throws ServiceException + * if a problem occurs when creating the request handlers */ - protected List<RequestHandler> createRequestHandlers() { + protected List<RequestHandler> createRequestHandlers() + throws ServiceException { ArrayList<RequestHandler> handlers = new ArrayList<RequestHandler>(); handlers.add(new SessionRequestHandler()); handlers.add(new PublishedFileHandler()); diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index 9dc62808c7..1facf6e29a 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -84,7 +84,11 @@ public class VaadinServlet extends HttpServlet implements Constants { } DeploymentConfiguration deploymentConfiguration = createDeploymentConfiguration(initParameters); - servletService = createServletService(deploymentConfiguration); + try { + servletService = createServletService(deploymentConfiguration); + } catch (ServiceException e) { + throw new ServletException("Could not initialize VaadinServlet", e); + } // Sets current service even though there are no request and response servletService.setCurrentInstances(null, null); @@ -142,8 +146,12 @@ public class VaadinServlet extends HttpServlet implements Constants { } protected VaadinServletService createServletService( - DeploymentConfiguration deploymentConfiguration) { - return new VaadinServletService(this, deploymentConfiguration); + DeploymentConfiguration deploymentConfiguration) + throws ServiceException { + VaadinServletService service = new VaadinServletService(this, + deploymentConfiguration); + service.init(); + return service; } /** diff --git a/server/src/com/vaadin/server/VaadinServletService.java b/server/src/com/vaadin/server/VaadinServletService.java index 088bb6d640..e7df223f89 100644 --- a/server/src/com/vaadin/server/VaadinServletService.java +++ b/server/src/com/vaadin/server/VaadinServletService.java @@ -50,7 +50,8 @@ public class VaadinServletService extends VaadinService { private boolean pushWarningLogged = false; public VaadinServletService(VaadinServlet servlet, - DeploymentConfiguration deploymentConfiguration) { + DeploymentConfiguration deploymentConfiguration) + throws ServiceException { super(deploymentConfiguration); this.servlet = servlet; @@ -82,7 +83,8 @@ public class VaadinServletService extends VaadinService { } @Override - protected List<RequestHandler> createRequestHandlers() { + protected List<RequestHandler> createRequestHandlers() + throws ServiceException { List<RequestHandler> handlers = super.createRequestHandlers(); handlers.add(0, new ServletBootstrapHandler()); handlers.add(new ServletUIInitHandler()); diff --git a/server/src/com/vaadin/server/communication/PushRequestHandler.java b/server/src/com/vaadin/server/communication/PushRequestHandler.java index f7cff43e84..3540078f85 100644 --- a/server/src/com/vaadin/server/communication/PushRequestHandler.java +++ b/server/src/com/vaadin/server/communication/PushRequestHandler.java @@ -26,6 +26,7 @@ import org.atmosphere.cpr.AtmosphereRequest; import org.atmosphere.cpr.AtmosphereResponse; import com.vaadin.server.RequestHandler; +import com.vaadin.server.ServiceException; import com.vaadin.server.ServletPortletHelper; import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinResponse; @@ -47,7 +48,7 @@ public class PushRequestHandler implements RequestHandler { private AtmosphereFramework atmosphere; private PushHandler pushHandler; - public PushRequestHandler(VaadinServletService service) { + public PushRequestHandler(VaadinServletService service) throws ServiceException { atmosphere = new AtmosphereFramework(); @@ -64,7 +65,11 @@ public class PushRequestHandler implements RequestHandler { // message stream into individual messages when using certain transports atmosphere.interceptor(new TrackMessageSizeInterceptor()); - atmosphere.init(); + try { + atmosphere.init(service.getServlet().getServletConfig()); + } catch (ServletException e) { + throw new ServiceException("Could not read atmosphere settings", e); + } } @Override |