Example usage for javax.servlet ServletConfig getServletName

List of usage examples for javax.servlet ServletConfig getServletName

Introduction

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

Prototype

public String getServletName();

Source Link

Document

Returns the name of this servlet instance.

Usage

From source file:at.gv.egiz.bku.online.webapp.MoccaParameterBean.java

public static String getInitParameter(String name, ServletConfig config, ServletContext context) {
    String initVal = config.getInitParameter(name);
    String contextVal = context.getInitParameter(config.getServletName() + "." + name);
    log.debug("Reading init param " + name + ": " + initVal + " - context param "
            + (config.getServletName() + "." + name) + ": " + contextVal);
    if (contextVal != null)
        return contextVal;
    return initVal;
}

From source file:com.acciente.induction.init.ConfigLoaderInitializer.java

/**
 * Loads the configuration parameters used to configure every module in this dispatcher servlet.
 *
 * @param oServletConfig provides access to the dispatcher's servlet config
 *
 * @return a container with configuration values
 *
 * @throws ClassNotFoundException propagated exception
 * @throws ConstructorNotFoundException propagated exception
 * @throws IllegalAccessException propagated exception
 * @throws InstantiationException propagated exception
 * @throws InvocationTargetException propagated exception
 *
 * Log/*from  w w  w. j  a  va  2s  .c  o m*/
 * Mar 15, 2008 APR  -  created
 */
public static ConfigLoader getConfigLoader(ServletConfig oServletConfig)
        throws ClassNotFoundException, InvocationTargetException, ConstructorNotFoundException,
        ParameterProviderException, IllegalAccessException, InstantiationException {
    ConfigLoader oConfigLoader;
    String sConfigLoaderClassName;
    Log oLog;

    oLog = LogFactory.getLog(ConfigLoaderInitializer.class);

    sConfigLoaderClassName = oServletConfig.getInitParameter(
            oServletConfig.getServletName() + "." + ConfigLoaderInitializer.CONFIG_LOADER_CLASS);

    // first check if there is custom config loader defined
    if (sConfigLoaderClassName == null) {
        // no custom loader defined, use the default XML loader (this is the typical case)
        oConfigLoader = new XMLConfigLoader("induction-" + oServletConfig.getServletName() + ".xml",
                oServletConfig);

        oLog.info("using default XML config loader");
    } else {
        oLog.info("loading user-defined config loader class: " + sConfigLoaderClassName);

        // note that to load this class we use the default class loader since any of our
        // custom classloaders have to wait until we load in the configuration
        Class oConfigLoaderClass = Class.forName(sConfigLoaderClassName);

        // attempt to find and call the single public constructor
        oConfigLoader = (ConfigLoader) ObjectFactory.createObject(oConfigLoaderClass,
                new Object[] { oServletConfig }, null);
    }

    return oConfigLoader;
}

From source file:org.jasig.springframework.test.ServletPortletAwareTester.java

@Override
public void setServletConfig(ServletConfig servletConfig) {
    logger.debug("{} - set ServletConfig {}", this.name, servletConfig.getServletName());
}

From source file:com.cognifide.aet.rest.ConfigsServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    LOGGER.info("Initializing " + config.getServletName());
}

From source file:com.iorga.iraj.servlet.AgglomeratorServlet.java

private void parseResourcesFromMappings(final ServletConfig config) throws ServletException {
    for (final String mapping : config.getServletContext().getServletRegistration(config.getServletName())
            .getMappings()) {/*ww  w .ja  v  a 2s . com*/
        try {
            parseResource(config, mapping);
        } catch (final IOException | URISyntaxException e) {
            throw new ServletException("Problem while parsing the mapping " + mapping, e);
        }
    }
}

From source file:com.productone.spring.ServerOsgiBundleXmlWebApplicationContext.java

/**
 * {@inheritDoc}//from  w  ww. j  av a  2  s.  c om
 */
public void setServletConfig(ServletConfig servletConfig) {
    this.servletConfig = servletConfig;
    if (servletConfig != null) {
        if (getServletContext() == null) {
            setServletContext(servletConfig.getServletContext());
        }
        if (getNamespace() == null) {
            setNamespace(servletConfig.getServletName() + DEFAULT_NAMESPACE_SUFFIX);
        }
    }
}

From source file:net.solarnetwork.web.gemini.ServerOsgiBundleXmlWebApplicationContext.java

/**
 * {@inheritDoc}//www . j  a  v  a  2 s.  c o  m
 */
@Override
public void setServletConfig(ServletConfig servletConfig) {
    this.servletConfig = servletConfig;
    if (servletConfig != null) {
        if (getServletContext() == null) {
            setServletContext(servletConfig.getServletContext());
        }
        if (getNamespace() == null) {
            setNamespace(servletConfig.getServletName() + DEFAULT_NAMESPACE_SUFFIX);
        }
    }
}

