Class BundledUnitManagerImpl
- java.lang.Object
-
- org.apache.sling.scripting.sightly.impl.engine.bundled.BundledUnitManagerImpl
-
- All Implemented Interfaces:
BundledUnitManager
public class BundledUnitManagerImpl extends Object implements BundledUnitManager
This service allows various components to work withBundledRenderUnitinstance and perform dependency resolution based on their availability in theBindingsmaps passed to the HTL Script Engine.
-
-
Constructor Summary
Constructors Constructor Description BundledUnitManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable ClassLoadergetBundledRenderUnitClassloader(Bindings bindings)Given aBindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and if the object provided byBundledRenderUnit.getUnit()is an instance of aRenderUnit.@Nullable org.apache.sling.scripting.sightly.render.RenderUnitgetRenderUnit(@NotNull Bindings bindings)Given aBindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and return the object provided byBundledRenderUnit.getUnit()if this is an instance of aRenderUnit.@Nullable org.apache.sling.scripting.sightly.render.RenderUnitgetRenderUnit(@NotNull Bindings bindings, @NotNull String identifier)Given aBindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and if the object provided byBundledRenderUnit.getUnit()is an instance of aRenderUnit.@Nullable URLgetScript(Bindings bindings, String identifier)Given aBindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and, if aBundledRenderUnitis found, attempt to return the URL of dependency that theBundledRenderUnitneeds to load.<T> TgetServiceForBundledRenderUnit(Bindings bindings, Class<T> clazz)Given aBindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and if the object provided byBundledRenderUnit.getUnit()is an instance of aRenderUnit.
-
-
-
Method Detail
-
getRenderUnit
@Nullable public @Nullable org.apache.sling.scripting.sightly.render.RenderUnit getRenderUnit(@NotNull @NotNull Bindings bindings)Given aBindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and return the object provided byBundledRenderUnit.getUnit()if this is an instance of aRenderUnit.- Parameters:
bindings- the bindings passed initially to the HTL Script Engine- Returns:
- a
RenderUnitif one is found,nullotherwise
-
getRenderUnit
@Nullable public @Nullable org.apache.sling.scripting.sightly.render.RenderUnit getRenderUnit(@NotNull @NotNull Bindings bindings, @NotNull @NotNull String identifier)Given a
Bindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and if the object provided byBundledRenderUnit.getUnit()is an instance of aRenderUnit. If so, this service will try to locate anotherRenderUnitbased on the passedidentifierand the coordinates of theRenderUnitfound in thebindingsmap.This method is suited for finding template libraries (collections of templates provided by the same
RenderUnit).- Parameters:
bindings- the bindings passed initially to the HTL Script Engineidentifier- the identifier of theRenderUnitthat has to be retrieved and returned- Returns:
- a
RenderUnitif one is found,nullotherwise
-
getScript
@Nullable public @Nullable URL getScript(Bindings bindings, String identifier)
Description copied from interface:BundledUnitManagerGiven aBindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and, if aBundledRenderUnitis found, attempt to return the URL of dependency that theBundledRenderUnitneeds to load. This will take into account the bundle wirings of the unit's providing bundle (seeBundledRenderUnit.getBundle()).- Specified by:
getScriptin interfaceBundledUnitManager- Parameters:
bindings- the bindings passed initially to the HTL Script Engineidentifier- the identifier of the dependency that aBundledRenderUnitfrom theBindingsneeds to load- Returns:
- the URL of the
identifierdependency, if one was found
-
getBundledRenderUnitClassloader
@Nullable public @Nullable ClassLoader getBundledRenderUnitClassloader(Bindings bindings)
Given a
Bindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and if the object provided byBundledRenderUnit.getUnit()is an instance of aRenderUnit. If so, this service will return theClassLoaderof theBundleproviding theBundledRenderUnit.- Specified by:
getBundledRenderUnitClassloaderin interfaceBundledUnitManager- Parameters:
bindings- the bindings passed initially to the HTL Script Engine- Returns:
- the
BundledRenderUnit's classloader if one is found,nullotherwise
-
getServiceForBundledRenderUnit
@Nullable public <T> T getServiceForBundledRenderUnit(Bindings bindings, Class<T> clazz)
Given a
Bindingsmap, this method will check if thebindingscontain a value for theBundledRenderUnit.VARIABLEproperty and if the object provided byBundledRenderUnit.getUnit()is an instance of aRenderUnit. If so, this service will try to get a reference to a service of typeclazzand return the service object. The service will be retrieved using the bundle context of theBundledRenderUnitfound in thebindingsmap.- Type Parameters:
T- the service type- Parameters:
bindings- the bindings passed initially to the HTL Script Engineclazz- the class identifying the type of the service- Returns:
- a service object, if one is found,
nullotherwise
-
-