Interface TemplateInstance

  • All Known Implementing Classes:
    TemplateInstanceBase

    public interface TemplateInstance
    Represents an instance of Template.

    This construct is not thread-safe.

    • Method Detail

      • data

        TemplateInstance data​(String key,
                              Object data)
        Put the data in a map. The map will be used as the root context object during rendering. Invocation of this method removes the root data object previously set by data(Object).
        Parameters:
        key -
        data -
        Returns:
        self
      • getAttribute

        Object getAttribute​(String key)
        Parameters:
        key -
        Returns:
        the attribute or null
      • render

        String render()
        Triggers rendering. Note that this method blocks the current thread!
        Returns:
        the rendered template as string
      • renderAsync

        CompletionStage<String> renderAsync()
        Triggers rendering.
        Returns:
        a completion stage that is completed once the rendering finished
      • createMulti

        io.smallrye.mutiny.Multi<String> createMulti()
        Create a new Multi that can be used to consume chunks of the rendered template. In particular, each item represents a part of the rendered template.

        This operation does not trigger rendering. Instead, each subscription triggers a new rendering of the template.

        Returns:
        a new Multi
        See Also:
        Multi.subscribe()
      • createUni

        io.smallrye.mutiny.Uni<String> createUni()
        Create a new Uni that can be used to consume the rendered template.

        This operation does not trigger rendering. Instead, each subscription triggers a new rendering of the template.

        Returns:
        a new Uni
        See Also:
        Uni.subscribe()
      • consume

        CompletionStage<Void> consume​(Consumer<String> consumer)
        Triggers rendering.
        Parameters:
        consumer - To consume chunks of the rendered template
        Returns:
        a completion stage that is completed once the rendering finished
      • getTimeout

        long getTimeout()
        Returns:
        the timeout
        See Also:
        TIMEOUT
      • getTemplate

        Template getTemplate()
        Returns:
        the original template
      • onRendered

        TemplateInstance onRendered​(Runnable action)
        Register an action that is performed after the rendering is finished.
        Parameters:
        action -
        Returns:
        self