Package ortus.boxlang.runtime.components
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
Base class for all Components. Components are invoked by the runtime from a template or script.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe result of a body processingstatic interfaceA functional interface for the body of a component which can be a lambda -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ComponentServiceThe component service helperprotected Attribute[]Component Attributesstatic final Component.BodyResultThe default return value for a component, which is BodyResult.ofDefault()protected FunctionServiceThe function service helperprotected InterceptorServiceThe interceptor service helperprotected BoxLangLoggerRuntime Loggerprotected KeyThe name of the componentprotected BoxRuntimeThe runtime instance -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Component.BodyResult_invoke(IBoxContext context, IStruct attributes, Component.ComponentBody body, IStruct executionState) Invoke the Component with the given arguments.voidAnnounce an event with the providedIStructof data.Get the attributes for this componentgetName()Get the name of the componentinvoke(IBoxContext context, IStruct attributes, Component.ComponentBody body) Invoke the Component with the given arguments.processBody(IBoxContext context, Component.ComponentBody body) Process the body of the component and not do capture output.processBody(IBoxContext context, Component.ComponentBody body, StringBuffer buffer) Process the body of the component while capturing the output into a provided buffer.Set namevoidvalidateAttributes(IBoxContext context, IStruct attributes) Validate the attributes for the component.
-
Field Details
-
DEFAULT_RETURN
The default return value for a component, which is BodyResult.ofDefault() -
name
The name of the component -
declaredAttributes
Component Attributes -
runtime
The runtime instance -
componentService
The component service helper -
functionService
The function service helper -
interceptorService
The interceptor service helper -
logger
Runtime Logger
-
-
Constructor Details
-
Component
protected Component()A base component
-
-
Method Details
-
setName
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 invokedattributes- The attributes to the Componentbody- 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 invokedattributes- The attributes to the Componentbody- The body of the ComponentexecutionState- The execution state of the Component- Returns:
- The result of the invocation
-
announce
Announce an event with the providedIStructof data.- Parameters:
state- The state key to announcedata- The data to announce
-
validateAttributes
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 invokedattributes- The attributes to the Component
-
processBody
Process the body of the component and not do capture output.- Parameters:
context- The context in which the body is being processedbody- 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 processedbody- The body to processbuffer- The buffer to capture the output into- Returns:
- A BodyResult object which describes the result of the body processing
-
getName
Get the name of the component- Returns:
- The name of the component
-
getDeclaredAttributes
Get the attributes for this component- Returns:
- The attributes for this component
-