Class CayenneFilter
- java.lang.Object
-
- org.apache.cayenne.configuration.web.CayenneFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
public class CayenneFilter extends Object implements javax.servlet.Filter
A filter that creates a Cayenne server runtime, possibly including custom modules. By default runtime includesServerModule. Any custom modules are loaded after the two standard ones to allow custom service overrides. Filter initialization parameters:- configuration-location - (optional) a name of Cayenne configuration XML file that will be used to load Cayenne stack. If missing, the filter name will be used to derive the location. ".xml" extension will be appended to the filter name to get the location, so a filter named "cayenne-foo" will result in location "cayenne-foo.xml".
- extra-modules - (optional) a comma or space-separated list of class names, with
each class implementing
Moduleinterface. These are the custom modules loaded after the two standard ones that allow users to override any Cayenne runtime aspects, e.g.RequestHandler. Each custom module must have a no-arg constructor.
CayenneFilter is a great utility to quickly start a Cayenne application. More advanced apps most likely will not use it, relying on their own configuration mechanism (such as Guice, Spring, etc.)
- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.servlet.ServletContextservletContext
-
Constructor Summary
Constructors Constructor Description CayenneFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckAlreadyConfigured(javax.servlet.ServletContext context)voiddestroy()voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)protected Collection<org.apache.cayenne.di.Module>getAdditionalModules()Subclasses may override this to specify additional modules that should be included when creating the CayenneRuntime (in addition to those specified in the web.xml file).voidinit(javax.servlet.FilterConfig config)
-
-
-
Method Detail
-
init
public void init(javax.servlet.FilterConfig config) throws javax.servlet.ServletException- Specified by:
initin interfacejavax.servlet.Filter- Throws:
javax.servlet.ServletException
-
getAdditionalModules
protected Collection<org.apache.cayenne.di.Module> getAdditionalModules()
Subclasses may override this to specify additional modules that should be included when creating the CayenneRuntime (in addition to those specified in the web.xml file).- Since:
- 4.0
-
checkAlreadyConfigured
protected void checkAlreadyConfigured(javax.servlet.ServletContext context) throws javax.servlet.ServletException- Throws:
javax.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroyin interfacejavax.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:
doFilterin interfacejavax.servlet.Filter- Throws:
IOExceptionjavax.servlet.ServletException
-
-