Class AbstractAppPluginRootResource<T extends AppPlugin>
- java.lang.Object
-
- org.camunda.bpm.webapp.plugin.resource.AbstractAppPluginRootResource<T>
-
- Direct Known Subclasses:
AbstractAdminPluginRootResource
,AbstractCockpitPluginRootResource
,AbstractTasklistPluginRootResource
,AbstractWelcomePluginRootResource
public class AbstractAppPluginRootResource<T extends AppPlugin> extends java.lang.Object
A resource class that provides a plugins restful API.Subclasses of this class may provide subresources using annotated getters in order to be multi-engine aware.
Subresources must properly initialize the subresources via
subResource(AbstractAppPluginResource, String)
.- Author:
- nico.rehwaldt, Daniel Meyer
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>
allowedAssets
protected javax.ws.rs.core.HttpHeaders
headers
static java.lang.String
MIME_TYPE_TEXT_CSS
static java.lang.String
MIME_TYPE_TEXT_HTML
static java.lang.String
MIME_TYPE_TEXT_JAVASCRIPT
static java.lang.String
MIME_TYPE_TEXT_PLAIN
protected AppRuntimeDelegate<T>
runtimeDelegate
protected javax.servlet.ServletContext
servletContext
protected javax.ws.rs.core.UriInfo
uriInfo
-
Constructor Summary
Constructors Constructor Description AbstractAppPluginRootResource(java.lang.String pluginName, AppRuntimeDelegate<T> runtimeDelegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.io.InputStream
applyResourceOverrides(java.lang.String file, java.io.InputStream assetStream)
protected java.util.List<java.lang.String>
getAllowedAssets()
Returns the list of allowed assets to be served by thegetAsset(String)
method.javax.ws.rs.core.Response
getAsset(java.lang.String file)
Provides a plugins asset files via$PLUGIN_ROOT_PATH/static
.protected java.io.InputStream
getClasspathResourceAsStream(AppPlugin plugin, java.lang.String assetDirectory, java.lang.String fileName)
protected java.lang.String
getContentType(java.lang.String file)
protected java.io.InputStream
getPluginAssetAsStream(AppPlugin plugin, java.lang.String fileName)
Returns an input stream for a given resourceprotected java.io.InputStream
getWebResourceAsStream(java.lang.String assetDirectory, java.lang.String fileName)
protected <S extends AbstractAppPluginResource<T>>
SsubResource(S subResource, java.lang.String engineName)
-
-
-
Field Detail
-
MIME_TYPE_TEXT_PLAIN
public static final java.lang.String MIME_TYPE_TEXT_PLAIN
- See Also:
- Constant Field Values
-
MIME_TYPE_TEXT_HTML
public static final java.lang.String MIME_TYPE_TEXT_HTML
- See Also:
- Constant Field Values
-
MIME_TYPE_TEXT_CSS
public static final java.lang.String MIME_TYPE_TEXT_CSS
- See Also:
- Constant Field Values
-
MIME_TYPE_TEXT_JAVASCRIPT
public static final java.lang.String MIME_TYPE_TEXT_JAVASCRIPT
- See Also:
- Constant Field Values
-
servletContext
@Context protected javax.servlet.ServletContext servletContext
-
headers
@Context protected javax.ws.rs.core.HttpHeaders headers
-
uriInfo
@Context protected javax.ws.rs.core.UriInfo uriInfo
-
runtimeDelegate
protected AppRuntimeDelegate<T extends AppPlugin> runtimeDelegate
-
allowedAssets
protected java.util.List<java.lang.String> allowedAssets
-
-
Constructor Detail
-
AbstractAppPluginRootResource
public AbstractAppPluginRootResource(java.lang.String pluginName, AppRuntimeDelegate<T> runtimeDelegate)
-
-
Method Detail
-
getAllowedAssets
protected java.util.List<java.lang.String> getAllowedAssets()
Returns the list of allowed assets to be served by the
getAsset(String)
method.The default implementation includes:
["app/plugin.js","app/plugin.css"]
- Returns:
- list of allowed assets
-
subResource
protected <S extends AbstractAppPluginResource<T>> S subResource(S subResource, java.lang.String engineName)
- Type Parameters:
T
-- Parameters:
subResource
-engineName
-- Returns:
-
getAsset
@GET @Path("/static/{file:.*}") public javax.ws.rs.core.Response getAsset(@PathParam("file") java.lang.String file)
Provides a plugins asset files via
$PLUGIN_ROOT_PATH/static
.Assets must be explicitly declared in the
getAllowedAssets()
method.- Parameters:
file
-- Returns:
-
applyResourceOverrides
protected java.io.InputStream applyResourceOverrides(java.lang.String file, java.io.InputStream assetStream)
- Parameters:
file
-assetStream
-
-
getContentType
protected java.lang.String getContentType(java.lang.String file)
-
getPluginAssetAsStream
protected java.io.InputStream getPluginAssetAsStream(AppPlugin plugin, java.lang.String fileName)
Returns an input stream for a given resource- Parameters:
resourceName
-- Returns:
-
getWebResourceAsStream
protected java.io.InputStream getWebResourceAsStream(java.lang.String assetDirectory, java.lang.String fileName)
-
getClasspathResourceAsStream
protected java.io.InputStream getClasspathResourceAsStream(AppPlugin plugin, java.lang.String assetDirectory, java.lang.String fileName)
-
-