生命在于运动

3.2. Filters 过滤器 (to be modified)

  3.2. Filters            
              过滤器
 

Acegi Security 使用很多种过滤器,过滤器的内容将会贯穿本参考文档的剩余部分。你可以选择怎么样在你的web应用程序中使用这些过滤器,你可以使用FilterToBeanProxy或者FilterChainProxy。下面我们就会讨论这两个过滤器。

大多数过滤器都是使用FilterToBeanProxy配置,下面是一个web.xml中配置的例子:

<filter>

<filter-name>Acegi HTTP Request Security Filter</filter-name>

<filter-class>org.acegisecurity.util.FilterToBeanProxy</filter-class>

<init-param>

<param-name>targetClass</param-name>

<param-value>org.acegisecurity.ClassThatImplementsFilter</param-value>

</init-param>

</filter>

请注意,在web.xml中配置的过滤器实际上就是FilterToBeanProxy,而不是真正实现该过滤器逻辑的。FilterToBeanProxy的工作就是将过滤器的方法代理给一个bean,而这个bean能够从Spring应用的上下文中取到。这个将能够使bean享受到Spring应用程序上下文的生命周期的支持和配置的灵活性。当然该bean是必须要要实现javax.servlet.Filter的。FilterToBeanProxy仅仅需要一个简单的初始化参数,targetClass或者targetBeantargetClass是用来定位在应用程序上下文中第一个对象的指定类,而targetBean则是通过bean name来定位对象的。就好像标准的Spring web应用程序FilterToBeanProxy能够通过WebApplicationContextUtils.getWebApplicationContext(ServletContext)访问应用程序上下文,所以你该在web.xml中定义一个ContextLoaderListener

posted on 2008-01-10 17:35 burrows 阅读(224) 评论(0)  编辑  收藏 所属分类: Acegi Security 参考文档翻译


只有注册用户登录后才能发表评论。


网站导航: