protected ResourceResponse newResourceResponse(final IResource.Attributes attributes) { final ResourceResponse response = new ResourceResponse(); if (this.lastModifiedTime != null) { response.setLastModified(this.lastModifiedTime); } else { response.setLastModified(Time.now()); } if (response.dataNeedsToBeWritten(attributes)) { response.setContentType("image/" + this.getFormat()); response.setContentDisposition(ContentDisposition.INLINE); final byte[] imageData = this.getImageData(attributes); if (imageData == null) { response.setError(404); } else { response.setWriteCallback( new WriteCallback() { public void writeData(final IResource.Attributes attributes) { attributes.getResponse().write(imageData); } }); this.configureResponse(response, attributes); } } return response; }