Example usage for javax.servlet ServletContext getInitParameter

List of usage examples for javax.servlet ServletContext getInitParameter

Introduction

In this page you can find the example usage for javax.servlet ServletContext getInitParameter.

Prototype

public String getInitParameter(String name);

Source Link

Document

Returns a String containing the value of the named context-wide initialization parameter, or null if the parameter does not exist.

Usage

From source file:WebAppProperties.java

public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();
    ServletContext context = getServletContext();
    String displayName = context.getServletContextName();
    if (displayName == null) {
        displayName = "(no display-name element defined)";
    }// w ww. ja  v a 2 s  .  co  m

    out.println("<html>");
    out.println("<head>");
    out.println("<title>Web Application Properties");
    out.println("</title>");
    out.println("</head><body>");
    out.println("<h1>Web Application Properties</h2>");
    out.println("<br>Name: " + displayName);
    out.println("<br>Context: " + req.getContextPath());

    out.println("<h2><center>");
    out.println("Initialization Parameters</center></h2>");
    out.println("<br>");

    out.println("<center><table border width=80%>");

    Enumeration e = context.getInitParameterNames();

    while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        out.println("<tr>");
        out.println("<td>" + name + "</td>");
        out.println("<td>" + context.getInitParameter(name) + "</td>");
        out.println("</tr>");
    }
    out.println("</table></center>");

    out.println("</body>");
    out.println("</html>");
    out.flush();
}

From source file:org.ajax4jsf.webapp.ConfigurableXMLFilter.java

/**
 * @param servletContext/*from w  w w  .  j  a  v a2 s. c  o m*/
 * @param parsersParameter
 * @throws ServletException
 */
public void configureParsers(ServletContext servletContext, String parsersParameter) throws ServletException {
    String[] parsersNames = parsersParameter.split("\\s*,\\s*");
    for (int i = parsersNames.length - 1; i >= 0; i--) {
        String parserName = parsersNames[i];
        ParserConfig parserConfig;
        if (TIDY.equals(parserName)) {
            parserConfig = new TidyParserConfig();
        } else if (NEKO.equals(parserName)) {
            parserConfig = new NekoParserConfig();
        } else if (NONE.equals(parserName)) {
            parserConfig = new PassParserConfig();
        } else {
            throw new ServletException("Unknown XML parser type in config parameter " + parserName);
        }
        parserConfig.setNext(parsers);
        if (null != servletContext) {
            try {
                String parserViewPattern = servletContext
                        .getInitParameter(VIEW_ID_PATTERN_PARAMETER + parserName);
                parserConfig.setPatterns(parserViewPattern);

            } catch (PatternSyntaxException e) {
                throw new ServletException(
                        "Invalid pattern for a parser " + parserName + " :" + e.getMessage());
            }
        }
        parsers = parserConfig;
    }
}

From source file:com.liferay.portal.servlet.MainServlet.java

