Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.acegisecurity.util
Class FilterToBeanProxy

    java.lang.Object
      org.acegisecurity.util.FilterToBeanProxy

All Implemented Interfaces:
  javax.servlet.Filter

    public class FilterToBeanProxy

extends Object
implements javax.servlet.Filter

Delegates `Filter` requests to a Spring-managed bean.

This class acts as a proxy on behalf of a target `Filter` that is defined in the Spring bean context. It is necessary to specify which target `Filter` should be proxied as a filter initialization parameter.

On filter initialisation, the class will use Spring's `WebApplicationContextUtils.getWebApplicationContext(ServletContext sc)` method to obtain an `ApplicationContext` instance. It will expect to find the target `Filter` in this `ApplicationContext`.

To use this filter, it is necessary to specify one of the following filter initialization parameters:

- `targetClass` indicates the class of the target `Filter` defined in the bean context. The only requirements are that this target class implements the `javax.servlet.Filter` interface and at least one instance is available in the `ApplicationContext`.
- `targetBean` indicates the bean name of the target class.

If both initialization parameters are specified, `targetBean` takes priority.

An additional initialization parameter, `init`, is also supported. If set to "`lazy`" the initialization will take place on the first HTTP request, rather than at filter creation time. This makes it possible to use `FilterToBeanProxy` with the Spring `ContextLoaderServlet`. Where possible you should not use this initialization parameter, instead using `ContextLoaderListener`.

A final optional initialization parameter, `lifecycle`, determines whether the servlet container or the IoC container manages the lifecycle of the proxied filter. When possible you should write your filters to be managed via the IoC container interfaces such as `InitializingBean` and `DisposableBean`. If you cannot control the filters you wish to proxy (eg you do not have their source code) you might need to allow the servlet container to manage lifecycle via the `Filter.init(javax.servlet.FilterConfig)` and `Filter.destroy()` methods. If this case, set the `lifecycle` initialization parameter to `servlet-container-managed`. If the parameter is any other value, servlet container lifecycle methods will not be delegated through to the proxy.

Version:
  $Id: FilterToBeanProxy.java,v 1.9 2005/11/17 00:56:09 benalex Exp $
Author:
  Ben Alex

Constructor Summary
`FilterToBeanProxy()`

Method Summary
`void` | `destroy()`
`void` | `doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)`
`protected ApplicationContext` | `getContext(javax.servlet.FilterConfig filterConfig)` Allows test cases to override where application context obtained from.
`void` | `init(javax.servlet.FilterConfig filterConfig)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FilterToBeanProxy

    public FilterToBeanProxy()

Method Detail

### destroy

    public void destroy()

  Specified by:
    `destroy` in interface `javax.servlet.Filter`

### doFilter

    public void doFilter(javax.servlet.ServletRequest request,
                         javax.servlet.ServletResponse response,
                         javax.servlet.FilterChain chain)
                  throws IOException,
                         javax.servlet.ServletException

  Specified by:
    `doFilter` in interface `javax.servlet.Filter`
  Throws:
    `IOException`
    `javax.servlet.ServletException`

### init

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

  Specified by:
    `init` in interface `javax.servlet.Filter`
  Throws:
    `javax.servlet.ServletException`

### getContext

    protected ApplicationContext getContext(javax.servlet.FilterConfig filterConfig)

  Allows test cases to override where application context obtained from.

  Parameters:
    `filterConfig` - which can be used to find the `ServletContext`
  Returns:
    the Spring application context

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2005 Acegi Technology Pty Limited. All Rights Reserved.