当前位置: 首页>>代码示例>>Java>>正文


Java FilterConfig.getServletContext方法代码示例

本文整理汇总了Java中javax.servlet.FilterConfig.getServletContext方法的典型用法代码示例。如果您正苦于以下问题:Java FilterConfig.getServletContext方法的具体用法?Java FilterConfig.getServletContext怎么用?Java FilterConfig.getServletContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.FilterConfig的用法示例。


在下文中一共展示了FilterConfig.getServletContext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
	this.cfg = filterConfig;
	this.ctx = filterConfig.getServletContext();
	final TreeMap<String, Limit> limits = new TreeMap<String, Limit>();
	final Enumeration<String> e = filterConfig.getInitParameterNames();
	final int ipMaxSize = getIntConfigParam("ipMaxSize", DEFAULT_IPMAXSIZE);
	while (e.hasMoreElements()) {
		final String key = e.nextElement();
		if (!key.isEmpty() && (key.charAt(0) == '/')) {
			final String uri = key;
			final String value = filterConfig.getInitParameter(key);
			final String[] conf = value.split(":"); // 0=concurrent-limit, 1=ip-time-limit-millis
			final int concurrent = (conf.length > 0 ? Integer.parseInt(conf[0]) : 0);
			final long timeByIP = (conf.length > 1 ? Long.parseLong(conf[1]) : 0);
			final Limit limit = new Limit(timeByIP, ipMaxSize, concurrent);
			filterConfig.getServletContext().log("uri=" + uri + " limit=[" + limit + "]");
			limits.put(uri, limit);
		}
	}
	this.limits = limits;
}
 
开发者ID:ggrandes,项目名称:concurrentlimit-servlet-filter,代码行数:23,代码来源:ConcurrentLimitFilter.java

示例2: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    ServletContext servletContext = filterConfig.getServletContext();

    // use decorators from context attributes
    Object contextAttribute = servletContext.getAttribute(SPAN_DECORATORS);
    if (contextAttribute instanceof Collection) {
        List<ServletFilterSpanDecorator> decorators = new ArrayList<>();
        for (Object decorator: (Collection)contextAttribute) {
            if (decorator instanceof ServletFilterSpanDecorator) {
                decorators.add((ServletFilterSpanDecorator) decorator);
            } else {
                log.severe(decorator + " is not an instance of " + ServletFilterSpanDecorator.class);
            }
        }
        this.spanDecorators = decorators.size() > 0 ? decorators : this.spanDecorators;
    }

    contextAttribute = servletContext.getAttribute(SKIP_PATTERN);
    if (contextAttribute instanceof Pattern) {
        skipPattern = (Pattern) contextAttribute;
    }
}
 
开发者ID:opentracing-contrib,项目名称:java-web-servlet-filter,代码行数:25,代码来源:TracingFilter.java

