Package com.atlassian.plugin.servlet
Class DownloadableWebResource
java.lang.Object
com.atlassian.plugin.servlet.DownloadableWebResource
- All Implemented Interfaces:
DownloadableResource
A
DownloadableResource that will serve the resource via the web application's ServletContext.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDownloadableWebResource(Plugin plugin, com.atlassian.plugin.elements.ResourceLocation resourceLocation, String extraPath, jakarta.servlet.ServletContext servletContext, boolean disableMinification) -
Method Summary
Modifier and TypeMethodDescriptionReturns the content type for the resource.protected StringThis is called to return the location of the resource that this object represents.protected InputStreamgetResourceAsStream(String resourceLocation) Returns anInputStreamto stream the resource from based on resource name.booleanisResourceModified(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) Checks any "If-Modified-Since" header from the request against the plugin's loading time, since plugins can't be modified after they've been loaded this is a good way to determine if a plugin resource has been modified or not.voidserveResource(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Writes the resource content out into the response.voidWrite the resource to the supplied OutputStream.toString()
-
Field Details
-
plugin
-
extraPath
-
resourceLocation
protected final com.atlassian.plugin.elements.ResourceLocation resourceLocation
-
-
Constructor Details
-
DownloadableWebResource
-
-
Method Details
-
getResourceAsStream
Returns anInputStreamto stream the resource from based on resource name.- Parameters:
resourceLocation- the location of the resource to try and load- Returns:
- an InputStream if the resource can be found or null if cant be found
-
serveResource
public void serveResource(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws DownloadException Description copied from interface:DownloadableResourceWrites the resource content out into the response.- Specified by:
serveResourcein interfaceDownloadableResource- Throws:
DownloadException- if there were errors writing to the response.
-
streamResource
Description copied from interface:DownloadableResourceWrite the resource to the supplied OutputStream. Note that the OutputStream will not be closed by this method.- Specified by:
streamResourcein interfaceDownloadableResource- Parameters:
out- the stream to write to- Throws:
DownloadException- if there were errors writing to the response. Since 2.3.
-
isResourceModified
public boolean isResourceModified(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) Checks any "If-Modified-Since" header from the request against the plugin's loading time, since plugins can't be modified after they've been loaded this is a good way to determine if a plugin resource has been modified or not. If this method returns true, don't do any more processing on the request -- the response code has already been set to "304 Not Modified" for you, and you don't need to serve the file.- Specified by:
isResourceModifiedin interfaceDownloadableResource
-
getContentType
Description copied from interface:DownloadableResourceReturns the content type for the resource. May return null if it cannot resolve its own content type.- Specified by:
getContentTypein interfaceDownloadableResource
-
getLocation
This is called to return the location of the resource that this object represents.- Returns:
- the location of the resource that this object represents.
-
toString
-