}
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);
}
protected VaadinPortletService createPortletService(
- DeploymentConfiguration deploymentConfiguration) {
- return new VaadinPortletService(this, deploymentConfiguration);
+ DeploymentConfiguration deploymentConfiguration)
+ throws ServiceException {
+ VaadinPortletService service = new VaadinPortletService(this,
+ deploymentConfiguration);
+ service.init();
+ return service;
}
/**
private final VaadinPortlet portlet;
public VaadinPortletService(VaadinPortlet portlet,
- DeploymentConfiguration deploymentConfiguration) {
+ DeploymentConfiguration deploymentConfiguration)
+ throws ServiceException {
super(deploymentConfiguration);
this.portlet = portlet;
}
@Override
- protected List<RequestHandler> createRequestHandlers() {
+ protected List<RequestHandler> createRequestHandlers()
+ throws ServiceException {
List<RequestHandler> handlers = super.createRequestHandlers();
handlers.add(new PortletUIInitHandler());
private ClassLoader classLoader;
- private final Iterable<RequestHandler> requestHandlers;
+ private Iterable<RequestHandler> requestHandlers;
/**
* Keeps track of whether a warning about missing push support has already
+ 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);
-
}
/**
* 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());
}
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);
}
protected VaadinServletService createServletService(
- DeploymentConfiguration deploymentConfiguration) {
- return new VaadinServletService(this, deploymentConfiguration);
+ DeploymentConfiguration deploymentConfiguration)
+ throws ServiceException {
+ VaadinServletService service = new VaadinServletService(this,
+ deploymentConfiguration);
+ service.init();
+ return service;
}
/**
private boolean pushWarningLogged = false;
public VaadinServletService(VaadinServlet servlet,
- DeploymentConfiguration deploymentConfiguration) {
+ DeploymentConfiguration deploymentConfiguration)
+ throws ServiceException {
super(deploymentConfiguration);
this.servlet = servlet;
}
@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());
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;
private AtmosphereFramework atmosphere;
private PushHandler pushHandler;
- public PushRequestHandler(VaadinServletService service) {
+ public PushRequestHandler(VaadinServletService service) throws ServiceException {
atmosphere = new AtmosphereFramework();
// 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
// Workaround to avoid calling init and creating servlet config
Field f = VaadinServlet.class.getDeclaredField("servletService");
f.setAccessible(true);
- f.set(servlet, new VaadinServletService(servlet,
+ VaadinServletService service = new VaadinServletService(servlet,
new DefaultDeploymentConfiguration(servlet.getClass(),
- new Properties())));
+ new Properties()));
+ service.init();
+ f.set(servlet, service);
}
private UI ui;
@Before
- public void setup() {
+ public void setup() throws Exception {
mockServlet = new VaadinServlet() {
@Override
public String getServletName() {
mockService = new VaadinServletService(mockServlet,
new MockDeploymentConfiguration());
+ mockService.init();
mockHttpSession = EasyMock.createMock(HttpSession.class);
mockWrappedSession = new WrappedHttpSession(mockHttpSession) {
variableName));
}
- private LegacyCommunicationManager createCommunicationManager() {
+ private LegacyCommunicationManager createCommunicationManager()
+ throws Exception {
VaadinServletService vss = new VaadinServletService(
EasyMock.createMock(VaadinServlet.class),
new MockDeploymentConfiguration());
+ vss.init();
return new LegacyCommunicationManager(
new AlwaysLockedVaadinSession(vss));
}