Example usage for com.vaadin.server.communication ServletBootstrapHandler ServletBootstrapHandler

List of usage examples for com.vaadin.server.communication ServletBootstrapHandler ServletBootstrapHandler

Introduction

In this page you can find the example usage for com.vaadin.server.communication ServletBootstrapHandler ServletBootstrapHandler.

Prototype

ServletBootstrapHandler

Source Link

Usage

From source file:com.github.mcollovati.vertx.vaadin.VertxVaadinService.java

License:Open Source License

@Override
protected List<RequestHandler> createRequestHandlers() throws ServiceException {
    List<RequestHandler> handlers = super.createRequestHandlers();
    handlers.add(0, new ServletBootstrapHandler());
    handlers.add(new ServletUIInitHandler());
    if (isAtmosphereAvailable()) {
        handlers.add((RequestHandler) (session, request, response) -> {
            if (!ServletPortletHelper.isPushRequest(request)) {
                return false;
            }//  w ww  .ja  v  a  2s. c  o m
            if (request instanceof VertxVaadinRequest) {
                ((VertxVaadinRequest) request).getRoutingContext().next();
            }
            return true;
        });
    }
    return handlers;
}

From source file:info.magnolia.ui.admincentral.AdmincentralVaadinServlet.java

License:Open Source License

@Override
protected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration)
        throws ServiceException {
    VaadinServletService service = new VaadinServletService(this, deploymentConfiguration) {

        @Override//w ww.j  a  v  a 2 s  .c  o  m
        protected List<RequestHandler> createRequestHandlers() throws ServiceException {
            List<RequestHandler> handlers = super.createRequestHandlers();
            for (int i = 0; i < handlers.size(); i++) {
                RequestHandler handler = handlers.get(i);
                if (handler instanceof ServletBootstrapHandler) {
                    handlers.set(i, new ServletBootstrapHandler() {

                        @Override
                        protected String getServiceUrl(BootstrapContext context) {

                            // We replace the default ServletBootstrapHandler with our own so that we can specify
                            // the serviceUrl explicitly. It's otherwise left empty making the client determine it
                            // using location.href. The client does not play well with this and appends paths after
                            // the JSESSIONID instead of in front of it. This results in a problem loading resources
                            // specified using @JavaScript and @StyleSheet.
                            //
                            // see com.vaadin.client.ApplicationConfiguration.loadFromDOM()
                            // see MGNLUI-2291
                            // see http://dev.vaadin.com/ticket/10974

                            return ServletUtil.getOriginalRequestURI(
                                    ((VaadinServletRequest) context.getRequest()).getHttpServletRequest());
                        }
                    });
                    break;
                }
            }
            return handlers;
        }
    };
    service.init();
    return service;
}