public void init(ServletConfig config) throws ServletException {
    synchronized (MainServlet.class) {
        super.init(config);
        Config.initializeConfig();/*from   w w  w .  ja v a  2s .  c o m*/
        com.dotmarketing.util.Config.setMyApp(config.getServletContext());
        // Need the plugin root dir before Hibernate comes up
        try {
            APILocator.getPluginAPI()
                    .setPluginJarDir(new File(config.getServletContext().getRealPath("WEB-INF/lib")));
        } catch (IOException e1) {
            Logger.debug(InitServlet.class, "IOException: " + e1.getMessage(), e1);
        }

        // Checking for execute upgrades
        try {
            StartupTasksExecutor.getInstance().executeUpgrades(config.getServletContext().getRealPath("."));
        } catch (DotRuntimeException e1) {
            throw new ServletException(e1);
        } catch (DotDataException e1) {
            throw new ServletException(e1);
        }

        // Starting the reindexation threads
        ClusterThreadProxy.createThread();
        if (Config.getBooleanProperty("DIST_INDEXATION_ENABLED")) {
            ClusterThreadProxy.startThread(Config.getIntProperty("DIST_INDEXATION_SLEEP", 500),
                    Config.getIntProperty("DIST_INDEXATION_INIT_DELAY", 5000));
        }

        ReindexThread.startThread(Config.getIntProperty("REINDEX_THREAD_SLEEP", 500),
                Config.getIntProperty("REINDEX_THREAD_INIT_DELAY", 5000));

        try {
            EventsProcessor.process(new String[] { StartupAction.class.getName() }, true);
        } catch (Exception e) {
            Logger.error(this, e.getMessage(), e);
        }

        // Context path

        ServletConfig sc = getServletConfig();
        ServletContext ctx = getServletContext();

        String ctxPath = GetterUtil.get(sc.getInitParameter("ctx_path"), "/");

        ctx.setAttribute(WebKeys.CTX_PATH, StringUtil.replace(ctxPath + "/c", "//", "/"));

        ctx.setAttribute(WebKeys.CAPTCHA_PATH, StringUtil.replace(ctxPath + "/captcha", "//", "/"));

        ctx.setAttribute(WebKeys.IMAGE_PATH, StringUtil.replace(ctxPath + "/image", "//", "/"));

        // Company id

        _companyId = ctx.getInitParameter("company_id");

        ctx.setAttribute(WebKeys.COMPANY_ID, _companyId);

        // Initialize portlets

        try {
            String[] xmls = new String[] { Http.URLtoString(ctx.getResource("/WEB-INF/portlet.xml")),
                    Http.URLtoString(ctx.getResource("/WEB-INF/portlet-ext.xml")),
                    Http.URLtoString(ctx.getResource("/WEB-INF/liferay-portlet.xml")),
                    Http.URLtoString(ctx.getResource("/WEB-INF/liferay-portlet-ext.xml")) };

            PortletManagerUtil.initEAR(xmls);
        } catch (Exception e) {
            Logger.error(this, e.getMessage(), e);
        }

        // Initialize portlets display

        try {
            String xml = Http.URLtoString(ctx.getResource("/WEB-INF/liferay-display.xml"));

            Map oldCategories = (Map) WebAppPool.get(_companyId, WebKeys.PORTLET_DISPLAY);

            Map newCategories = PortletManagerUtil.getEARDisplay(xml);

            Map mergedCategories = PortalUtil.mergeCategories(oldCategories, newCategories);

            WebAppPool.put(_companyId, WebKeys.PORTLET_DISPLAY, mergedCategories);
        } catch (Exception e) {
            Logger.error(this, e.getMessage(), e);
        }

        // Initialize skins
        //
        //         try {
        //            String[] xmls = new String[] { Http.URLtoString(ctx.getResource("/WEB-INF/liferay-skin.xml")),
        //                  Http.URLtoString(ctx.getResource("/WEB-INF/liferay-skin-ext.xml")) };
        //
        //            SkinManagerUtil.init(xmls);
        //         } catch (Exception e) {
        //            Logger.error(this, e.getMessage(), e);
        //         }

        // Check company

        try {
            CompanyLocalManagerUtil.checkCompany(_companyId);
        } catch (Exception e) {
            Logger.error(this, e.getMessage(), e);
        }

        // Check web settings

        try {
            String xml = Http.URLtoString(ctx.getResource("/WEB-INF/web.xml"));

            _checkWebSettings(xml);
        } catch (Exception e) {
            Logger.error(this, e.getMessage(), e);
        }

        // Scheduler

        // try {
        // Iterator itr =
        // PortletManagerUtil.getPortlets(_companyId).iterator();
        //
        // while (itr.hasNext()) {
        // Portlet portlet = (Portlet)itr.next();
        //
        // String className = portlet.getSchedulerClass();
        //
        // if (portlet.isActive() && className != null) {
        // Scheduler scheduler =
        // (Scheduler)InstancePool.get(className);
        //
        // scheduler.schedule();
        // }
        // }
        // }
        // catch (ObjectAlreadyExistsException oaee) {
        // }
        // catch (Exception e) {
        // Logger.error(this,e.getMessage(),e);
        // }

        // Message Resources

        MultiMessageResources messageResources = (MultiMessageResources) ctx.getAttribute(Globals.MESSAGES_KEY);

        messageResources.setServletContext(ctx);

        WebAppPool.put(_companyId, Globals.MESSAGES_KEY, messageResources);

        // Current users

        WebAppPool.put(_companyId, WebKeys.CURRENT_USERS, new TreeMap());

        // HttpBridge

        TaskController.bridgeUserServicePath = "/httpbridge/home";
        TaskController.bridgeHttpServicePath = "/httpbridge/http";
        TaskController.bridgeGotoTag = "(goto)";
        TaskController.bridgeThenTag = "(then)";
        TaskController.bridgePostTag = "(post)";

        // Process startup events

        try {
            EventsProcessor.process(PropsUtil.getArray(PropsUtil.GLOBAL_STARTUP_EVENTS), true);

            EventsProcessor.process(PropsUtil.getArray(PropsUtil.APPLICATION_STARTUP_EVENTS),
                    new String[] { _companyId });
        } catch (Exception e) {
            Logger.error(this, e.getMessage(), e);
        }

        PortalInstances.init(_companyId);
    }
}

