public interface ContentPlugin extends Plugin
Content plug-ins allow generated content to be returned by the application server in response to requests from the web browser. Where content plug-ins differ from similar mechanisms employed on most other application servers is that they are required to support flat-file export, and so must therefore have the following properties:
getValidDevContentPaths()
),
such that any requests from the browser that are not included in this list are considered to be an
error.Although content-plugins are designed to be usable both dynamically, and as part of a build (for flat-file export), a provision for generating different content in development and production is provided, for cases where things need to be done in a more efficient manner in production, and in a more dev-friendly manner in development. Developers that choose to exploit this facility should take care to ensure there is no chance of bugs being found in production, that can't also be observed in development; a core tenet of BladeRunnerJS.
The following methods are identifier-methods, and may be invoked before Plugin.setBRJS()
has been invoked:
CompositeContentPlugin
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getRequestPrefix()
Returns the prefix that all requests for this content plug-in will begin with.
|
java.util.List<java.lang.String> |
getUsedContentPaths(BundleSet bundleSet,
org.bladerunnerjs.model.RequestMode requestMode,
Locale... locales) |
java.util.List<java.lang.String> |
getValidContentPaths(BundleSet bundleSet,
org.bladerunnerjs.model.RequestMode requestMode,
Locale... locales)
Returns the list of valid content paths for the given bundle-set and locale.
|
ResponseContent |
handleRequest(java.lang.String contentPath,
BundleSet bundleSet,
org.bladerunnerjs.model.UrlContentAccessor contentAccessor,
java.lang.String version)
Get a reader for the content generated for the given request.
|
castTo, close, getPluginClass, instanceOf, setBRJS
java.lang.String getRequestPrefix()
Note: Developers should not rely on any class initialization performed within Plugin.setBRJS()
as this
method is an identifier-method which may be invoked before Plugin.setBRJS()
has itself been
invoked.
ResponseContent handleRequest(java.lang.String contentPath, BundleSet bundleSet, org.bladerunnerjs.model.UrlContentAccessor contentAccessor, java.lang.String version) throws MalformedRequestException, ContentProcessingException, ResourceNotFoundException
contentPath
- The content path the request is being made for.bundleSet
- The bundle-set for the bundlable node to which this request is related to.contentAccessor
- The output stream the content will be written to.version
- TODOContentProcessingException
- if a problem is encountered when generating the content. Typically a 500 type errorMalformedRequestException
- if the content path isn't formed properly. Typically a 400 type errorResourceNotFoundException
- if the content path is valid but the requested file/path doesn't exist. Typically a 404 type errorjava.util.List<java.lang.String> getValidContentPaths(BundleSet bundleSet, org.bladerunnerjs.model.RequestMode requestMode, Locale... locales) throws ContentProcessingException
bundleSet
- The bundle-set for which content paths must be generated.requestMode
- An enum representing the 'mode' for this request - either dev or prod.locales
- The locale for which content paths must be generated.ContentProcessingException
- if a problem is encountered.java.util.List<java.lang.String> getUsedContentPaths(BundleSet bundleSet, org.bladerunnerjs.model.RequestMode requestMode, Locale... locales) throws ContentProcessingException
ContentProcessingException