@Test public void whenResourceHasLinksAddThemToTheHeader() { CacheableOrder cacheable = new CacheableOrder(); handler.handle(cacheable); }
public void handle(HypermediaResource resource) { if(Cacheable.class.isAssignableFrom(resource.getClass())) { Cacheable cache = (Cacheable) resource; response.addHeader("Cache-control","max-age=" + cache.getMaximumAge()); } if(RestfulEntity.class.isInstance(resource)) { RestfulEntity entity = (RestfulEntity) resource; restfulHeadersFor(entity.getEtag(), entity.getLastModified()); } else { restfulHeadersFor(defaults.getEtagFor(resource), defaults.getLastModifiedFor(resource)); } }
DefaultRestHeadersHandler implements RestHeadersHandler { public void handle(HypermediaResource resource) { if(Cacheable.class.isAssignableFrom(resource.getClass())) { Cacheable cache = (Cacheable) resource; response.addHeader("Cache-control","max-age=" + cache.getMaximumAge()); } if(RestfulEntity.class.isInstance(resource)) { RestfulEntity entity = (RestfulEntity) resource; restfulHeadersFor(entity.getEtag(), entity.getLastModified()); } else { restfulHeadersFor(defaults.getEtagFor(resource), defaults.getLastModifiedFor(resource)); } } }
DefaultRestHeadersHandler implements RestHeadersHandler { public void handle(HypermediaResource resource) { if(Cacheable.class.isAssignableFrom(resource.getClass())) { Cacheable cache = (Cacheable) resource; response.addHeader("Cache-control","max-age=" + cache.getMaximumAge()); } if(RestfulEntity.class.isInstance(resource)) { RestfulEntity entity = (RestfulEntity) resource; restfulHeadersFor(entity.getEtag(), entity.getLastModified()); } else { restfulHeadersFor(defaults.getEtagFor(resource), defaults.getLastModifiedFor(resource)); } } DefaultRestHeadersHandler(HttpServletResponse response, RestDefaults defaults); }
DefaultRestHeadersHandler implements RestHeadersHandler { public void handle(HypermediaResource resource) { if(Cacheable.class.isAssignableFrom(resource.getClass())) { Cacheable cache = (Cacheable) resource; response.addHeader("Cache-control","max-age=" + cache.getMaximumAge()); } if(RestfulEntity.class.isInstance(resource)) { RestfulEntity entity = (RestfulEntity) resource; restfulHeadersFor(entity.getEtag(), entity.getLastModified()); } else { restfulHeadersFor(defaults.getEtagFor(resource), defaults.getLastModifiedFor(resource)); } } DefaultRestHeadersHandler(HttpServletResponse response, RestDefaults defaults); void handle(HypermediaResource resource); }
DefaultRestHeadersHandler implements RestHeadersHandler { public void handle(HypermediaResource resource) { if(Cacheable.class.isAssignableFrom(resource.getClass())) { Cacheable cache = (Cacheable) resource; response.addHeader("Cache-control","max-age=" + cache.getMaximumAge()); } if(RestfulEntity.class.isInstance(resource)) { RestfulEntity entity = (RestfulEntity) resource; restfulHeadersFor(entity.getEtag(), entity.getLastModified()); } else { restfulHeadersFor(defaults.getEtagFor(resource), defaults.getLastModifiedFor(resource)); } } DefaultRestHeadersHandler(HttpServletResponse response, RestDefaults defaults); void handle(HypermediaResource resource);  }