From source file:org.wings.session.Session.java

protected void initProps(ServletContext servletContext) {
    Enumeration params = servletContext.getInitParameterNames();
    while (params.hasMoreElements()) {
        String name = (String) params.nextElement();
        props.put(name, servletContext.getInitParameter(name));
    }//from ww w . j  a va2  s .c o  m
}

From source file:org.apache.myfaces.component.html.util.StreamingAddResource.java

private String getResourceVirtualPath(ServletContext servletContext) {
    if (resourceVirtualPath == null) {
        resourceVirtualPath = servletContext.getInitParameter(MyfacesConfig.INIT_PARAM_RESOURCE_VIRTUAL_PATH);

        if (resourceVirtualPath == null) {
            resourceVirtualPath = MyfacesConfig.INIT_PARAM_RESOURCE_VIRTUAL_PATH_DEFAULT;
        }// ww w.j a va 2 s.  c  o  m
    }

    return resourceVirtualPath;
}

From source file:org.wso2.carbon.apimgt.webapp.publisher.APIPublisherUtil.java

/**
 * Build the API Configuration to be passed to APIM, from a given list of URL templates
 *
 * @param servletContext/* w ww.  jav  a 2s.c  o  m*/
 * @param apiDef
 * @return
 */
public static APIConfig buildApiConfig(ServletContext servletContext, APIResourceConfiguration apiDef)
        throws UserStoreException {
    APIConfig apiConfig = new APIConfig();

    String name = apiDef.getName();
    if (name == null || name.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("API Name not set in @SwaggerDefinition Annotation");
        }
        name = servletContext.getServletContextName();
    }
    apiConfig.setName(name);

    String version = apiDef.getVersion();
    if (version == null || version.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("'API Version not set in @SwaggerDefinition Annotation'");
        }
        version = API_CONFIG_DEFAULT_VERSION;
    }
    apiConfig.setVersion(version);

    String context = apiDef.getContext();
    if (context == null || context.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("'API Context not set in @SwaggerDefinition Annotation'");
        }
        context = servletContext.getContextPath();
    }
    apiConfig.setContext(context);

    String[] tags = apiDef.getTags();
    if (tags == null || tags.length == 0) {
        if (log.isDebugEnabled()) {
            log.debug("'API tag not set in @SwaggerDefinition Annotation'");
        }
    } else {
        apiConfig.setTags(tags);
    }

    String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    servletContext.setAttribute(PARAM_PROVIDER_TENANT_DOMAIN, tenantDomain);
    tenantDomain = (tenantDomain != null && !tenantDomain.isEmpty()) ? tenantDomain
            : MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    apiConfig.setTenantDomain(tenantDomain);

    String endpoint = servletContext.getInitParameter(PARAM_MANAGED_API_ENDPOINT);
    if (endpoint == null || endpoint.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("'managed-api-endpoint' attribute is not configured");
        }
        String endpointContext = apiDef.getContext();
        endpoint = APIPublisherUtil.getApiEndpointUrl(endpointContext);
    }
    apiConfig.setEndpoint(endpoint);

    String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration()
            .getAdminUserName();
    if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
        owner = owner + "@" + tenantDomain;
    }
    if (owner == null || owner.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("'managed-api-owner' attribute is not configured");
        }
    }
    apiConfig.setOwner(owner);

    apiConfig.setSecured(false);

    boolean isDefault = true;
    String isDefaultParam = servletContext.getInitParameter(PARAM_IS_DEFAULT);
    if (isDefaultParam != null && !isDefaultParam.isEmpty()) {
        isDefault = Boolean.parseBoolean(isDefaultParam);
    }
    apiConfig.setDefault(isDefault);

    String transports = servletContext.getInitParameter(PARAM_MANAGED_API_TRANSPORTS);
    if (transports == null || transports.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("'managed-api-transports' attribute is not configured. Therefore using the default, "
                    + "which is 'https'");
        }
        transports = "https,http";
    }
    apiConfig.setTransports(transports);

    String sharingValueParam = servletContext.getInitParameter(PARAM_SHARED_WITH_ALL_TENANTS);
    boolean isSharedWithAllTenants = Boolean.parseBoolean(sharingValueParam);
    if (isSharedWithAllTenants && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
        isSharedWithAllTenants = false;
    }
    apiConfig.setSharedWithAllTenants(isSharedWithAllTenants);

    Set<ApiUriTemplate> uriTemplates = new LinkedHashSet<>();
    for (APIResource apiResource : apiDef.getResources()) {
        ApiUriTemplate template = new ApiUriTemplate();
        template.setAuthType(apiResource.getAuthType());
        template.setHttpVerb(apiResource.getHttpVerb());
        template.setResourceURI(apiResource.getUri());
        template.setUriTemplate(apiResource.getUriTemplate());
        template.setScope(apiResource.getScope());
        uriTemplates.add(template);
    }
    apiConfig.setUriTemplates(uriTemplates);
    // adding scopes to the api
    Map<String, ApiScope> apiScopes = new HashMap<>();
    if (uriTemplates != null) {
        // this creates distinct scopes list
        for (ApiUriTemplate template : uriTemplates) {
            ApiScope scope = template.getScope();
            if (scope != null) {
                if (apiScopes.get(scope.getKey()) == null) {
                    apiScopes.put(scope.getKey(), scope);
                }
            }
        }
        Set<ApiScope> scopes = new HashSet<>(apiScopes.values());
        // set current scopes to API
        apiConfig.setScopes(scopes);
    }

    String policy = servletContext.getInitParameter(PARAM_MANAGED_API_POLICY);
    if (policy == null || policy.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("'managed-api-policy' attribute is not configured. Therefore using the default, "
                    + "which is 'null'");
        }
        policy = null;
    }
    apiConfig.setPolicy(policy);

    return apiConfig;
}

