Class AsyncCacheFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class AsyncCacheFilter
    extends AbstractFilter

    This Filter is a companion to the CachingAsyncDatastoreService, and must be installed any time the CachingAsyncDatastoreService is used without Objectify.

    This Filter is a temporary measure until Google provides a hook that lets us intercept the raw Future calls at the end of a request. At that point this filter can be eliminated in favor of the hook.

    In your web.xml:
           <filter>
                  <filter-name>AsyncCacheFilter</filter-name>
                  <filter-class>com.googlecode.objectify.cache.AsyncCacheFilter</filter-class>
          </filter>
          <filter-mapping>
                  <filter-name>AsyncCacheFilter</filter-name>
                  <url-pattern>/*</url-pattern>
          </filter-mapping>
    
    Or, if you use Guice:
          filter("/*").through(AsyncCacheFilter.class);
    

    Note that you do not need to configure this filter if you use the ObjectifyFilter.

    If you use the CachingAsyncDatastoreService outside of the context of a request (say, using the remote API or from a unit test), then you should call AsyncCacheFilter.complete() after every operation that you consider a "request". For example, after each test.

    Author:
    Jeff Schnitzer
    • Constructor Detail

      • AsyncCacheFilter

        public AsyncCacheFilter()
    • Method Detail

      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws IOException,
                             javax.servlet.ServletException
        Throws:
        IOException
        javax.servlet.ServletException
      • complete

        public static void complete()
        Perform the actions that are performed upon normal completion of a request.