com.googlecode.objectify.cache.AsyncCacheFilter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of objectify Show documentation
Show all versions of objectify Show documentation
*** THIS VERSION UPLOADED FOR USE WITH CEDAR-COMMON, TO AVOID DEPENDENCIES ON GOOGLE CODE-BASED MAVEN REPOSITORIES. *** The simplest convenient interface to the Google App Engine datastore
The newest version!
package com.googlecode.objectify.cache;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
/**
* This Filter is a companion to the CachingAsyncDatastoreService, and must be
* installed any time the CachingAsyncDatastoreService is used.
*
* 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);
*
*
* @author Jeff Schnitzer
*/
public class AsyncCacheFilter implements Filter
{
@Override
public void init(FilterConfig config) throws ServletException
{
}
@Override
public void destroy()
{
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
try
{
chain.doFilter(request, response);
}
finally
{
TriggerFutureHook.completeAllPendingFutures();
}
}
}