Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Created February 20, 2015 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhirockzz/24f9b3e4551397431c94 to your computer and use it in GitHub Desktop.
Save abhirockzz/24f9b3e4551397431c94 to your computer and use it in GitHub Desktop.
A CDI Producer (factory)
public class CacheControlFactory {
@Produces
public CacheControl get(InjectionPoint ip) {
CachControlConfig ccConfig = ip.getAnnotated().getAnnotation(CachControlConfig.class);
CacheControl cc = null;
if (ccConfig != null) {
cc = new CacheControl();
cc.setMaxAge(ccConfig.maxAge());
cc.setMustRevalidate(ccConfig.mustRevalidate());
cc.setNoCache(ccConfig.noCache());
cc.setNoStore(ccConfig.noStore());
cc.setNoTransform(ccConfig.noTransform());
cc.setPrivate(ccConfig.isPrivate());
cc.setProxyRevalidate(ccConfig.proxyRevalidate());
cc.setSMaxAge(ccConfig.sMaxAge());
}
return cc;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment