public interface

WebResourceIntegration

com.atlassian.plugin.webresource.WebResourceIntegration

Class Overview

The integration layer between Plugin's Web Resource Handler, and specific applications (eg JIRA, Confluence).

See Also
  • WebResourceManagerImpl#WebResourceManagerImpl(PluginResourceLocator, WebResourceIntegration)

Summary

Public Methods
String getBaseUrl(UrlMode urlMode)
Returns the base URL for this application in either relative or absolute format, depending on the value of urlMode.
String getBaseUrl()
Returns the base URL for this application.
PluginAccessor getPluginAccessor()
Applications must implement this method to get access to the application's PluginAccessor
Map<StringObject> getRequestCache()
This must be a thread-local cache that will be accessible from both the page, and the decorator
String getStaticResourceLocale()
The locale identifier that should be inserted into static resource urls for the current request, if appropriate.
String getSuperBatchVersion()
This version number is used for caching URL generation, and needs to be incremented every time the contents of the superbatch may have changed.
String getSystemBuildNumber()
Represents the last time the system was updated.
String getSystemCounter()
Represents the unique number for this system, which when updated will flush the cache.
File getTemporaryDirectory()
A reference to the temporary directory the application want the plugin system to use.

Public Methods

public String getBaseUrl (UrlMode urlMode)

Returns the base URL for this application in either relative or absolute format, depending on the value of urlMode.

If urlMode == {@link UrlMode#ABSOLUTE}, this method returns an absolute URL, with URL scheme, hostname, port (if non-standard for the scheme), and context path.

If urlMode == {@link UrlMode#RELATIVE}, this method returns a relative URL containing just the context path.

If urlMode == {@link UrlMode#AUTO}, this method may return either an absolute or a relative URL. Implementations are free to determine which mode to use based on any criteria of their choosing. For example, an implementation may choose to return a relative URL if it detects that it is running in the context of an HTTP request, and an absolute URL if it detects that it is not. Or it may choose to always return an absolute URL, or always return a relative URL. Callers should only use WebResourceManager.UrlMode#AUTO when they are sure that either an absolute or a relative URL will be appropriate, and should not rely on any particular observed behavior regarding how this value is interpreted, which may vary across different implementations.
Parameters
urlMode specifies whether to use absolute URLs, relative URLs, or allow the concrete implementation to decide
Returns
  • the string value of the base URL of this application

public String getBaseUrl ()

Returns the base URL for this application. This method may return either an absolute or a relative URL. Implementations are free to determine which mode to use based on any criteria of their choosing. For example, an implementation may choose to return a relative URL if it detects that it is running in the context of an HTTP request, and an absolute URL if it detects that it is not. Or it may choose to always return an absolute URL, or always return a relative URL. Callers should only use this method when they are sure that either an absolute or a relative URL will be appropriate, and should not rely on any particular observed behavior regarding how this value is interpreted, which may vary across different implementations.

In general, the behavior of this method should be equivalent to calling getBaseUrl(UrlMode) with a urlMode value of AUTO.
Returns
  • the string value of the base URL of this application

public PluginAccessor getPluginAccessor ()

Applications must implement this method to get access to the application's PluginAccessor

public Map<StringObject> getRequestCache ()

This must be a thread-local cache that will be accessible from both the page, and the decorator

public String getStaticResourceLocale ()

The locale identifier that should be inserted into static resource urls for the current request, if appropriate.

Returns
  • null if the url should not have a locale component

public String getSuperBatchVersion ()

This version number is used for caching URL generation, and needs to be incremented every time the contents of the superbatch may have changed. Practically this means updating every time the plugin system state changes

Returns
  • a version number

public String getSystemBuildNumber ()

Represents the last time the system was updated. This is generally obtained from BuildUtils or similar.

public String getSystemCounter ()

Represents the unique number for this system, which when updated will flush the cache. This should be a number and is generally stored in the global application-properties.

Returns
  • A string representing the count

public File getTemporaryDirectory ()

A reference to the temporary directory the application want the plugin system to use. The temporary directory can be cleared at any time by the application and can be used by the plugin system to cache things like batches or other things that can easily be re-generated. It is recommended that this directory be /apphome/tmp/webresources. The plugin system can delete any or all files it sees fit that exists under this directory at any time. The directory does not need to exist.

Returns
  • a File reference to the temporary directory. This can not return null.