From source file:org.wso2.carbon.dynamic.client.web.app.registration.DynamicClientWebAppRegistrationManager.java

public void initiateDynamicClientRegistration() {
    String requiredDynamicClientRegistration, webAppName, serviceProviderName;
    ServletContext servletContext;
    RegistrationProfile registrationProfile;
    OAuthAppDetails oAuthAppDetails;//from  w  w w.  j  a va  2  s .  c  o m
    DynamicClientWebAppRegistrationManager dynamicClientWebAppRegistrationManager = DynamicClientWebAppRegistrationManager
            .getInstance();
    Enumeration enumeration = new IteratorEnumeration(
            DynamicClientWebAppRegistrationManager.webAppContexts.keySet().iterator());
    if (log.isDebugEnabled()) {
        log.debug("Initiating the DynamicClientRegistration service for web-apps");
    }
    while (enumeration.hasMoreElements()) {
        oAuthAppDetails = new OAuthAppDetails();
        webAppName = (String) enumeration.nextElement();
        serviceProviderName = DynamicClientWebAppRegistrationUtil
                .replaceInvalidChars(DynamicClientWebAppRegistrationUtil.getUserName()) + "_" + webAppName;
        servletContext = DynamicClientWebAppRegistrationManager.webAppContexts.get(webAppName);
        requiredDynamicClientRegistration = servletContext
                .getInitParameter(DynamicClientWebAppRegistrationConstants.DYNAMIC_CLIENT_REQUIRED_FLAG);
        //Java web-app section
        if ((requiredDynamicClientRegistration != null)
                && (Boolean.parseBoolean(requiredDynamicClientRegistration))) {
            //Check whether this is an already registered application
            if (!dynamicClientWebAppRegistrationManager.isRegisteredOAuthApplication(serviceProviderName)) {
                //Construct the RegistrationProfile
                registrationProfile = DynamicClientWebAppRegistrationUtil
                        .constructRegistrationProfile(servletContext, webAppName);
                //Register the OAuth application
                oAuthAppDetails = dynamicClientWebAppRegistrationManager
                        .registerOAuthApplication(registrationProfile);

            } else {
                oAuthAppDetails = dynamicClientWebAppRegistrationManager.getOAuthApplicationData(webAppName);
            }
        } else if (requiredDynamicClientRegistration == null) {
            //Jaggery apps
            JaggeryOAuthConfigurationSettings jaggeryOAuthConfigurationSettings = DynamicClientWebAppRegistrationUtil
                    .getJaggeryAppOAuthSettings(servletContext);
            if (jaggeryOAuthConfigurationSettings.isRequireDynamicClientRegistration()) {
                if (!dynamicClientWebAppRegistrationManager.isRegisteredOAuthApplication(serviceProviderName)) {
                    registrationProfile = DynamicClientWebAppRegistrationUtil
                            .constructRegistrationProfile(jaggeryOAuthConfigurationSettings, webAppName);
                    oAuthAppDetails = dynamicClientWebAppRegistrationManager
                            .registerOAuthApplication(registrationProfile);
                } else {
                    oAuthAppDetails = dynamicClientWebAppRegistrationManager
                            .getOAuthApplicationData(webAppName);
                }
            }
        }
        //Add client credentials to the web-context
        if ((oAuthAppDetails != null && oAuthAppDetails.getClientKey() != null)
                && !oAuthAppDetails.getClientKey().isEmpty()) {
            DynamicClientWebAppRegistrationUtil.addClientCredentialsToWebContext(oAuthAppDetails,
                    servletContext);
            if (log.isDebugEnabled()) {
                log.debug("Added OAuth application credentials to webapp context of webapp : " + webAppName);
            }
        }
    }
}

