Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.jersey.caching;
 
 
        private static final int ONE_YEAR_IN_SECONDS = (int..toSeconds(365);
        private final ResourceMethodDispatchProvider provider;
            this. = provider;
        }
        @Override
        public RequestDispatcher create(AbstractResourceMethod abstractResourceMethod) {
            final RequestDispatcher dispatcher = .create(abstractResourceMethod);
            final CacheControl control = abstractResourceMethod.getAnnotation(CacheControl.class);
            if (control != null) {
                final javax.ws.rs.core.CacheControl cacheControl = new javax.ws.rs.core.CacheControl();
                cacheControl.setPrivate(control.isPrivate());
                cacheControl.setNoCache(control.noCache());
                cacheControl.setNoStore(control.noStore());
                cacheControl.setNoTransform(control.noTransform());
                cacheControl.setMustRevalidate(control.mustRevalidate());
                cacheControl.setProxyRevalidate(control.proxyRevalidate());
                cacheControl.setMaxAge((intcontrol.maxAgeUnit().toSeconds(control.maxAge()));
                cacheControl.setSMaxAge((intcontrol.sharedMaxAgeUnit()
                                                     .toSeconds(control.sharedMaxAge()));
                if (control.immutable()) {
                    cacheControl.setMaxAge();
                }
                return new CacheControlledRequestDispatcher(dispatchercacheControl);
            }
            return dispatcher;
        }
    }
    private static class CacheControlledRequestDispatcher implements RequestDispatcher {
        private final RequestDispatcher dispatcher;
        private final String cacheControl;
        private CacheControlledRequestDispatcher(RequestDispatcher dispatcherjavax.ws.rs.core.CacheControl cacheControl) {
            this. = dispatcher;
            this. = cacheControl.toString();
        }
        @Override
        public void dispatch(Object resourceHttpContext context) {
            .dispatch(resourcecontext);
            if (!.isEmpty()) {
                context.getResponse().getHttpHeaders().add(.);
            }
        }
    }
    @Override
        return new CacheControlledResourceMethodDispatchProvider(provider);
    }
New to GrepCode? Check out our FAQ X