Example usage for javax.servlet FilterConfig getServletContext

List of usage examples for javax.servlet FilterConfig getServletContext

Introduction

In this page you can find the example usage for javax.servlet FilterConfig getServletContext.

Prototype

public ServletContext getServletContext();

Source Link

Document

Returns a reference to the ServletContext in which the caller is executing.

Usage

From source file:org.niord.proxy.web.ETagServletFilter.java

/** {@inheritDoc} */
@Override/*from w w  w  .j  a  va 2s  .c  o  m*/
public void init(FilterConfig filterConfig) throws ServletException {
    basePath = filterConfig.getServletContext().getRealPath(File.separator);
    log.info("Initialized with base path " + basePath);
}

From source file:com.mb.framework.web.filter.ReqRespLoggerFilter.java

/**
 * /* w ww.  ja v a 2  s . co m*/
 * This method is not implemented
 */
@Override
public void init(FilterConfig filterConfig) throws ServletException {

    ServletContext servletContext = filterConfig.getServletContext();

    WebApplicationContext webApplicationContext = WebApplicationContextUtils
            .getWebApplicationContext(servletContext);

    AutowireCapableBeanFactory autowireCapableBeanFactory = webApplicationContext
            .getAutowireCapableBeanFactory();

    autowireCapableBeanFactory.autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);

    logger.trace("This method implementation not needed");
}

From source file:org.jsecurity.web.servlet.OncePerRequestFilter.java

/**
 * Sets the FilterConfig <em>and</em> the <code>ServletContext</code> as attributes of this class for use by
 * subclasses.  That is:/*from   ww  w.j  a va  2  s . c  o  m*/
 * <p/>
 * <code>this.filterConfig = filterConfig;<br/>
 * setServletContext(filterConfig.getServletContext());</code>
 *
 * @param filterConfig the FilterConfig instance provided by the Servlet container at startup.
 */
public void setFilterConfig(FilterConfig filterConfig) {
    this.filterConfig = filterConfig;
    setServletContext(filterConfig.getServletContext());
}

From source file:de.xwic.sandbox.security.SSOAuthFilter.java

@Override
public void init(FilterConfig config) throws ServletException {
    String authServerServiceUrl = config.getServletContext().getInitParameter("sso.auth.serviceurl");
    String authServerUserUrl = config.getServletContext().getInitParameter("sso.auth.userurl");
    baseDomain = config.getServletContext().getInitParameter("sso.auth.basedomain");
    String paramEnabled = config.getServletContext().getInitParameter("sso.auth.enabled");
    enabled = "true".equalsIgnoreCase(paramEnabled) || "1".equalsIgnoreCase(paramEnabled);
    if (authServerServiceUrl == null || authServerUserUrl == null) {
        throw new ServletException("sso.auth.serviceurl or sso.auth.userurl is not specified.");
    }/*w w  w.  j  a v a 2 s.  co  m*/

    ssoHandler = new SSOHandler(authServerServiceUrl, authServerUserUrl);

    if (!enabled) {
        log.warn("SSOAuthentication is disabled.");
    }

}

From source file:nc.noumea.mairie.organigramme.core.authentification.AuthentificationFilter.java

public void init(FilterConfig config) throws ServletException {
    ServletContext servletContext = config.getServletContext();
    WebApplicationContext webApplicationContext = WebApplicationContextUtils
            .getWebApplicationContext(servletContext);

    AutowireCapableBeanFactory autowireCapableBeanFactory = webApplicationContext
            .getAutowireCapableBeanFactory();

    radiWSConsumer = (IRadiWSConsumer) autowireCapableBeanFactory.getBean("radiWSConsumer");
    sirhWSConsumer = (ISirhWSConsumer) autowireCapableBeanFactory.getBean("sirhWSConsumer");
}

From source file:org.niord.web.ETagServletFilter.java

/** {@inheritDoc} */
@Override//from  w w  w  .j  a va 2 s  .  c  o m
public void init(FilterConfig filterConfig) throws ServletException {
    basePath = filterConfig.getServletContext().getRealPath(File.separator);
    log.info("Initialized with base path {} ", basePath);
}

From source file:org.xchain.framework.filter.MultipartFormDataFilter.java

public void init(FilterConfig filterConfig) throws javax.servlet.ServletException {

    // get the systems default temp dir
    File tempDir = (File) filterConfig.getServletContext().getAttribute("javax.servlet.context.tempdir");
    String DEFAULT_REPOSITORY_PATH = (tempDir != null) ? tempDir.getPath() : null;

    // Read in the max size param value.
    maxSize = getLongInitParameter(filterConfig, MAX_SIZE_PARAMETER_NAME, DEFAULT_MAX_SIZE);

    // Read in the size threshold param value.
    sizeThreashold = getIntInitParameter(filterConfig, SIZE_THRESHOLD_PARAMETER_NAME, DEFAULT_SIZE_THRESHOLD);

    // Read in the repository path param value.
    repositoryPath = getStringInitParameter(filterConfig, REPOSITORY_PATH_PARAMETER_NAME,
            DEFAULT_REPOSITORY_PATH);/*from  ww w . ja  va 2 s . c  o  m*/

    if (repositoryPath == null) {
        throw new ServletException(
                "Unable to determine DEFAULT_REPOSITORY_PATH, please specify a path using the 'repository-path' config param, or ensure that 'javax.servlet.context.tempdir' is set properly.");
    }

    log.info("Using max size param of: " + maxSize);
    log.info("Using threashold size of: " + sizeThreashold);
    log.info("Using repository path: " + repositoryPath);

}

From source file:org.springside.modules.security.jcaptcha.JCaptchaFilter.java

/**
 * ApplicatonContext?CaptchaService.//from ww w.j av a  2 s.  co m
 */
protected void initCaptchaService(final FilterConfig fConfig) {
    ApplicationContext context = WebApplicationContextUtils
            .getWebApplicationContext(fConfig.getServletContext());
    captchaService = (CaptchaService) context.getBean(captchaServiceId);
}

From source file:org.openspaces.pu.container.jee.stats.RequestStatisticsFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    requests = new AtomicLong();
    reqeustsActive = new AtomicLong();
    requestsDurationTotal = new AtomicLong();

    ClusterInfo clusterInfo = (ClusterInfo) filterConfig.getServletContext()
            .getAttribute(JeeProcessingUnitContainerProvider.CLUSTER_INFO_CONTEXT);
    if (clusterInfo == null) {
        logger.warn("Failed to find cluster info, can't register JEE request service monitor");
    } else {//  ww  w . ja  v a  2  s  .c  o  m
        SharedServiceData.addServiceMonitors(clusterInfo.getUniqueName(), new Callable() {
            public Object call() throws Exception {
                return RequestStatisticsFilter.this.getServicesMonitors();
            }
        });
    }
}

From source file:ee.pri.rl.blog.web.filter.BlogPageCachingFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    synchronized (this.getClass()) {
        ApplicationContext context = WebApplicationContextUtils
                .getWebApplicationContext(filterConfig.getServletContext());
        // Use the cache administrator created by Spring context.
        cacheAdministrator = (GeneralCacheAdministrator) context.getBean("cacheManager");
        blogService = (BlogService) context.getBean("blogService");
    }//from   w  w w . j  a  va  2  s . c o m
}