|
From: Ben A. <ben...@ac...> - 2005-03-04 05:11:53
|
Yaroslav Gnatyuk wrote: >Currently there is no way to inject dependencies into filter. Instead, >it must lookup for beans in application context. It would be great to >initialize fields of filter with beans, corresponding to init-param >values instead of with that values themselves. > > > http://acegisecurity.sourceforge.net/docbook/acegi.html#security-filters discusses two solutions: 1. FilterToBeanProxy, which loads a bean directly from your application context (where Spring wires them for you as normal) 2, FilterChainProxy, which is URI sensitive and fires whatever application context-defined Filters you like. Historically there was concern about lifecycle methods (ie should a servlet container manage the Filter lifecycle, or should the application context)? As per the docs, this is now configurable and defaults to expecting the application context to manage lifecycle. This is basically because the application context has far richer lifecycle methods than offered by the servlet container, and, more justifiably, a Filter that expects setters to be called is obviously IoC container aware and as such should be designed to use IoC lifecycle services as opposed to servlet container ones. Best regards Ben |