@ConsumerType
public interface BundledRenderUnit
A BundledRenderUnit represents a pre-packaged script or precompiled script (Java class) that will be executed in order to
render a HttpServletRequest.
The BundledRenderUnit provider module is responsible for defining how a unit is executed. However, when executing the unit in the
context of a ScriptEngine, the provider module should add the current executing unit into the ScriptEngine's ScriptContext using the VARIABLE key.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
VARIABLE
The variable available in the
Bindings associated to a HttpServletRequest if
that request is served by a BundledRenderUnit. |
| Modifier and Type | Method and Description |
|---|---|
void |
eval(@NotNull javax.servlet.http.HttpServletRequest request,
@NotNull javax.servlet.http.HttpServletResponse response)
This method will execute / evaluate the wrapped script or precompiled script with the given request.
|
@NotNull org.osgi.framework.Bundle |
getBundle()
Returns the
Bundle the publishing bundle of this unit (not to be confused with the provider module, which is the module that
instantiates a BundledRenderUnit). |
@NotNull org.osgi.framework.BundleContext |
getBundleContext()
Returns the
BundleContext to use for this unit. |
default @Nullable java.io.InputStream |
getInputStream()
This method will return an input stream if
this unit is backed by a script that can be interpreted. |
@NotNull java.lang.String |
getName()
Returns the name of
this BundledRenderUnit. |
@NotNull java.lang.String |
getPath()
Returns the path of this executable in the resource type hierarchy.
|
<T> T |
getService(@NotNull java.lang.String className)
Retrieves an OSGi runtime dependency of the wrapped script identified by the passed
className parameter. |
<T> T[] |
getServices(@NotNull java.lang.String className,
@Nullable java.lang.String filter)
Retrieves multiple instances of an OSGi runtime dependency of the wrapped script identified by the passed
className
parameter, filtered according to the passed filter. |
@NotNull java.util.Set<TypeProvider> |
getTypeProviders()
Returns the
Set of TypeProviders which are related to this unit. |
default @Nullable java.lang.Object |
getUnit()
In case this
BundledRenderUnit wraps a precompiled script, this method will return an instance of that object. |
static final java.lang.String VARIABLE
Bindings associated to a HttpServletRequest if
that request is served by a BundledRenderUnit.@Nullable default @Nullable java.lang.Object getUnit()
BundledRenderUnit wraps a precompiled script, this method will return an instance of that object.this unit wraps a precompiled script; null otherwise@NotNull @NotNull java.lang.String getName()
this BundledRenderUnit. This can be the name of the wrapped script or precompiled script.this BundledRenderUnit@NotNull @NotNull org.osgi.framework.Bundle getBundle()
Bundle the publishing bundle of this unit (not to be confused with the provider module, which is the module that
instantiates a BundledRenderUnit). This method can be useful for getting an instance of the bundle's classloader, when
needed to load dependencies at run-time. To do so the following code example can help:
Bundle bundle = bundledRenderUnit.getBundle(); Classloader bundleClassloader = bundle.adapt(BundleWiring.class).getClassLoader();
@NotNull @NotNull org.osgi.framework.BundleContext getBundleContext()
BundleContext to use for this unit. This method can be useful for getting an instance of the publishing bundle's
context, when needed to load dependencies at run-time.@NotNull @NotNull java.util.Set<TypeProvider> getTypeProviders()
Set of TypeProviders which are related to this unit.TypeProvider@Nullable
<T> T getService(@NotNull
@NotNull java.lang.String className)
className parameter.T - the expected service typeclassName - the fully qualified class nameT or null@Nullable
<T> T[] getServices(@NotNull
@NotNull java.lang.String className,
@Nullable
@Nullable java.lang.String filter)
className
parameter, filtered according to the passed filter.T - the expected service typeclassName - the fully qualified class namefilter - a filter expression or null if all the instances should be returned; for more details about the filter's syntax check BundleContext.getServiceReferences(String, String)T or null@NotNull @NotNull java.lang.String getPath()
void eval(@NotNull
@NotNull javax.servlet.http.HttpServletRequest request,
@NotNull
@NotNull javax.servlet.http.HttpServletResponse response)
throws javax.script.ScriptException
request - the requestresponse - the responsejavax.script.ScriptException - if the execution leads to an error@Nullable default @Nullable java.io.InputStream getInputStream()
this unit is backed by a script that can be interpreted.InputStream providing the source code of the backing script; if this unit is backed by a precompiled
script (essentially a Java class), then this method will return nullCopyright © 2022 The Apache Software Foundation. All rights reserved.