From source file:org.ajax4jsf.resource.InternetResourceService.java

public void init(FilterConfig config) throws ServletException {
    filterConfig = config;/*www .j  av a 2s.com*/
    ServletContext servletContext = config.getServletContext();
    if ("false".equalsIgnoreCase(config.getInitParameter(ENABLE_CACHING_PARAMETER))) {
        setCacheEnabled(false);
        // this.cacheEnabled = false;
        // this.cacheAdmin = null;
    } else {
        // this.cacheAdmin = ServletCacheAdministrator.getInstance(
        // servletContext, cacheProperties);
        try {
            CacheManager cacheManager = CacheManager.getInstance();
            Map<String, String> env = new ServletContextInitMap(servletContext);
            CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
            this.cache = cacheFactory.createCache(env, this, this);
        } catch (CacheException e) {
            throw new FacesException(e.getMessage(), e);
        }
    }
    // Create Resource-specific Faces Lifecycle instance.
    lifecycleClass = servletContext.getInitParameter(RESOURCE_LIFECYCLE_PARAMETER);
    if (lifecycleClass != null) {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        try {
            Class<?> clazz = classLoader.loadClass(lifecycleClass);
            lifecycle = (ResourceLifecycle) clazz.newInstance();
        } catch (Exception e) {
            throw new FacesException("Error create instance of resource Lifecycle " + lifecycleClass, e);
        }
    } else {
        lifecycle = new ResourceLifecycle();
    }
    webXml = new WebXml();
    webXml.init(servletContext, filterConfig.getFilterName());
    if (log.isDebugEnabled()) {
        log.debug("Resources service initialized");
    }
}

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

/**
 * @see org.springframework.web.WebApplicationInitializer#onStartup(javax.servlet.ServletContext)
 *//*from   w ww .  j a  va  2 s . c om*/
@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:org.opencb.opencga.storage.server.rest.GenericRestWebService.java

public GenericRestWebService(@PathParam("version") String version, @Context UriInfo uriInfo,
        @Context HttpServletRequest httpServletRequest, @Context ServletContext context) throws IOException {
    this.startTime = System.currentTimeMillis();
    this.version = version;
    this.uriInfo = uriInfo;
    this.params = uriInfo.getQueryParameters();
    this.queryOptions = new QueryOptions(params, true);
    this.sessionIp = httpServletRequest.getRemoteAddr();

    logger = LoggerFactory.getLogger(this.getClass());

    defaultStorageEngine = storageConfiguration.getDefaultStorageEngineId();

    // Only one StorageManagerFactory is needed, this acts as a simple Singleton pattern which improves the performance significantly
    if (storageManagerFactory == null) {
        privLogger.debug("Creating the StorageManagerFactory object");
        storageManagerFactory = StorageManagerFactory.get(storageConfiguration);
    }/*from  w  ww .j  a  v a 2  s. co  m*/

    if (authorizedHosts == null) {
        privLogger.debug("Creating the authorizedHost HashSet");
        authorizedHosts = new HashSet<>(storageConfiguration.getServer().getAuthorizedHosts());
    }

    if (authManager == null) {
        try {
            if (StringUtils.isNotEmpty(context.getInitParameter("authManager"))) {
                privLogger.debug("Loading AuthManager in {} from {}", this.getClass(),
                        context.getInitParameter("authManager"));
                authManager = (AuthManager) Class.forName(context.getInitParameter("authManager"))
                        .newInstance();
            } else {
                privLogger.debug("Loading DefaultAuthManager in {} from {}", this.getClass(),
                        DefaultAuthManager.class);
                authManager = new DefaultAuthManager();
            }
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}