Class 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 includes ServerModule. 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 Module interface. 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 Detail

      • servletContext

        protected javax.servlet.ServletContext servletContext
    • Constructor Detail

      • CayenneFilter

        public CayenneFilter()
    • Method Detail

      • init

        public void init​(javax.servlet.FilterConfig config)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.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:
        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