09:24:20,106 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]] (http--0.0.0.0-80-33)
loginrpc: ERROR: The serialization policy file '/v4workflow/FB64C6F0204DFD63FB92E5485E94A4E0.gwt.rpc' was not found;
did you forget to include it in this deployment?
09:24:20,106 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]]
(http--0.0.0.0-80-33) loginrpc: WARNING: Failed to get the SerializationPolicy 'FB64C6F0204DFD63FB92E5485E94A4E0'
for module a legacy, 1.3.3 compatible, serialization policy will be used.
you may experience SerializationExceptions as a result.
servlet.getServletContext().getResourceAsStream. You can customize this by overriding doGetSerializationPolicy (as said in the JavaDoc).
The file name (resource URL) is built from the request's path and X-GWT-Permutation request
<filter>
<filter-name>gwtCacheControlFilter</filter-name>
<filter-class>com.server.GWTCacheControlFilter</filter-class>
<init-param>
<param-name>private</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>expirationTime</param-name>
<param-value>2592000</param-value>
</init-param>
</filter>
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import com.samaxes.filter.util.CacheConfigParameter;
import com.samaxes.filter.util.Cacheability;
import com.samaxes.filter.util.HTTPCacheHeader;
/**
* Code imported from cachefilter.jar
* <br/><br/>
*/
public class GWTCacheControlFilter implements Filter {
private final static String[] STATIC_CONTENTS = { ".jpeg", ".jpg", ".gif",
".png", ".css", ".js", ".html" };
private Cacheability cacheability;
private boolean isStatic;
private long seconds;
private static final Logger LOGGER = Logger.getLogger(GWTCacheControlFilter.class);
public static final int YEAR_IN_MINUTES = 365 * 24 * 60 * 60;
public void destroy() {
}
public void init(FilterConfig filterConfig) throws ServletException {
this.cacheability = (Boolean.valueOf(filterConfig.getInitParameter(CacheConfigParameter.PRIVATE.getName())).booleanValue() ? Cacheability.PRIVATE : Cacheability.PUBLIC);
this.isStatic = Boolean.valueOf(filterConfig.getInitParameter(CacheConfigParameter.STATIC.getName())).booleanValue();
try{
this.seconds = Long.valueOf(filterConfig.getInitParameter(CacheConfigParameter.EXPIRATION_TIME.getName())).longValue();
} catch (NumberFormatException e) {
throw new ServletException("The initialization parameter " +
CacheConfigParameter.EXPIRATION_TIME.getName() + " is missing for filter " +
filterConfig.getFilterName() + ".");
}
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String requestURI = httpRequest.getRequestURI();
HttpServletResponse httpResponse = (HttpServletResponse) response;
if (requestURI.contains(".nocache.")) {
Date now = new Date();
httpResponse.setDateHeader("Date", now.getTime());
// one day old
httpResponse.setDateHeader("Expires", now.getTime() - 86400000L);
httpResponse.setHeader("Pragma", "no-cache");
httpResponse.setHeader("Cache-control",
"no-cache, no-store, max-age=0, must-revalidate");
}else if ( requestURI.contains( ".cache." ) ){
// set expiry to back in the past (makes us a bad candidate for caching)
final Calendar calendar = Calendar.getInstance();
calendar.setTime( new Date() );
calendar.add( Calendar.YEAR, 1 );
httpResponse.setDateHeader( "Expires", calendar.getTime().getTime() );
httpResponse.setHeader( "Cache-control", "max-age=" + YEAR_IN_MINUTES + ", public" );
httpResponse.setHeader( "Pragma", "" );
} else if (isStaticContentUri(requestURI)) {
StringBuilder cacheControl = new StringBuilder(this.cacheability.getValue()).append(", max-age=").append(this.seconds);
if (!this.isStatic) {
cacheControl.append(", must-revalidate");
}
httpResponse.setHeader(HTTPCacheHeader.CACHE_CONTROL.getName(), cacheControl.toString());
httpResponse.setDateHeader(HTTPCacheHeader.EXPIRES.getName(), System.currentTimeMillis() + this.seconds * 1000L);
if (httpResponse.containsHeader("Pragma")) {
LOGGER.debug("found pragma header");
httpResponse.setHeader(HTTPCacheHeader.PRAGMA.getName(), "");
} else {
LOGGER.debug("did not find pragma header");
}
}
filterChain.doFilter(request, response);
}
private boolean isStaticContentUri(String uri) {
uri = uri.toLowerCase();
for (String contentType : STATIC_CONTENTS) {
if (uri.endsWith(contentType.toLowerCase()))
return true;
}
return false;
}
}