Example usage for com.vaadin.server Constants SERVLET_PARAMETER_PRODUCTION_MODE

List of usage examples for com.vaadin.server Constants SERVLET_PARAMETER_PRODUCTION_MODE

Introduction

In this page you can find the example usage for com.vaadin.server Constants SERVLET_PARAMETER_PRODUCTION_MODE.

Prototype

String SERVLET_PARAMETER_PRODUCTION_MODE

To view the source code for com.vaadin.server Constants SERVLET_PARAMETER_PRODUCTION_MODE.

Click Source Link

Usage

From source file:com.haulmont.cuba.web.sys.CubaApplicationServlet.java

License:Apache License

@Override
protected DeploymentConfiguration createDeploymentConfiguration(Properties initParameters) {
    int sessionExpirationTimeout = webConfig.getHttpSessionExpirationTimeoutSec();
    int sessionPingPeriod = sessionExpirationTimeout / 3;

    if (Strings.isNullOrEmpty(initParameters.getProperty(Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL))) {
        if (sessionPingPeriod > 0) {
            // configure Vaadin heartbeat according to web config
            initParameters.setProperty(Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL,
                    String.valueOf(sessionPingPeriod));
        }// ww w.  ja v a2  s.  c o  m
    }

    if (Strings.isNullOrEmpty(initParameters.getProperty(Constants.PARAMETER_WIDGETSET))) {
        String widgetSet = webConfig.getWidgetSet();
        initParameters.setProperty(Constants.PARAMETER_WIDGETSET, widgetSet);
    }

    if (Strings.isNullOrEmpty(initParameters.getProperty(Constants.SERVLET_PARAMETER_PRODUCTION_MODE))) {
        boolean productionMode = webConfig.getProductionMode();
        if (productionMode) {
            initParameters.setProperty(Constants.SERVLET_PARAMETER_PRODUCTION_MODE, String.valueOf(true));
        }
    }

    if (Strings.isNullOrEmpty(initParameters.getProperty(Constants.SERVLET_PARAMETER_UI_PROVIDER))) {
        initParameters.setProperty(Constants.SERVLET_PARAMETER_UI_PROVIDER,
                CubaUIProvider.class.getCanonicalName());
    }

    if (Strings.isNullOrEmpty(initParameters.getProperty(VaadinSession.UI_PARAMETER))) {
        // not actually used by CubaUIProvider
        initParameters.setProperty(VaadinSession.UI_PARAMETER, AppUI.class.getCanonicalName());
    }

    return super.createDeploymentConfiguration(initParameters);
}

From source file:fr.univlorraine.mondossierweb.Initializer.java

License:Apache License

