Class Component

java.lang.Object
ortus.boxlang.runtime.components.Component
Direct Known Subclasses:
Abort, Application, Associate, BoxLangComponentProxy, Cache, Component, DBInfo, Directory, Dump, Execute, Exit, File, Flush, HTTP, HTTPParam, Include, Invoke, InvokeArgument, Lock, Log, Loop, ObjectComponent, Output, Param, ProcessingDirective, ProcParam, ProcResult, Query, QueryParam, SaveContent, Setting, Silent, Sleep, StoredProc, Thread, Throw, Timer, Trace, Transaction, XML, Zip

public abstract class Component extends Object
Base class for all Components. Components are invoked by the runtime from a template or script.
  • Field Details

    • DEFAULT_RETURN

      public static final Component.BodyResult DEFAULT_RETURN
      The default return value for a component, which is BodyResult.ofDefault()
    • name

      protected Key name
      The name of the component
    • declaredAttributes

      protected Attribute[] declaredAttributes
      Component Attributes
    • runtime

      protected BoxRuntime runtime
      The runtime instance
    • componentService

      protected ComponentService componentService
      The component service helper
    • functionService

      protected FunctionService functionService
      The function service helper
    • interceptorService

      protected InterceptorService interceptorService
      The interceptor service helper
    • logger

      protected BoxLangLogger logger
      Runtime Logger
  • Constructor Details

    • Component

      protected Component()
      A base component
  • Method Details

    • setName

      public Component setName(Key name)
      Set name
      Parameters:
      name - The name of the component
      Returns:
      this
    • invoke

      public Component.BodyResult invoke(IBoxContext context, IStruct attributes, Component.ComponentBody body)
      Invoke the Component with the given arguments. This is a wrapper method that sets up the execution.
      Parameters:
      context - The context in which the Component is being invoked
      attributes - The attributes to the Component
      body - The body of the Component
      Returns:
      The result of the invocation
    • _invoke

      public abstract Component.BodyResult _invoke(IBoxContext context, IStruct attributes, Component.ComponentBody body, IStruct executionState)
      Invoke the Component with the given arguments. This is the actual method that must be implemented by the component.
      Parameters:
      context - The context in which the Component is being invoked
      attributes - The attributes to the Component
      body - The body of the Component
      executionState - The execution state of the Component
      Returns:
      The result of the invocation
    • announce

      public void announce(Key state, IStruct data)
      Announce an event with the provided IStruct of data.
      Parameters:
      state - The state key to announce
      data - The data to announce
    • validateAttributes

      public void validateAttributes(IBoxContext context, IStruct attributes)
      Validate the attributes for the component. This method is called before the component is invoked.
      Parameters:
      context - The context in which the Component is being invoked
      attributes - The attributes to the Component
    • processBody

      public Component.BodyResult processBody(IBoxContext context, Component.ComponentBody body)
      Process the body of the component and not do capture output.
      Parameters:
      context - The context in which the body is being processed
      body - The body to process
      Returns:
      A BodyResult object which describes the result of the body processing
    • processBody

      public Component.BodyResult processBody(IBoxContext context, Component.ComponentBody body, StringBuffer buffer)
      Process the body of the component while capturing the output into a provided buffer.
      Parameters:
      context - The context in which the body is being processed
      body - The body to process
      buffer - The buffer to capture the output into
      Returns:
      A BodyResult object which describes the result of the body processing
    • getName

      public Key getName()
      Get the name of the component
      Returns:
      The name of the component
    • getDeclaredAttributes

      public Attribute[] getDeclaredAttributes()
      Get the attributes for this component
      Returns:
      The attributes for this component