Class BundledUnitManagerImpl

  • All Implemented Interfaces:
    BundledUnitManager

    public class BundledUnitManagerImpl
    extends Object
    implements BundledUnitManager
    This service allows various components to work with BundledRenderUnit instance and perform dependency resolution based on their availability in the Bindings maps passed to the HTL Script Engine.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @Nullable ClassLoader getBundledRenderUnitClassloader​(Bindings bindings)
      Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and if the object provided by BundledRenderUnit.getUnit() is an instance of a RenderUnit.
      @Nullable org.apache.sling.scripting.sightly.render.RenderUnit getRenderUnit​(@NotNull Bindings bindings)
      Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and return the object provided by BundledRenderUnit.getUnit() if this is an instance of a RenderUnit.
      @Nullable org.apache.sling.scripting.sightly.render.RenderUnit getRenderUnit​(@NotNull Bindings bindings, @NotNull String identifier)
      Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and if the object provided by BundledRenderUnit.getUnit() is an instance of a RenderUnit.
      @Nullable URL getScript​(Bindings bindings, String identifier)
      Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and, if a BundledRenderUnit is found, attempt to return the URL of dependency that the BundledRenderUnit needs to load.
      <T> T getServiceForBundledRenderUnit​(Bindings bindings, Class<T> clazz)
      Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and if the object provided by BundledRenderUnit.getUnit() is an instance of a RenderUnit.
    • Constructor Detail

      • BundledUnitManagerImpl

        public BundledUnitManagerImpl()
    • Method Detail

      • getRenderUnit

        @Nullable
        public @Nullable org.apache.sling.scripting.sightly.render.RenderUnit getRenderUnit​(@NotNull
                                                                                            @NotNull Bindings bindings)
        Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and return the object provided by BundledRenderUnit.getUnit() if this is an instance of a RenderUnit.
        Parameters:
        bindings - the bindings passed initially to the HTL Script Engine
        Returns:
        a RenderUnit if one is found, null otherwise
      • getRenderUnit

        @Nullable
        public @Nullable org.apache.sling.scripting.sightly.render.RenderUnit getRenderUnit​(@NotNull
                                                                                            @NotNull Bindings bindings,
                                                                                            @NotNull
                                                                                            @NotNull String identifier)

        Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and if the object provided by BundledRenderUnit.getUnit() is an instance of a RenderUnit. If so, this service will try to locate another RenderUnit based on the passed identifier and the coordinates of the RenderUnit found in the bindings map.

        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 Engine
        identifier - the identifier of the RenderUnit that has to be retrieved and returned
        Returns:
        a RenderUnit if one is found, null otherwise
      • getScript

        @Nullable
        public @Nullable URL getScript​(Bindings bindings,
                                       String identifier)
        Description copied from interface: BundledUnitManager
        Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and, if a BundledRenderUnit is found, attempt to return the URL of dependency that the BundledRenderUnit needs to load. This will take into account the bundle wirings of the unit's providing bundle (see BundledRenderUnit.getBundle()).
        Specified by:
        getScript in interface BundledUnitManager
        Parameters:
        bindings - the bindings passed initially to the HTL Script Engine
        identifier - the identifier of the dependency that a BundledRenderUnit from the Bindings needs to load
        Returns:
        the URL of the identifier dependency, if one was found
      • getBundledRenderUnitClassloader

        @Nullable
        public @Nullable ClassLoader getBundledRenderUnitClassloader​(Bindings bindings)

        Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and if the object provided by BundledRenderUnit.getUnit() is an instance of a RenderUnit. If so, this service will return the ClassLoader of the Bundle providing the BundledRenderUnit.

        Specified by:
        getBundledRenderUnitClassloader in interface BundledUnitManager
        Parameters:
        bindings - the bindings passed initially to the HTL Script Engine
        Returns:
        the BundledRenderUnit's classloader if one is found, null otherwise
      • getServiceForBundledRenderUnit

        @Nullable
        public <T> T getServiceForBundledRenderUnit​(Bindings bindings,
                                                    Class<T> clazz)

        Given a Bindings map, this method will check if the bindings contain a value for the BundledRenderUnit.VARIABLE property and if the object provided by BundledRenderUnit.getUnit() is an instance of a RenderUnit. If so, this service will try to get a reference to a service of type clazz and return the service object. The service will be retrieved using the bundle context of the BundledRenderUnit found in the bindings map.

        Type Parameters:
        T - the service type
        Parameters:
        bindings - the bindings passed initially to the HTL Script Engine
        clazz - the class identifying the type of the service
        Returns:
        a service object, if one is found, null otherwise