public class

BatchPluginResource

extends Object
implements DownloadableResource BatchResource PluginResource
java.lang.Object
   ↳ com.atlassian.plugin.webresource.BatchPluginResource

Class Overview

Represents a batch of plugin resources.

It provides methods to parse and generate urls to locate a batch of plugin resources.

Note BatchPluginResource is also a type of DownloadableResource. The underlying implementation simply keeps a list of DownloadableResource of which this batch represents and delegates method calls.

Summary

Public Constructors
BatchPluginResource(String moduleCompleteKey, String type, Map<StringString> params)
A constructor that creates a default resource name for the batch in the format: moduleCompleteKey.type For example: test.plugin:resources.js

Note that name of the batch does not identify what the batch includes and could have been static e.g.
BatchPluginResource(String moduleCompleteKey, String type, Map<StringString> params, Iterable<DownloadableResource> resources)
A constructor that creates a default resource name for the batch in the format: moduleCompleteKey.type For example: test.plugin:resources.js

This constructor includes the resources that are contained in the batch, and so is primarily for use when serving the resource.
Public Methods
boolean equals(Object o)
String getContentType()
Returns the content type for the resource.
String getModuleCompleteKey()
Map<StringString> getParams()
String getResourceName()
String getType()
String getUrl()
Returns a url string in the format: /download/batch/MODULE_COMPLETE_KEY/resourceName?PARAMS e.g.
String getVersion(WebResourceIntegration integration)
int hashCode()
boolean isCacheSupported()
boolean isEmpty()
boolean isResourceModified(HttpServletRequest request, HttpServletResponse response)
Returns true if the plugin resource has been modified.
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
void addParamsToUrl(StringBuilder sb, Map<StringString> params)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.plugin.servlet.DownloadableResource
From interface com.atlassian.plugin.webresource.BatchResource
From interface com.atlassian.plugin.webresource.PluginResource

Public Constructors

public BatchPluginResource (String moduleCompleteKey, String type, Map<StringString> params)

A constructor that creates a default resource name for the batch in the format: moduleCompleteKey.type For example: test.plugin:resources.js

Note that name of the batch does not identify what the batch includes and could have been static e.g. batch.js
Parameters
moduleCompleteKey - the key of the plugin module
type - the type of resource (CSS/JS)
params - the parameters of the resource (ieonly, media, etc)

public BatchPluginResource (String moduleCompleteKey, String type, Map<StringString> params, Iterable<DownloadableResource> resources)

A constructor that creates a default resource name for the batch in the format: moduleCompleteKey.type For example: test.plugin:resources.js

This constructor includes the resources that are contained in the batch, and so is primarily for use when serving the resource.
Parameters
moduleCompleteKey - the key of the plugin module
type - the type of resource (CSS/JS)
params - the parameters of the resource (ieonly, media, etc)
resources - the resources included in the batch.

Public Methods

public boolean equals (Object o)

public String getContentType ()

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

public String getModuleCompleteKey ()

public Map<StringString> getParams ()

public String getResourceName ()

public String getType ()

public String getUrl ()

Returns a url string in the format: /download/batch/MODULE_COMPLETE_KEY/resourceName?PARAMS e.g. /download/batch/example.plugin:webresources/example.plugin:webresources.css?ie=true

It is important for the url structure to be: 1. the same number of sectioned paths as the SinglePluginResource 2. include the module completey key in the path before the resource name This is due to css resources referencing other resources such as images in relative path forms.

public String getVersion (WebResourceIntegration integration)

public int hashCode ()

public boolean isCacheSupported ()

public boolean isEmpty ()

Returns
  • true if there are no resources included in this batch

public boolean isResourceModified (HttpServletRequest request, HttpServletResponse response)

Returns true if the plugin resource has been modified. The implementing class is responsible for setting any appropriate response codes or headers on the response. If the resource has been modified, the resource shouldn't be served.

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 void addParamsToUrl (StringBuilder sb, Map<StringString> params)