Example usage for javax.servlet ServletConfig getInitParameter

List of usage examples for javax.servlet ServletConfig getInitParameter

Introduction

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

Prototype

public String getInitParameter(String name);

Source Link

Document

Gets the value of the initialization parameter with the given name.

Usage

From source file:pl.exsio.frameset.vaadin.bootstrap.servlet.FramesetServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    this.applicationContext = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext());

    if (config.getInitParameter(CONTEXT_CONFIG_LOCATION_PARAMETER) != null) {
        XmlWebApplicationContext context = new XmlWebApplicationContext();
        context.setParent(this.applicationContext);
        context.setConfigLocation(config.getInitParameter(CONTEXT_CONFIG_LOCATION_PARAMETER));
        context.setServletConfig(config);
        context.setServletContext(config.getServletContext());
        context.refresh();//from  w  w w.ja  v  a 2  s.c  o m

        this.applicationContext = context;
    }

    if (config.getInitParameter(SYSTEM_MESSAGES_BEAN_NAME_PARAMETER) != null) {
        this.systemMessagesBeanName = config.getInitParameter(SYSTEM_MESSAGES_BEAN_NAME_PARAMETER);
    }

    if (FramesetApplicationContext.getApplicationContext() == null) {
        FramesetApplicationContext.setApplicationContext(applicationContext);
    }

    super.init(config);
}

From source file:com.cyclopsgroup.waterview.servlet.WaterviewServlet.java

/**
 * Override method init in super class of MainServlet
 *
 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
 *///ww  w  . jav a  2 s .  c  o m
public void init(ServletConfig config) throws ServletException {
    applicationBase = config.getInitParameter("application.base");

    servletConfig = config;
    String basedir = config.getServletContext().getRealPath("");
    Properties initProperties = new Properties();
    initProperties.setProperty("basedir", basedir);
    initProperties.setProperty("plexus.home", basedir);
    Enumeration i = config.getInitParameterNames();
    while (i.hasMoreElements()) {
        String key = (String) i.nextElement();
        String value = config.getInitParameter(key);
        initProperties.setProperty(key, value);
    }
    try {
        container = new WaterviewPlexusContainer();
        serviceManager = new ServiceManagerAdapter(container);
        for (Iterator j = initProperties.keySet().iterator(); j.hasNext();) {
            String initPropertyName = (String) j.next();
            container.addContextValue(initPropertyName, initProperties.get(initPropertyName));
        }

        container.addContextValue(Waterview.INIT_PROPERTIES, initProperties);
        container.initialize();
        container.start();
    } catch (Exception e) {
        container.getLogger().fatalError("Can not start container", e);
    }
}

From source file:be.fedict.eid.idp.sp.protocol.saml2.AbstractAuthenticationResponseServlet.java

/**
 * {@inheritDoc}//from  w w  w.  j  av a2 s.  co m
 */
@Override
public void init(ServletConfig config) throws ServletException {

    String requiresResponseSignatureString = config.getInitParameter(REQUIRES_RESPONSE_SIGNATURE_INIT_PARAM);
    if (null != requiresResponseSignatureString) {
        requiresResponseSignature = Boolean.valueOf(requiresResponseSignatureString);
    }

    this.responseSessionAttribute = getRequiredInitParameter(RESPONSE_SESSION_ATTRIBUTE_INIT_PARAM, config);
    this.redirectPage = getRequiredInitParameter(REDIRECT_PAGE_INIT_PARAM, config);

    this.errorPage = config.getInitParameter(ERROR_PAGE_INIT_PARAM);
    this.errorMessageSessionAttribute = config.getInitParameter(ERROR_MESSAGE_SESSION_ATTRIBUTE_INIT_PARAM);

    initialize(config);
}

From source file:org.sakaiproject.webdav.SakaiWebDavServlet.java

/**
 * {@inheritDoc}/*from www. j a v  a2s . c  om*/
 *
 * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
 */
@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    String filter = config.getInitParameter("path-filter");
    if (StringUtils.isEmpty(filter)) {
        filter = DEFAULT_FILTER;
    }
    String[] filters = StringUtils.split(filter, ';');
    if (filters != null) {
        for (String f : filters) {
            f = f.trim();
            filterElement.put(f, f);
        }
    }

    KernelManager km = new KernelManager();
    jcrService = km.getService(JCRService.class);
    repository = jcrService.getRepository();

    // for now, the ResourceConfig is fixed
    final String configPath = "/webdav-resource-config.xml";
    final ResourceConfig rc = new ResourceConfig();
    final URL cfg = getClass().getResource(configPath);
    if (cfg == null) {
        throw new UnavailableException("ResourceConfig source not found:" + configPath);
    }

    rc.parse(cfg);
    setResourceConfig(rc);
}

From source file:be.fedict.eid.idp.sp.protocol.ws_federation.AuthenticationRequestServlet.java

/**
 * {@inheritDoc}//from  ww  w  .  ja  v  a  2 s. c  om
 */
@Override
public void init(ServletConfig config) throws ServletException {

    this.idpDestination = config.getInitParameter(IDP_DESTINATION_PARAM);
    this.spDestination = config.getInitParameter(SP_DESTINATION_PARAM);
    this.spRealm = config.getInitParameter(SP_REALM_PARAM);
    this.spDestinationPage = config.getInitParameter(SP_DESTINATION_PAGE_PARAM);
    this.language = config.getInitParameter(LANGUAGE_PARAM);
    this.authenticationRequestServiceLocator = new ServiceLocator<AuthenticationRequestService>(
            AUTHN_REQUEST_SERVICE_PARAM, config);

    // validate necessary configuration params
    if (null == this.idpDestination && !this.authenticationRequestServiceLocator.isConfigured()) {
        throw new ServletException("need to provide either " + IDP_DESTINATION_PARAM + " or "
                + AUTHN_REQUEST_SERVICE_PARAM + "(Class) init-params");
    }

    if (null == this.spDestination && null == this.spDestinationPage
            && !this.authenticationRequestServiceLocator.isConfigured()) {
        throw new ServletException("need to provide either " + SP_DESTINATION_PARAM + " or "
                + SP_DESTINATION_PAGE_PARAM + " or " + AUTHN_REQUEST_SERVICE_PARAM + "(Class) init-param");
    }
}

