Example usage for javax.servlet ServletRegistration.Dynamic setInitParameter

List of usage examples for javax.servlet ServletRegistration.Dynamic setInitParameter

Introduction

In this page you can find the example usage for javax.servlet ServletRegistration.Dynamic setInitParameter.

Prototype

public boolean setInitParameter(String name, String value);

Source Link

Document

Sets the initialization parameter with the given name and value on the Servlet or Filter that is represented by this Registration.

Usage

From source file:be.wolkmaan.klimtoren.web.config.WebAppInitializer.java

public void zkLoaderServlet(ServletContext servletContext) {
    ServletRegistration.Dynamic servlet = servletContext.addServlet("zkLoader", new DHtmlLayoutServlet());
    servlet.setInitParameter("update-uri", "/zkau");
    servlet.setLoadOnStartup(1);/*  w ww. j a v a2 s.  com*/
    servlet.addMapping("*.zul");
    servlet.addMapping("*.zhtml");
    servlet.addMapping("/zk/*");
}

From source file:org.beast.project.template.initializer.WebxmlConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    WebApplicationContext context = getContext();
    servletContext.addListener(new ContextLoaderListener(context));

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet",
            new DispatcherServlet(context));
    dispatcher.setLoadOnStartup(1);//  www .  ja  v a2  s.  c om
    dispatcher.addMapping(MAPPING_URL);

    ServletRegistration.Dynamic ws = servletContext.addServlet("MessageDispatcherServlet",
            new MessageDispatcherServlet(context));
    ws.setInitParameter("transformWsdlLocations", "true"); // Don't use this in production
    ws.addMapping("/services/*");

}

From source file:com.mycompany.testfile.config.WebConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    ServletRegistration.Dynamic h2ConsoleServlet = servletContext.addServlet("H2Console",
            new org.h2.server.web.WebServlet());
    h2ConsoleServlet.addMapping("/console/*");
    h2ConsoleServlet.setInitParameter("-properties", "src/main/resources");
    h2ConsoleServlet.setLoadOnStartup(1);
}

From source file:com.gosmarter.it.eis.config.ExcelERPWebApplicationInitializer.java

private void registerDispatcherServlet(ServletContext servletContext) {

    AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
    dispatcherContext.register(RootConfig.class);

    logger.debug("after register(DispatcherConfig function");

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("zkLoader", new DHtmlLayoutServlet());

    dispatcher.setInitParameter("update-uri", "/zkau");

    dispatcher.setLoadOnStartup(1);/*from  w w w .j  a  va  2 s  . com*/
    dispatcher.addMapping("*.zul");

    dispatcher = servletContext.addServlet("auEngine", new DHtmlUpdateServlet());
    dispatcher.addMapping("/zkau/*");

    dispatcher = servletContext.addServlet("dspLoader", new InterpreterServlet());
    dispatcher.setInitParameter("class-resource", "true");
    dispatcher.addMapping("*.dsp");

}

From source file:com.indeed.iupload.web.WebAppInitializer.java

@Override
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
    String initClass = getPropertiesInitializerClass();
    if (initClass != null) {
        registration.setInitParameter("contextInitializerClasses", initClass);
    }//  w w w . jav a2s. c  o m

    super.customizeRegistration(registration);
}

From source file:com.test.config.BackendConsoleWebConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext webCtx = new AnnotationConfigWebApplicationContext();
    webCtx.register(BackendConsoleMVCConfig.class);
    webCtx.register(BackendConsoleConfig.class);

    servletContext.addListener(new ContextLoaderListener(webCtx));

    /* Spring Delegating Dispatcher Servlet */
    Servlet dispatcherServlet = new DispatcherServlet(webCtx);
    ServletRegistration.Dynamic dispatcherServletReg = servletContext.addServlet("dispatcherServlet",
            dispatcherServlet);//from   w  w  w. j  a  v  a  2s .  c  om
    dispatcherServletReg.setLoadOnStartup(1);
    dispatcherServletReg.setInitParameter("contextConfigLocation", "");
    dispatcherServletReg.addMapping("/");

    /* Spring Security Delegating Filter */
    FilterRegistration springSecurityFilterChainReg = servletContext.addFilter("springSecurityFilterChain",
            DelegatingFilterProxy.class);
    springSecurityFilterChainReg.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST,
            DispatcherType.FORWARD, DispatcherType.ERROR, DispatcherType.ASYNC), false,
            dispatcherServletReg.getName());
}