示例3: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
public void init(FilterConfig cfg) throws ServletException {
	iContext = cfg.getServletContext();
	try {
		Document config = (new SAXReader()).read(cfg.getServletContext().getResource(cfg.getInitParameter("config")));
		for (Iterator i=config.getRootElement().element("action-mappings").elementIterator("action"); i.hasNext();) {
			Element action = (Element)i.next();
			String path = action.attributeValue("path");
			String input = action.attributeValue("input");
			if (path!=null && input!=null) {
				iPath2Tile.put(path+".do", input);
			}
		}
	} catch (Exception e) {
		sLog.error("Unable to read config "+cfg.getInitParameter("config")+", reason: "+e.getMessage());
	}
	if (cfg.getInitParameter("debug-time")!=null) {
		debugTime = Long.parseLong(cfg.getInitParameter("debug-time"));
	}
	if (cfg.getInitParameter("dump-time")!=null) {
		dumpTime = Long.parseLong(cfg.getInitParameter("dump-time"));
	}
	if (cfg.getInitParameter("session-attributes")!=null) {
		dumpSessionAttribues = Boolean.parseBoolean(cfg.getInitParameter("session-attributes"));
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:26,代码来源:PageAccessFilter.java

示例4: loadUrlRewriter

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
@Override
protected void loadUrlRewriter(FilterConfig filterConfig) throws ServletException {
    try {
        Conf conf = new Conf(filterConfig.getServletContext(), resource.getInputStream(), resource.getFilename(), "");
    checkConf(conf);
    } catch (IOException ex) {
        throw new ServletException("Unable to load URL-rewrite configuration file from " + CONFIG_LOCATION, ex);
    }
}
 
开发者ID:Angular2Guy,项目名称:AngularAndSpring,代码行数:10,代码来源:MyUrlRewriteFilter.java

示例5: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
public void init(FilterConfig config) throws ServletException {
    if (enable) {
        ProxyFilterConfig proxyFilterConfig = new ProxyFilterConfig(
                config.getServletContext());
        proxyFilterConfig.setFilterName(name);
        proxyFilterConfig.setMap(map);
        filter.init(proxyFilterConfig);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:10,代码来源:ProxyFilter.java

示例6: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
public void init(FilterConfig filterConfig) throws ServletException
{
  // potentially wrap the FilterConfig to catch Serialization changes
  filterConfig = CheckSerializationConfigurator.getFilterConfig(filterConfig);
  
  _servletContext = filterConfig.getServletContext();
          
  //There is some functionality that still might require servlet-only filter services.
  _filters = ClassLoaderUtils.getServices(TrinidadFilterImpl.class.getName());

  ExternalContext externalContext = new ServletExternalContext(
                                      _servletContext, null, null);

  PseudoFacesContext facesContext = new PseudoFacesContext(externalContext);
  facesContext.setAsCurrentInstance();

  try
  {
    for(Filter f:_filters)
    {
      f.init(filterConfig);
    }
  }
  finally
  {
    facesContext.release();
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:29,代码来源:TrinidadFilterImpl.java

示例7: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
/**
 * Standard way of initializing this filter.
 * Map config parameters onto bean properties of this filter, and
 * invoke subclass initialization.
 * @param filterConfig the configuration for this filter
 * @throws ServletException if bean properties are invalid (or required
 * properties are missing), or if subclass initialization fails.
 * @see #initFilterBean
 */
@Override
public final void init(FilterConfig filterConfig) throws ServletException {
	Assert.notNull(filterConfig, "FilterConfig must not be null");
	if (logger.isDebugEnabled()) {
		logger.debug("Initializing filter '" + filterConfig.getFilterName() + "'");
	}

	this.filterConfig = filterConfig;

	// Set bean properties from init parameters.
	try {
		PropertyValues pvs = new FilterConfigPropertyValues(filterConfig, this.requiredProperties);
		BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
		ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext());
		bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, this.environment));
		initBeanWrapper(bw);
		bw.setPropertyValues(pvs, true);
	}
	catch (BeansException ex) {
		String msg = "Failed to set bean properties on filter '" +
			filterConfig.getFilterName() + "': " + ex.getMessage();
		logger.error(msg, ex);
		throw new NestedServletException(msg, ex);
	}

	// Let subclasses do whatever initialization they like.
	initFilterBean();

	if (logger.isDebugEnabled()) {
		logger.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:GenericFilterBean.java

示例8: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
@Override
public synchronized void init(FilterConfig filterConfig) throws ServletException {
    checkArgument(servletContext == null, "servlet context is already initialized");
    servletContext = filterConfig.getServletContext();
    Object prevAttribute = servletContext.getAttribute(SERVLET_CONTEXT_ATTRIBUTE_KEY);
    checkArgument(prevAttribute == null, "servlet context attribute is already initialized");
    servletContext.setAttribute(SERVLET_CONTEXT_ATTRIBUTE_KEY, this);
    LOGGER.trace("initialized");
}
 
开发者ID:vy,项目名称:hrrs,代码行数:10,代码来源:HrrsFilter.java

示例9: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
/**
 * Initialize the filter
 * 
 * @param config
 *            FitlerConfig
 * @exception ServletException
 */
public void init(FilterConfig config) throws ServletException
{
    // Save the context

    m_context = config.getServletContext();

    // Setup the authentication context

    WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(m_context);

    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    setNodeService(serviceRegistry.getNodeService());
    setAuthenticationService(serviceRegistry.getAuthenticationService());
    setTransactionService(serviceRegistry.getTransactionService());
    setPersonService((PersonService) ctx.getBean("PersonService")); // transactional and permission-checked
    m_authComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    
    httpServletRequestAuthHeaderName = config.getInitParameter("httpServletRequestAuthHeaderName");
    if(httpServletRequestAuthHeaderName == null)
    {
        httpServletRequestAuthHeaderName = "x-user";
    }
    this.m_authPatternString = config.getInitParameter("authPatternString");
    if (this.m_authPatternString != null)
    {
        try
        {
            m_authPattern = Pattern.compile(this.m_authPatternString);
        }
        catch (PatternSyntaxException e)
        {
            logger.warn("Invalid pattern: " + this.m_authPatternString, e);
            m_authPattern = null;
        }
    }
    
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:45,代码来源:HTTPRequestAuthenticationFilter.java

示例10: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    logger.debug("init...");
    long start = System.currentTimeMillis();

    // 获取配置类
    String configClass = filterConfig.getInitParameter("configClass");
    createDispatcherConfig(configClass);

    ServletContext servletContext = filterConfig.getServletContext();
    String realPath = servletContext.getRealPath("/");
    logger.info("webRootPath:{}", realPath);
    Constants.me().setWebRootPath(new File(realPath));

    config();

    BeanFactory.getInject().injectMembers(ViewManager.me());
    ViewManager.me().init(servletContext);

    String contextPath = servletContext.getContextPath();
    logger.info("contextPath:{}", contextPath);
    contextPathLength = (contextPath == null || "/".equals(contextPath) ? 0 : contextPath.length());

    actionHandler = BeanFactory.getBean(ActionHandler.class);
    actionHandler.init(contextPath);
    actionConfig.afterStart();

    long end = System.currentTimeMillis();
    logger.info("init {} ms", (end - start));
}
 
开发者ID:Xlongshu,项目名称:EasyController,代码行数:31,代码来源:ActionDispatcherFilter.java

示例11: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
public void init(FilterConfig config) throws ServletException
{
    servletContext = config.getServletContext();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:5,代码来源:FacesExtensionFilter.java

示例12: init

import javax.servlet.FilterConfig; //导入方法依赖的package包/类
/**
 * Initialize the filter.
 * 
 * @param args
 *            FilterConfig
 * @throws ServletException
 *             the servlet exception
 * @exception ServletException
 */
public void init(FilterConfig args) throws ServletException
{
    WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(args.getServletContext());
    this.filter = (DependencyInjectedFilter)ctx.getBean(args.getInitParameter(INIT_PARAM_BEAN_NAME));
    this.context = args.getServletContext();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:16,代码来源:BeanProxyFilter.java


注:本文中的javax.servlet.FilterConfig.getServletContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。