org.apache.cayenne.configuration.web

## 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 includes `ServerModule` and `WebModule`. 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 Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected javax.servlet.ServletContext` | `servletContext`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CayenneFilter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `checkAlreadyConfigured(javax.servlet.ServletContext context)`
    `void` | `destroy()`
    `void` | `doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)`
    `protected Collection<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).
    `void` | `init(javax.servlet.FilterConfig config)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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<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`

Copyright © 2001–2018 Apache Cayenne. All rights reserved.