/**
 * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext)
 *//*from ww  w.  jav a2s  . com*/
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    addContextParametersToSystemProperties(servletContext);

    /* Configure les sessions */
    Set<SessionTrackingMode> sessionTrackingModes = new HashSet<SessionTrackingMode>();
    sessionTrackingModes.add(SessionTrackingMode.COOKIE);
    servletContext.setSessionTrackingModes(sessionTrackingModes);
    servletContext.addListener(new HttpSessionListener() {
        @Override
        public void sessionCreated(HttpSessionEvent httpSessionEvent) {
            // sans nouvelle requte, on garde la session active 4 minutes
            httpSessionEvent.getSession().setMaxInactiveInterval(240);
        }

        @Override
        public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
        }
    });
    /* Gestion des sessions dans Atmosphere (Push Vaadin) */
    servletContext.addListener(SessionSupport.class);

    /* Configure Spring */
    AnnotationConfigWebApplicationContext springContext = new AnnotationConfigWebApplicationContext();
    if (!Boolean.valueOf(servletContext.getInitParameter(Constants.SERVLET_PARAMETER_PRODUCTION_MODE))) {
        springContext.getEnvironment().setActiveProfiles(DEBUG_PROFILE);
    }
    springContext.register(SpringConfig.class);
    servletContext.addListener(new ContextLoaderListener(springContext));
    servletContext.addListener(new RequestContextListener());

    /* Filtre Spring Security */
    FilterRegistration.Dynamic springSecurityFilterChain = servletContext.addFilter("springSecurityFilterChain",
            DelegatingFilterProxy.class);
    springSecurityFilterChain.addMappingForUrlPatterns(null, false, "/*");

    /* Filtre passant l'utilisateur courant  Logback */
    FilterRegistration.Dynamic userMdcServletFilter = servletContext.addFilter("userMdcServletFilter",
            UserMdcServletFilter.class);
    userMdcServletFilter.addMappingForUrlPatterns(null, false, "/*");

    /* Filtre Spring Mobile permettant de dtecter le device */
    FilterRegistration.Dynamic springMobileServletFilter = servletContext
            .addFilter("deviceResolverRequestFilter", DeviceResolverRequestFilter.class);
    springMobileServletFilter.addMappingForUrlPatterns(null, false, "/*");

    /* Servlet Spring-Vaadin */
    //ServletRegistration.Dynamic springVaadinServlet = servletContext.addServlet("springVaadin", JMeterServlet.class);
    //ServletRegistration.Dynamic springVaadinServlet = servletContext.addServlet("springVaadin", SpringVaadinServlet.class);
    ServletRegistration.Dynamic springVaadinServlet = servletContext.addServlet("springVaadin",
            fr.univlorraine.mondossierweb.utils.MdwSpringVaadinServlet.class);
    springVaadinServlet.setLoadOnStartup(1);
    springVaadinServlet.addMapping("/*");
    /* Dfini le bean UI */
    //springVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_UI_PROVIDER, "fr.univlorraine.mondossierweb.MdwUIProvider");
    /* Utilise les messages Spring pour les messages d'erreur Vaadin (cf. http://vaadin.xpoft.ru/#system_messages) */
    springVaadinServlet.setInitParameter("systemMessagesBeanName", "DEFAULT");
    /* Dfini la frquence du heartbeat en secondes (cf. https://vaadin.com/book/vaadin7/-/page/application.lifecycle.html#application.lifecycle.ui-expiration) */
    springVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_HEARTBEAT_INTERVAL, String.valueOf(30));

    /* Configure le Push */
    springVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_PUSH_MODE,
            Boolean.valueOf(servletContext.getInitParameter("enablePush")) ? PushMode.AUTOMATIC.name()
                    : PushMode.DISABLED.name());

    /* Active le support des servlet 3 et des requtes asynchrones (cf. https://vaadin.com/wiki/-/wiki/Main/Working+around+push+issues) */
    springVaadinServlet.setInitParameter(ApplicationConfig.WEBSOCKET_SUPPORT_SERVLET3, String.valueOf(true));
    /* Active le support des requtes asynchrones */
    springVaadinServlet.setAsyncSupported(true);
    /* Ajoute l'interceptor Atmosphere permettant de restaurer le SecurityContext dans le SecurityContextHolder (cf. https://groups.google.com/forum/#!msg/atmosphere-framework/8yyOQALZEP8/ZCf4BHRgh_EJ) */
    springVaadinServlet.setInitParameter(ApplicationConfig.ATMOSPHERE_INTERCEPTORS,
            RecoverSecurityContextAtmosphereInterceptor.class.getName());

    /* Spring-Vaadin Touchkit Servlet  */
    ServletRegistration.Dynamic springTouchkitVaadinServlet = servletContext.addServlet("springTouchkitVaadin",
            MDWTouchkitServlet.class);
    //springTouchkitVaadinServlet.setLoadOnStartup(1);
    springTouchkitVaadinServlet.addMapping("/m/*");
    /* Dfini le bean UI */
    //springTouchkitVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_UI_PROVIDER, "fr.univlorraine.mondossierweb.MdwTouchkitUIProvider");
    /* Utilise les messages Spring pour les messages d'erreur Vaadin (cf. http://vaadin.xpoft.ru/#system_messages) */
    springTouchkitVaadinServlet.setInitParameter("systemMessagesBeanName", "DEFAULT");
    springTouchkitVaadinServlet.setInitParameter(Constants.PARAMETER_WIDGETSET,
            "fr.univlorraine.mondossierweb.AppWidgetset");

    /* Configure le Push */
    springTouchkitVaadinServlet.setInitParameter(Constants.SERVLET_PARAMETER_PUSH_MODE,
            PushMode.DISABLED.name());
    /* Active le support des servlet 3 et des requtes asynchrones (cf. https://vaadin.com/wiki/-/wiki/Main/Working+around+push+issues) */
    springTouchkitVaadinServlet.setInitParameter(ApplicationConfig.WEBSOCKET_SUPPORT_SERVLET3,
            String.valueOf(true));
    /* Active le support des requtes asynchrones */
    springTouchkitVaadinServlet.setAsyncSupported(true);
    /* Ajoute l'interceptor Atmosphere permettant de restaurer le SecurityContext dans le SecurityContextHolder (cf. https://groups.google.com/forum/#!msg/atmosphere-framework/8yyOQALZEP8/ZCf4BHRgh_EJ) */
    springTouchkitVaadinServlet.setInitParameter(ApplicationConfig.ATMOSPHERE_INTERCEPTORS,
            RecoverSecurityContextAtmosphereInterceptor.class.getName());

}

From source file:makeithappen.vaadin.app.internal.servlet.VaadinOsgiServletConfigurator.java

License:Open Source License

/**
 * Binds the HTTP service./*w  w  w.  jav  a 2 s.c o  m*/
 *
 */
public void bindHttpService() {
    try {
        final VaadinOsgiServlet osgiServlet = new VaadinOsgiServlet();

        final Dictionary<String, String> dict = new Hashtable<String, String>();
        dict.put(Constants.SERVLET_PARAMETER_PRODUCTION_MODE, Boolean.TRUE.toString());

        httpService.registerServlet(ROOT_PATH, osgiServlet, dict, null);
        httpService.registerResources(VAADIN_RESOURCE_PATH, VAADIN_RESOURCE_PATH, resourceProvider);

    } catch (final ServletException e) {
        e.printStackTrace();
    } catch (final NamespaceException e) {
        e.printStackTrace();
    }
}