public class

DownloadableClasspathResource

extends Object
implements DownloadableResource
java.lang.Object
   ↳ com.atlassian.plugin.servlet.DownloadableClasspathResource

Class Overview

A DownloadableResource that will serve the resource from the plugin.

See Also
  • {@link Plugin#getResourceAsStream(String)}.

Summary

Fields
protected final String extraPath
protected final Plugin plugin
protected final ResourceLocation resourceLocation
Public Constructors
DownloadableClasspathResource(Plugin plugin, ResourceLocation resourceLocation, String extraPath)
Public Methods
String getContentType()
Returns the content type for the resource.
boolean isResourceModified(HttpServletRequest httpServletRequest, 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.
void serveResource(HttpServletRequest request, HttpServletResponse response)
Writes the resource content out into the response.
void streamResource(OutputStream out)
Write the resource to the supplied OutputStream.
String toString()
Protected Methods
String getLocation()
This is called to return the location of the resource that this object represents.
InputStream getResourceAsStream(String resourceLocation)
Returns an InputStream to stream the resource from based on resource name.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.plugin.servlet.DownloadableResource

Fields

protected final String extraPath

protected final Plugin plugin

protected final ResourceLocation resourceLocation

Public Constructors

public DownloadableClasspathResource (Plugin plugin, ResourceLocation resourceLocation, String extraPath)

Public Methods

public String getContentType ()

Returns the content type for the resource. May return null if it cannot resolve its own content type.

public boolean isResourceModified (HttpServletRequest httpServletRequest, 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.

public void serveResource (HttpServletRequest request, HttpServletResponse response)

Writes the resource content out into the response.

public void streamResource (OutputStream out)

Write the resource to the supplied OutputStream. Note that the OutputStream will not be closed by this method.

Parameters
out the stream to write to

public String toString ()

Protected Methods

protected String 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.

protected InputStream getResourceAsStream (String resourceLocation)

Returns an InputStream to 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