|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.wideplay.warp.persist.PersistenceFilter
@ThreadSafe public class PersistenceFilter
Apply this filter to enable the HTTP Request unit of work and to have Warp Persist manage the lifecycle of
all the active (module installed) PersistenceService
instances.
The filter automatically starts and stops all registered PersistenceService
instances
upon Filter.init(javax.servlet.FilterConfig)
and
Filter.destroy()
. To disable the managing of PersistenceService instances,
override Filter.init(javax.servlet.FilterConfig)
and Filter.destroy()
.
To be able to use UnitOfWork.REQUEST
, register this filter once in the
web.xml
or using Guice's 2.0 ServletModule
. It is important that you register this filter
before any other framework filter (except the Guice servlet filter). Example configuration:
<filter>
<filter-name>persistenceFilter</filter-name>
<filter-class>com.wideplay.warp.persist.PersistenceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>persistenceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Important note: Filter.init(javax.servlet.FilterConfig)
will have no effect if Guice has
not been started before it gets called. Usually this means Guice should be started in a
ServletContextListener
. If you can't for some reason, don't worry; all
PersistenceService
instances will automatically start when they first get used.
Just make sure you don't get any incoming request before Guice starts.
Even though all mutable state is package local, this Filter is thread safe. This allows people to create injectors concurrently and deploy multiple Warp Persist applications within the same VM / web container.
UnitOfWork
Constructor Summary | |
---|---|
PersistenceFilter()
|
Method Summary | |
---|---|
void |
destroy()
Stops all registered PersistenceService instances. |
void |
doFilter(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse,
javax.servlet.FilterChain filterChain)
Activates the HTTP request unit of work. |
void |
init(javax.servlet.FilterConfig filterConfig)
Starts all registered PersistenceService instances. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PersistenceFilter()
Method Detail |
---|
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
PersistenceService
instances.
init
in interface javax.servlet.Filter
filterConfig
- the filter config
javax.servlet.ServletException
- when one or more {code PersistenceService} instances could not be startedpublic void destroy()
PersistenceService
instances.
destroy
in interface javax.servlet.Filter
public void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
servletRequest
- HTTP requestservletResponse
- HTTP responsefilterChain
- filter chain
IOException
javax.servlet.ServletException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |