Class ObjectifyService.Filter

java.lang.Object
com.googlecode.objectify.ObjectifyService.Filter
All Implemented Interfaces:
jakarta.servlet.Filter
Enclosing class:
ObjectifyService

public static class ObjectifyService.Filter extends Object implements jakarta.servlet.Filter

This version is for the newer jakarta.servlet.* API. If you are using the older javax.servlet.*, use FilterJavax.

Configure this filter to use Objectify in your application. It works in concert with ObjectifyService to provide the correct Objectify instance when ObjectifyService.ofy() is called.

In your web.xml:

       <filter>
              <filter-name>ObjectifyFilter</filter-name>
              <filter-class>com.googlecode.objectify.ObjectifyService$Filter</filter-class>
      </filter>
      <filter-mapping>
              <filter-name>ObjectifyFilter</filter-name>
              <url-pattern>/*</url-pattern>
      </filter-mapping>

Or, if you use Guice:

      filter("/*").through(ObjectifyService.Filter.class);

If you use the Objectify outside of the context of a request (say, using the remote API or from a unit test), then you should use the ObjectifyService.run() method.

Author:
Jeff Schnitzer
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain)
     
    void
    init(jakarta.servlet.FilterConfig filterConfig)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Filter

      public Filter()
  • Method Details

    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Specified by:
      doFilter in interface jakarta.servlet.Filter
      Throws:
      IOException
      jakarta.servlet.ServletException
    • init

      public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException
      Specified by:
      init in interface jakarta.servlet.Filter
      Throws:
      jakarta.servlet.ServletException
    • destroy

      public void destroy()
      Specified by:
      destroy in interface jakarta.servlet.Filter