From source file:com.dominion.salud.nomenclator.configuration.NOMENCLATORInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.scan("com.dominion.salud.nomenclator.configuration");
    ctx.setServletContext(servletContext);
    ctx.refresh();//  ww  w .j  av a 2  s . c o m

    logger.info("     Registrando servlets de configuracion");
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(ctx));
    dispatcher.setInitParameter("contextClass", ctx.getClass().getName());
    dispatcher.setLoadOnStartup(1);
    logger.info("          Agregando mapping: /");
    dispatcher.addMapping("/");
    logger.info("          Agregando mapping: /controller/*");
    dispatcher.addMapping("/controller/*");
    logger.info("          Agregando mapping: /services/*");
    dispatcher.addMapping("/services/*");
    servletContext.addListener(new ContextLoaderListener(ctx));
    logger.info("     Servlets de configuracion registrados correctamente");

    // Configuracion general
    logger.info("     Iniciando la configuracion del modulo");
    NOMENCLATORConstantes._HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator)
            ? servletContext.getRealPath("/")
            : servletContext.getRealPath("/") + File.separator;
    NOMENCLATORConstantes._TEMP = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "temp"
            + File.separator;
    NOMENCLATORConstantes._VERSION = ResourceBundle.getBundle("version").getString("version");
    NOMENCLATORConstantes._LOGS = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "classes"
            + File.separator + "logs";
    NOMENCLATORConstantes._CONTEXT_NAME = servletContext.getServletContextName();
    NOMENCLATORConstantes._CONTEXT_PATH = servletContext.getContextPath();
    NOMENCLATORConstantes._CONTEXT_SERVER = servletContext.getServerInfo();
    NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils.isNotBlank(
            ResourceBundle.getBundle("application").getString("nomenclator.enable.technical.information"))
                    ? Boolean.parseBoolean(ResourceBundle.getBundle("application")
                            .getString("nomenclator.enable.technical.information"))
                    : false;
    PropertyConfigurator.configureAndWatch("log4j");

    logger.info("          Configuracion general del sistema");
    logger.info("               nomenclator.home: " + NOMENCLATORConstantes._HOME);
    logger.info("               nomenclator.temp: " + NOMENCLATORConstantes._TEMP);
    logger.info("               nomenclator.version: " + NOMENCLATORConstantes._VERSION);
    logger.info("               nomenclator.logs: " + NOMENCLATORConstantes._LOGS);
    logger.info("               nomenclator.context.name: " + NOMENCLATORConstantes._CONTEXT_NAME);
    logger.info("               nomenclator.context.path: " + NOMENCLATORConstantes._CONTEXT_PATH);
    logger.info("               nomenclator.context.server: " + NOMENCLATORConstantes._CONTEXT_SERVER);
    logger.info("          Parametrizacion del sistema");
    logger.info("               nomenclator.enable.technical.information: "
            + NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION);
    logger.info("     Modulo configurado correctamente");
    logger.info("MODULO INICIADO CORRECTAMENTE");
}

From source file:org.kew.rmf.reconciliation.config.WebAppInitializer.java

@Override
public void onStartup(ServletContext servletContext) {
    WebApplicationContext rootContext = createRootContext(servletContext);

    configureSpringMvc(servletContext, rootContext);

    // Add Perf4J graphing servlet
    ServletRegistration.Dynamic servletRegistration = servletContext.addServlet("perf4j",
            org.perf4j.logback.servlet.GraphingServlet.class);
    servletRegistration.setInitParameter("graphNames", "graphOtherTimes,graphQueryTimes,graphQueriesPerSecond");
    servletRegistration.addMapping("/perf4j");

    String TAG_SWAP_FILTER_CLASS = "org.kew.servlet.filter.TagSwapFilter";
    try {/*  www . j  ava 2  s  .  co  m*/
        Class.forName(TAG_SWAP_FILTER_CLASS, false, this.getClass().getClassLoader());
        String[] urlPatterns = { "/", "/about/*", "/admin", "/filematch/*", "/help" };

        FilterRegistration.Dynamic cssLinkFilter = servletContext.addFilter("CssLinkFilter",
                TAG_SWAP_FILTER_CLASS);
        cssLinkFilter.setInitParameter("include_file_name", "/var/lib/science-apps/web-resources/head.chunk");
        cssLinkFilter.setInitParameter("tag_name", "[KEWCSS]");
        cssLinkFilter.addMappingForUrlPatterns(null, true, urlPatterns);

        FilterRegistration.Dynamic headerFilter = servletContext.addFilter("HeaderFilter",
                TAG_SWAP_FILTER_CLASS);
        headerFilter.setInitParameter("include_file_name", "/var/lib/science-apps/web-resources/bodytop.chunk");
        headerFilter.setInitParameter("tag_name", "[KEWHEADER]");
        headerFilter.addMappingForUrlPatterns(null, true, urlPatterns);

        FilterRegistration.Dynamic footerFilter = servletContext.addFilter("FooterFilter",
                TAG_SWAP_FILTER_CLASS);
        footerFilter.setInitParameter("include_file_name",
                "/var/lib/science-apps/web-resources/bodybottom.chunk");
        footerFilter.setInitParameter("tag_name", "[KEWFOOTER]");
        footerFilter.addMappingForUrlPatterns(null, true, urlPatterns);
    } catch (ClassNotFoundException e) {
        log.error("Kew servlet filters not in use, class {} not on classpath", TAG_SWAP_FILTER_CLASS);
    }
}

