Here is how I inject spring services into my filter:
This example just makes the transaction manager available to the servlet
filter.
In your context.xml file:
<bean id="suspendableTransactionFilter"
class="com.celeres.pago.util.filters.SuspendableTransactionFilter">
<property name="suspendableTransactionManager">
<ref bean="transactionManager"/>
</property>
</bean>
In your web.xml:
<filter>
<filter-name>Suspendable Transaction
Filter</filter-name>
<filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
<init-param>
<param-name>targetClass</param-name>
<param-value>
com.celeres.pago.util.filters.SuspendableTransactionFilter</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Suspendable Transaction
Filter</filter-name>
<url-pattern>/do/*</url-pattern>
</filter-mapping>
Hope this helps,
Craig
-----Original Message-----
From: Dan Adams [mailto:[EMAIL PROTECTED]
Sent: Friday, September 23, 2005 8:25 AM
To: Tapestry users
Subject: [OT] accessing spring in a filter
I'm writing a servlet redirect filter and need to look something up
using one of my services (which use hibernate). Anyone have any
suggestions on an good/efficient way to do this? As long as I can call
getBean() I'll be all set.
--
Dan Adams
Software Engineer
Interactive Factory
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]