From source file:com.enonic.cms.server.service.dwr.DwrServletWrapper.java

@Override
public void init(final ServletConfig config) throws ServletException {
    final ConfigProperties configProperties = getConfigProperties(config.getServletContext());

    final Map<String, String> params = new HashMap<String, String>();
    params.put("debug", configProperties.getProperty("cms.admin.dwr.debug", "false"));
    params.put("crossDomainSessionSecurity",
            configProperties.getProperty("cms.admin.dwr.crossDomainSessionSecurity", "false"));
    params.put("classes", this.classes.toString());

    final ServletConfig wrapper = new ServletConfig() {
        public String getServletName() {
            return config.getServletName();
        }//  w  w w . j a  va  2 s.  co  m

        public ServletContext getServletContext() {
            return config.getServletContext();
        }

        public String getInitParameter(final String name) {
            return params.get(name);
        }

        public Enumeration getInitParameterNames() {
            return Collections.enumeration(params.keySet());
        }
    };

    super.init(wrapper);
}

From source file:org.wrml.server.WrmlServlet.java

@Override
public void init(final ServletConfig servletConfig) throws ServletException {

    LOGGER.debug("Servlet Name {}", servletConfig.getServletName());

    if (LOGGER.isDebugEnabled()) {

        LOGGER.debug("Parameters names passed [");
        List<String> paramList = new ArrayList<>();
        Enumeration<String> params = servletConfig.getInitParameterNames();
        while (params.hasMoreElements()) {
            String paramName = params.nextElement();
            paramList.add(String.format("%s=%s", paramName, servletConfig.getInitParameter(paramName)));
        }/*w w w .j  a va 2 s .c  o m*/
        LOGGER.debug("Parameters names passed={}", Arrays.toString(paramList.toArray()));
    }

    super.init(servletConfig);

    final String configFileLocation = PropertyUtil.getSystemProperty(
            EngineConfiguration.WRML_CONFIGURATION_FILE_PATH_PROPERTY_NAME,
            servletConfig.getInitParameter(WRML_CONFIGURATION_FILE_PATH_INIT_PARAM_NAME));

    String configResourceLocation = null;
    if (configFileLocation == null) {
        configResourceLocation = servletConfig
                .getInitParameter(WRML_CONFIGURATION_RESOURCE_PATH_INIT_PARAM_NAME);
    }

    try {

        final EngineConfiguration engineConfig;

        if (configFileLocation != null) {
            LOGGER.info("Extracted configuration file location: {}", configFileLocation);
            engineConfig = EngineConfiguration.load(configFileLocation);
        } else if (configResourceLocation != null) {
            LOGGER.info("Extracted configuration resource location: {}", configResourceLocation);
            engineConfig = EngineConfiguration.load(getClass(), configResourceLocation);
        } else {
            throw new ServletException("The WRML engine configuration is null. Unable to initialize servlet.");
        }

        final Engine engine = new DefaultEngine();
        engine.init(engineConfig);
        setEngine(engine);
        LOGGER.debug("Initialized WRML with: {}", engineConfig);
    } catch (IOException ex) {
        throw new ServletException("Unable to initialize servlet.", ex);
    }

    LOGGER.info("WRML SERVLET INITIALIZED --------------------------------------------------");
}

From source file:com.sonicle.webtop.core.app.JaxRsServiceApplication.java

private void configureLegacyApiEndpoints(WebTopApp wta, ServletConfig servletConfig) {
    ServiceManager svcMgr = wta.getServiceManager();

    String serviceId = servletConfig.getInitParameter(RestApi.INIT_PARAM_WEBTOP_SERVICE_ID);
    if (StringUtils.isBlank(serviceId))
        throw new WTRuntimeException(
                "Invalid servlet init parameter [" + RestApi.INIT_PARAM_WEBTOP_SERVICE_ID + "]");

    ServiceDescriptor desc = svcMgr.getDescriptor(serviceId);
    if (desc == null)
        throw new WTRuntimeException("Service descriptor not found [{0}]", serviceId);

    if (desc.hasRestApiEndpoints()) {
        // Take only the first. We do not support many endpoints anymore!!!
        ServiceDescriptor.ApiEndpointClass endpointClass = desc.getRestApiEndpoints().get(0);
        logger.debug("[{}] Registering JaxRs resource (legacy) [{}] -> [{}]", servletConfig.getServletName(),
                endpointClass.toString(), "/");
        registerResources(Resource.builder(endpointClass.clazz).path("/").build());
    }/*  ww  w  . j  a v a2s  . c  o  m*/
}