From source file:com.indeed.imhotep.web.config.WebApp.java

@Override
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
    String initClass = getPropertiesInitializerClass();
    if (initClass != null) {
        registration.setInitParameter("contextInitializerClasses", initClass);
    }//  w w  w .j ava 2 s . c  o m
    super.customizeRegistration(registration);
}

From source file:com.iflytek.edu.cloud.frame.web.RestServiceWebApplicationInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    servletContext.setInitParameter("contextConfigLocation", "classpath*:META-INF/spring/*-context.xml");
    servletContext.setInitParameter("contextInitializerClasses",
            ProfileApplicationContextInitializer.class.getName());
    servletContext.addListener(new LogBackLoadConfigureListener());
    servletContext.addListener(new ContextLoaderListener());

    FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter",
            new CharacterEncodingFilter());
    EnumSet<DispatcherType> characterEncodingFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST,
            DispatcherType.FORWARD);/* w  w  w  .ja  va  2 s .  co  m*/
    characterEncodingFilter.setInitParameter("encoding", "UTF-8");
    characterEncodingFilter.setInitParameter("forceEncoding", "true");
    characterEncodingFilter.addMappingForUrlPatterns(characterEncodingFilterDispatcherTypes, true, "/*");

    FilterRegistration.Dynamic openServiceFilter = servletContext.addFilter("openServiceFilter",
            new DelegatingFilterProxy());
    EnumSet<DispatcherType> openServiceFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST,
            DispatcherType.FORWARD);
    openServiceFilter.addMappingForUrlPatterns(openServiceFilterDispatcherTypes, true, "/api");

    if (EnvUtil.jdbcEnabled()) {
        FilterRegistration.Dynamic serviceMetricsFilter = servletContext.addFilter("serviceMetricsFilter",
                new DelegatingFilterProxy());
        EnumSet<DispatcherType> serviceMetricsFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST,
                DispatcherType.FORWARD);
        serviceMetricsFilter.addMappingForUrlPatterns(serviceMetricsFilterDispatcherTypes, true, "/api");
    }

    FilterRegistration.Dynamic CORSFilter = servletContext.addFilter("CORSFilter", new DelegatingFilterProxy());
    EnumSet<DispatcherType> CORSFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST,
            DispatcherType.FORWARD);
    CORSFilter.addMappingForUrlPatterns(CORSFilterDispatcherTypes, true, "/api");

    if (EnvUtil.oauthEnabled()) {
        FilterRegistration.Dynamic springSecurityFilterChain = servletContext
                .addFilter("springSecurityFilterChain", new DelegatingFilterProxyExt());
        EnumSet<DispatcherType> springSecurityFilterChainDispatcherTypes = EnumSet.of(DispatcherType.REQUEST,
                DispatcherType.FORWARD);
        springSecurityFilterChain.addMappingForUrlPatterns(springSecurityFilterChainDispatcherTypes, true,
                "/api");
    } else {
        logger.info(
                "?oauth2???META-INF/res/profile.propertiesoauth2 profile");
    }

    ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("rest", new DispatcherServlet());
    dispatcherServlet.setLoadOnStartup(1);
    dispatcherServlet.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
    dispatcherServlet.setInitParameter("contextConfigLocation", "org.spring.rest");
    dispatcherServlet.setMultipartConfig(getMultiPartConfig());
    dispatcherServlet.addMapping("/api");

    ServletRegistration.Dynamic printProjectVersionServlet = servletContext
            .addServlet("printProjectVersionServlet", new PrintProjectVersionServlet());
    printProjectVersionServlet.setLoadOnStartup(Integer.MAX_VALUE);
}