From source file:com.ctriposs.rest4j.server.Rest4JServlet.java

private int getParseqThreadPoolSize(ServletConfig servletConfig) {
    int threadPoolSize;

    String threadPoolSizeStr = servletConfig.getInitParameter(PAR_SEQ_THREAD_POOL_SIZE);
    if (StringUtils.isNumeric(threadPoolSizeStr) && !threadPoolSizeStr.isEmpty()) {
        threadPoolSize = Integer.valueOf(threadPoolSizeStr);
    } else {/*from  ww w. j  a  v  a 2  s  .  co m*/
        final int numCores = Runtime.getRuntime().availableProcessors();
        threadPoolSize = numCores + 1;
    }
    return threadPoolSize;
}

From source file:org.cruxframework.crux.core.server.rest.servlet.RestServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    String processors = config.getInitParameter("preprocessors");
    if (processors != null) {
        String[] processorNames = processors.split(",");
        for (String proc : processorNames) {
            try {
                RequestPreprocessors.registerPreprocessor(proc.trim());
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }//from  w  w w. ja  va2  s  . co m
        }
    }
}

From source file:org.seasar.cadhelin.ControllerServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    LOG.info("start cadhelin servlert" + config.getServletName());
    String s = config.getInitParameter("encoding");
    if (s != null) {
        encoding = s;/*from  ww  w  .  j  a  v a 2 s.c  o  m*/
    }
    s = config.getInitParameter("viewUrlPattern");
    if (s != null) {
        viewUrlPattern = s;
    }
    container = SingletonS2ContainerFactory.getContainer();
    Object[] objects = container.findAllComponents(Plugin.class);
    if (objects != null && 0 < objects.length) {
        plugins = new Plugin[objects.length];
        System.arraycopy(objects, 0, plugins, 0, plugins.length);
    }
    for (Plugin plugin : plugins) {
        plugin.start(config);
    }
    actionMetadataFactory = new ActionMetadataFactoryImpl(container);
    config.getServletContext().setAttribute(CONTROLLER_METADATA_NAME, actionMetadataFactory);
    if (container.hasComponentDef(ExceptionHandler.class)) {
        exceptionHandlerMetadata = new ExceptionHandlerMetadata(
                container.getComponentDef(ExceptionHandler.class));
    }
    Object[] f = container.findComponents(ActionFilter.class);
    this.filters = new ActionFilter[f.length];
    System.arraycopy(f, 0, filters, 0, filters.length);

}

From source file:jp.eisbahn.oauth2.server.spi.servlet.TokenServlet.java

@SuppressWarnings("unchecked")
private <T> T createInstance(String name, ServletConfig config)
        throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    String className = config.getInitParameter(name);
    if (className != null) {
        Class<?> clazz = Class.forName(className);
        return (T) clazz.newInstance();
    } else {//from www . j  a  va  2  s  . c  om
        return null;
    }
}

From source file:be.fedict.eid.dss.protocol.simple.client.SignatureRequestServlet.java

@Override
public void init(ServletConfig config) throws ServletException {

    LOG.debug("init");
    this.spDestination = config.getInitParameter(SP_DESTINATION_PARAM);
    this.spDestinationPage = config.getInitParameter(SP_DESTINATION_PAGE_PARAM);
    this.target = config.getInitParameter(TARGET_PARAM);
    this.language = config.getInitParameter(LANGUAGE_PARAM);

    this.signatureRequestServiceServiceLocator = new ServiceLocator<SignatureRequestService>(
            SIGNATURE_REQUEST_SERVICE_PARAM, config);

    // Request Config
    this.targetSessionAttribute = config.getInitParameter(TARGET_SESSION_ATTRIBUTE_INIT_PARAM);
    this.signatureRequestSessionAttribute = config
            .getInitParameter(SIGNATURE_REQUEST_SESSION_ATTRIBUTE_INIT_PARAM);
    this.signatureRequestIdSessionAttribute = config
            .getInitParameter(SIGNATURE_REQUEST_ID_SESSION_ATTRIBUTE_INIT_PARAM);
    this.relayStateSessionAttribute = config.getInitParameter(RELAY_STATE_SESSION_ATTRIBUTE_INIT_PARAM);
    this.contentTypeSessionAttribute = config.getInitParameter(CONTENT_TYPE_SESSION_ATTRIBUTE_INIT_PARAM);

    // validate necessary configuration params
    if (null == this.target && !this.signatureRequestServiceServiceLocator.isConfigured()) {
        throw new ServletException("need to provide either " + TARGET_PARAM + " or "
                + SIGNATURE_REQUEST_SERVICE_PARAM + "(Class) init-params");
    }//w w  w  .  j  a v  a 2 s . co m

    if (null == this.spDestination && null == this.spDestinationPage
            && !this.signatureRequestServiceServiceLocator.isConfigured()) {
        throw new ServletException("need to provide either " + SP_DESTINATION_PARAM + " or "
                + SP_DESTINATION_PAGE_PARAM + " or " + SIGNATURE_REQUEST_SERVICE_PARAM + "(Class) init-param");
    }
}