Package ortus.boxlang.runtime.context
Class BaseBoxContext
java.lang.Object
ortus.boxlang.runtime.context.BaseBoxContext
- All Implemented Interfaces:
Serializable,IBoxContext,IBoxAttachable
- Direct Known Subclasses:
ApplicationBoxContext,ClassBoxContext,ContainerBoxContext,CustomTagBoxContext,FunctionBoxContext,InterfaceBoxContext,ParentPassthroughBoxContext,RequestBoxContext,RuntimeBoxContext,SessionBoxContext,StaticClassBoxContext,ThreadBoxContext
This context represents the context of ANYTHING that can execute in BoxLang
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ortus.boxlang.runtime.context.IBoxContext
IBoxContext.ScopeSearchResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ArrayDeque<StringBuffer> A buffer to write output toprotected ArrayDeque<IStruct> A way to discover the current executing componenetprotected List<ImportDefinition> A way to discover the imports tied to the original source of the current template.static booleanA flag to control whether null is considered undefined or not.protected IBoxContextAny context can have a parent it can delegate toprotected LinkedHashMap<Query, Integer> A way to track query loopsprotected ArrayDeque<ResolvedFilePath> A way to discover the current executing template. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new execution context with no execution templateBaseBoxContext(IBoxContext parent) Creates a new execution context with a bounded execution template and parent context -
Method Summary
Modifier and TypeMethodDescriptionCan the current context output to the response stream? Contexts tied to a specific object like a function or class may override this to return false based on their own logic.Clear the buffervoidContexts can optionallky cache their config.<T> TcomputeAttachmentIfAbsent(Key key, Function<? super Key, ? extends T> mappingFunction) Comput an attachment if it is not already present.Finds the base (first) template in this requestprotected BIFDescriptorFind out if the given function name is a BIF in the Function ServicefindClosestComponent(Key name) Gets the execution state for the closest component.findClosestComponent(Key name, int offset) Gets the execution state for the closest component.findClosestComponent(Key name, int offset, Predicate<IStruct> predicate) Gets the execution state for the closest component with a predicate to filter.findClosestComponent(Key name, Predicate<IStruct> predicate) Gets the execution state for the closest component with a predicate to filter.Finds the closest function call nameFinds the closest templateprotected FunctionfindFunction(Key name) Find a function in the corrent context.flushBuffer(boolean force) Flush the buffer to the output stream and then clears the local buffersSerach for an ancestor context of ApplicationBoxContext This is a convenience method for getParentOfType( ApplicationBoxContext.class ) since it is so common<T> TgetAttachment(Key key) Get the attachment for the given key.Key[]Get the keys of all attachments.Get the bufferIStruct[]Get the stack of components as an arrayGet the contexual config struct.getConfigItem(Key itemKey) Convenience method to retrieve a single config itemgetConfigItem(Key itemKey, Object defaultValue) Convenience method to retrieve a config item with with an optional defaultgetConfigItems(Key... itemKey) Convenience method to retrieve a config item(s).Retrieve all known imports for the current templateGet the default variable assignment scope for this contextGet the class, if any, for a function invocationGet the interface, if any, for a function invocationGet parent context for a function execution happening in this contextGet the class, if any, for a function invocationGet the context loggergetModuleRecord(Key name) Get a module recordgetModuleSettings(Key name) Get a struct of module settingsReturns the parent box context.<T> TgetParentOfType(Class<T> type) Serach for an ancestor context of the given typeintgetQueryRow(Query query) Get the current query rowSerach for an ancestor context of RequestBoxContext This is a convenience method for getParentOfType( RequestBoxContext.class ) since it is so commonGet the BoxLang runtime 'Get a scope from the context.getScopeNearby(Key name) Get a scope from the context.getScopeNearby(Key name, boolean shallow) Get a scope from the context.Get templatesThis is mostly for the debugger.getVisibleScopes(IStruct scopes, boolean nearby, boolean shallow) This is mostly for the debugger.booleanhasAttachment(Key key) Verify if an attachment is present for the given key.Verifies if a parent context is attached to this contextbooleanHas the execution context been bound to a template?voidincludeTemplate(String templatePath) Invoke a template in the current contextvoidincrementQueryLoop(Query query) Increment the query loopinjectParentContext(IBoxContext parentContext) Inject a parent context, moving the current parent to the grandparent Any existing parent in the passed context will be overwritten with the current parentinjectTopParentContext(IBoxContext parentContext) Inject a top parent context above the request-type context, moving the request context's current parent to its grandparentinvokeComponent(Key name, IStruct attributes, Component.ComponentBody componentBody) Invoke a component callinvokeFunction(Object function) Invoke a function expression such as (()=>{})() using no args.invokeFunction(Object function, Object[] positionalArguments) Invoke a function expression such as (()=>{})() using positional args.invokeFunction(Object function, Map<Key, Object> namedArguments) Invoke a function expression such as (()=>{})() using named args.invokeFunction(Key name) Invoke a function call such as foo() using no args.invokeFunction(Key name, Object[] positionalArguments) Invoke a function call such as foo() using positional args.invokeFunction(Key name, Map<Key, Object> namedArguments) Invoke a function call such as foo() using named args.invokeFunction(Function function, Key calledName, Object[] positionalArguments) Invoke a function expression such as (()=>{})() using named args.Invoke a function expression such as (()=>{})() using named args.booleanDecide if a value found in a scope is defined or notbooleanIs there at least one output component on the stackbooleanisKeyVisibleScope(Key key) Check if a key is visible in the current context as a scope name.booleanisKeyVisibleScope(Key key, boolean nearby, boolean shallow) Check if a key is visible in the current context as a scope name.navigateConfig(String... path) Get the contexual config as a DataNavigator.Pop a buffer from the stackPop a template from the stackPop a template from the stackpushBuffer(StringBuffer buffer) Push a buffer onto the stack.pushComponent(IStruct executionState) Push a Component to the stackpushTemplate(IBoxRunnable template) Push a template to the stackpushTemplate(ResolvedFilePath template) Push a template to the stack<T> TputAttachment(Key key, T value) -------------------------------------------------------------------------- Attachable Delegation --------------------------------------------------------------------------protected IBoxContext.ScopeSearchResultqueryFindNearby(Key key) Search any query loops for a column name matching the uncscoped variablevoidregisterQueryLoop(Query query, int row) Register a query loopvoidregisterUDF(UDF udf) Register a UDF with the local context.voidregisterUDF(UDF udf, boolean override) Register a UDF with the local context choosing to override.<T> TremoveAttachment(Key key) Remove an attachment, returning its previous value.removeParentContext(Class<? extends IBoxContext> type) Remove ancestor contexts of this typevoidrethrow()rethrows the closest exceptionTry to get the requested key from an unknown scope Meaning it needs to search scopes in order according to it's context.scopeFindNearby(Key key, IScope defaultScope, boolean forAssign) Try to get the requested key from an unkonwn scope but overriding the parent to check if not foundscopeFindNearby(Key key, IScope defaultScope, boolean shallow, boolean forAssign) Try to get the requested key from an unknown scope Meaning it needs to search scopes in order according to it's context.setParent(IBoxContext parentContext) Sets the parent box context.voidunregisterQueryLoop(Query query) Unregister a query loopunwrapQueryColumn(Object value) If input is a QueryColumn, unwrap it to the underlying value If input is not a QueryColumn, return it as-isWrite output to this buffer.writeToBuffer(Object o, boolean force) Write output to this buffer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ortus.boxlang.runtime.context.IBoxContext
getApplicationCache, getApplicationName, registerUDF, shutdown, startup
-
Field Details
-
nullIsUndefined
public static boolean nullIsUndefinedA flag to control whether null is considered undefined or not. Used by the compat module -
parent
Any context can have a parent it can delegate to -
templates
A way to discover the current executing template. We're storing the path directly instead of the ITemplateRunnable instance to avoid memory leaks by keepin Box Classes in memory since all we really need is static data from them -
currentImports
A way to discover the imports tied to the original source of the current template. This should always match the top current template stack -
components
A way to discover the current executing componenet -
queryLoops
A way to track query loops -
buffers
A buffer to write output to
-
-
Constructor Details
-
BaseBoxContext
Creates a new execution context with a bounded execution template and parent context- Parameters:
parent- The parent context
-
BaseBoxContext
public BaseBoxContext()Creates a new execution context with no execution template
-
-
Method Details
-
getLogger
Get the context logger -
pushTemplate
Push a template to the stack- Specified by:
pushTemplatein interfaceIBoxContext- Parameters:
template- The template that this execution context is bound to- Returns:
- IBoxContext
-
pushTemplate
Push a template to the stack- Specified by:
pushTemplatein interfaceIBoxContext- Parameters:
template- The template that this execution context is bound to- Returns:
- IBoxContext
-
popTemplate
Pop a template from the stack- Specified by:
popTemplatein interfaceIBoxContext- Returns:
- The template that this execution context is bound to
-
getTemplates
Get templates- Specified by:
getTemplatesin interfaceIBoxContext- Returns:
- The templates
-
pushComponent
Push a Component to the stack- Specified by:
pushComponentin interfaceIBoxContext- Parameters:
executionState- The state for this component execution- Returns:
- This context
-
popComponent
Pop a template from the stack- Specified by:
popComponentin interfaceIBoxContext- Returns:
- This context
-
isInOutputComponent
public boolean isInOutputComponent()Is there at least one output component on the stack- Specified by:
isInOutputComponentin interfaceIBoxContext- Returns:
- True if there is at least one output component, else false
-
findClosestComponent
Gets the execution state for the closest component.- Specified by:
findClosestComponentin interfaceIBoxContext- Returns:
- The execution state for the closest component, null if none was found
-
findClosestComponent
Gets the execution state for the closest component.- Specified by:
findClosestComponentin interfaceIBoxContext- Returns:
- The execution state for the closest component, null if none was found
-
findClosestComponent
Gets the execution state for the closest component with a predicate to filter.- Specified by:
findClosestComponentin interfaceIBoxContext- Returns:
- The execution state for the closest component, null if none was found
-
findClosestComponent
Gets the execution state for the closest component with a predicate to filter.- Specified by:
findClosestComponentin interfaceIBoxContext- Returns:
- The execution state for the closest component, null if none was found
-
getComponents
Get the stack of components as an array- Specified by:
getComponentsin interfaceIBoxContext- Returns:
- This context
-
hasTemplates
public boolean hasTemplates()Has the execution context been bound to a template?- Specified by:
hasTemplatesin interfaceIBoxContext- Returns:
- True if bound, else false
-
findClosestTemplate
Finds the closest template- Specified by:
findClosestTemplatein interfaceIBoxContext- Returns:
- The template instance if found, null if this code is not called from a template
-
findBaseTemplate
Finds the base (first) template in this request- Specified by:
findBaseTemplatein interfaceIBoxContext- Returns:
- The template instance if found, null if this code is not called from a template
-
rethrow
public void rethrow()rethrows the closest exception- Specified by:
rethrowin interfaceIBoxContext
-
getParent
Returns the parent box context. Null if none.- Specified by:
getParentin interfaceIBoxContext- Returns:
- The parent box context. Null if none.
-
setParent
Sets the parent box context.- Specified by:
setParentin interfaceIBoxContext- Parameters:
parentContext- The parent context to set- Returns:
- This context
-
injectParentContext
Inject a parent context, moving the current parent to the grandparent Any existing parent in the passed context will be overwritten with the current parent- Specified by:
injectParentContextin interfaceIBoxContext- Parameters:
parentContext- The parent context to inject- Returns:
- This context
-
injectTopParentContext
Inject a top parent context above the request-type context, moving the request context's current parent to its grandparent- Specified by:
injectTopParentContextin interfaceIBoxContext- Parameters:
parentContext- The parent context to inject- Returns:
- This context
-
removeParentContext
Remove ancestor contexts of this type- Specified by:
removeParentContextin interfaceIBoxContext- Parameters:
type- The type of context to remove- Returns:
- This context
-
hasParent
Verifies if a parent context is attached to this context- Specified by:
hasParentin interfaceIBoxContext- Returns:
- True if a parent context is attached to this context, else false
-
invokeFunction
Invoke a function call such as foo() using positional args. Will check for a registered BIF first, then search known scopes for a UDF.- Specified by:
invokeFunctionin interfaceIBoxContext- Returns:
- Return value of the function call
-
invokeFunction
Invoke a function call such as foo() using named args. Will check for a registered BIF first, then search known scopes for a UDF.- Specified by:
invokeFunctionin interfaceIBoxContext- Returns:
- Return value of the function call
-
invokeFunction
Invoke a function call such as foo() using no args.- Specified by:
invokeFunctionin interfaceIBoxContext- Returns:
- Return value of the function call
-
invokeComponent
public Component.BodyResult invokeComponent(Key name, IStruct attributes, Component.ComponentBody componentBody) Invoke a component call- Specified by:
invokeComponentin interfaceIBoxContext- Parameters:
name- The name of the component to invokeattributes- The attributes to pass to the componentcomponentBody- The body of the component
-
invokeFunction
Invoke a function expression such as (()=>{})() using positional args. This method will validate the incoming object is a function type.- Specified by:
invokeFunctionin interfaceIBoxContext- Returns:
- Return value of the function call
-
findBIF
Find out if the given function name is a BIF in the Function Service- Parameters:
name- The name of the function to find- Returns:
- The BIFDescriptor if found, else null
-
invokeFunction
Invoke a function expression such as (()=>{})() using named args. This method will validate the incoming object is a function type.- Specified by:
invokeFunctionin interfaceIBoxContext- Returns:
- Return value of the function call
-
invokeFunction
Invoke a function expression such as (()=>{})() using no args. This method will validate the incoming object is a function type.- Specified by:
invokeFunctionin interfaceIBoxContext- Returns:
- Return value of the function call
-
invokeFunction
Invoke a function expression such as (()=>{})() using named args.- Returns:
- Return value of the function call
-
invokeFunction
Invoke a function expression such as (()=>{})() using named args.- Returns:
- Return value of the function call
-
findFunction
Find a function in the corrent context. Will search known scopes for a UDF.- Parameters:
name- The name of the function to find- Returns:
- The function instance
-
includeTemplate
Invoke a template in the current context- Specified by:
includeTemplatein interfaceIBoxContext- Parameters:
templatePath- A relateive template path
-
getVisibleScopes
This is mostly for the debugger. It returns all visible scopes from this context.- Specified by:
getVisibleScopesin interfaceIBoxContext- Returns:
- A struct containing all contextual and lexically visible scopes
-
getVisibleScopes
This is mostly for the debugger. It returns all visible scopes from this context.- Specified by:
getVisibleScopesin interfaceIBoxContext- Returns:
- A struct containing all contextual and lexically visible scopes
-
isKeyVisibleScope
Check if a key is visible in the current context as a scope name. This allows us to "reserve" known scope names to ensure arguments.foo will always look in the proper arguments scope and never in local.arguments.foo for example- Specified by:
isKeyVisibleScopein interfaceIBoxContext- Parameters:
key- The key to check for visibility- Returns:
- True if the key is visible in the current context, else false
-
isKeyVisibleScope
Check if a key is visible in the current context as a scope name. This allows us to "reserve" known scope names to ensure arguments.foo will always look in the proper arguments scope and never in local.arguments.foo for example- Specified by:
isKeyVisibleScopein interfaceIBoxContext- Parameters:
key- The key to check for visibilitynearby- true, check only scopes that are nearby to the current execution contextshallow- true, do not delegate to parent or default scope if not found- Returns:
- True if the key is visible in the current context, else false
-
getScope
Get a scope from the context. If not found, the parent context is asked. Don't search for scopes which are nearby to an execution context- Specified by:
getScopein interfaceIBoxContext- Parameters:
name- The name of the scope to get- Returns:
- The requested scope
- Throws:
ScopeNotFoundException- If the scope was not found in any context
-
getScopeNearby
Get a scope from the context. If not found, the parent context is asked. Search all known scopes- Specified by:
getScopeNearbyin interfaceIBoxContext- Parameters:
name- The name of the scope to getshallow- true, do not delegate to parent or default scope if not found- Returns:
- The requested scope
- Throws:
ScopeNotFoundException- If the scope was not found in any context
-
scopeFind
Try to get the requested key from an unknown scope Meaning it needs to search scopes in order according to it's context. Unlike scopeFindNearby(), this version only searches trancedent scopes like cgi or server which are never encapsulated like variables is inside a class. If defaultScope is null and the key can't be found, a KeyNotFoundException will be thrown If defaultScope is not null, it will return a record with the default scope and null value if the key is not found- Specified by:
scopeFindin interfaceIBoxContext- Parameters:
key- The key to search fordefaultScope- The default scope to return if the key is not foundforAssign- true, this is for an assignment operation- Returns:
- The value of the key if found
-
scopeFindNearby
public IBoxContext.ScopeSearchResult scopeFindNearby(Key key, IScope defaultScope, boolean shallow, boolean forAssign) Try to get the requested key from an unknown scope Meaning it needs to search scopes in order according to it's context. A nearby lookup is used for the closest context to the executing code If defaultScope is null and the key can't be found, a KeyNotFoundException will be thrown If defaultScope is not null, it will return a record with the default scope and null value if the key is not found- Specified by:
scopeFindNearbyin interfaceIBoxContext- Parameters:
key- The key to search fordefaultScope- The default scope to return if the key is not foundshallow- true, do not delegate to parent or default scope if not foundforAssign- true, this is for an assignment operation- Returns:
- The value of the key if found
-
isDefined
Decide if a value found in a scope is defined or not- Specified by:
isDefinedin interfaceIBoxContext- Parameters:
value- The value to check, possibly null, possibly an instance of NullValue- Returns:
- True if the value is defined, else false
-
queryFindNearby
Search any query loops for a column name matching the uncscoped variable- Parameters:
key- The key to search for- Returns:
- A ScopeSearchResult if found, else null
-
registerUDF
Register a UDF with the local context. Will override any existing methods- Specified by:
registerUDFin interfaceIBoxContext- Parameters:
udf- The UDF to register
-
registerUDF
Register a UDF with the local context choosing to override.- Specified by:
registerUDFin interfaceIBoxContext- Parameters:
udf- The UDF to registeroverride- true, override any existing UDF with the same name
-
getDefaultAssignmentScope
Get the default variable assignment scope for this context- Specified by:
getDefaultAssignmentScopein interfaceIBoxContext- Returns:
- The scope reference to use
-
findClosestFunctionName
Finds the closest function call name- Specified by:
findClosestFunctionNamein interfaceIBoxContext- Returns:
- The called name of the function if found, null if this code is not called from a function
-
getFunctionParentContext
Get parent context for a function execution happening in this context- Specified by:
getFunctionParentContextin interfaceIBoxContext- Returns:
- The context to use
-
getFunctionClass
Get the class, if any, for a function invocation- Specified by:
getFunctionClassin interfaceIBoxContext- Returns:
- The class to use, or null if none
-
getFunctionStaticClass
Get the class, if any, for a function invocation- Specified by:
getFunctionStaticClassin interfaceIBoxContext- Returns:
- The class to use, or null if none
-
getFunctionInterface
Get the interface, if any, for a function invocation- Specified by:
getFunctionInterfacein interfaceIBoxContext- Returns:
- The interface to use, or null if none
-
scopeFindNearby
public IBoxContext.ScopeSearchResult scopeFindNearby(Key key, IScope defaultScope, boolean forAssign) Try to get the requested key from an unkonwn scope but overriding the parent to check if not found- Specified by:
scopeFindNearbyin interfaceIBoxContext- Parameters:
key- The key to search fordefaultScope- The default scope to return if the key is not foundforAssign- true, this is for an assignment operation- Returns:
- The value of the key if found
-
getScopeNearby
Get a scope from the context. If not found, the parent context is asked. Search all known scopes- Specified by:
getScopeNearbyin interfaceIBoxContext- Parameters:
name- The name of the scope to get- Returns:
- The requested scope
- Throws:
ScopeNotFoundException- If the scope was not found in any context
-
getCurrentImports
Retrieve all known imports for the current template- Specified by:
getCurrentImportsin interfaceIBoxContext- Returns:
- List of import definitions
-
unwrapQueryColumn
If input is a QueryColumn, unwrap it to the underlying value If input is not a QueryColumn, return it as-is- Specified by:
unwrapQueryColumnin interfaceIBoxContext- Parameters:
value- The value to unwrap- Returns:
- The unwrapped value
-
getQueryRow
Get the current query row- Specified by:
getQueryRowin interfaceIBoxContext- Parameters:
query- The query to get the row from- Returns:
- The current row
-
registerQueryLoop
Register a query loop- Specified by:
registerQueryLoopin interfaceIBoxContext- Parameters:
query- The query to registerrow- The row to start at
-
unregisterQueryLoop
Unregister a query loop- Specified by:
unregisterQueryLoopin interfaceIBoxContext- Parameters:
query- The query to unregister
-
incrementQueryLoop
Increment the query loop- Specified by:
incrementQueryLoopin interfaceIBoxContext- Parameters:
query- The query to increment
-
writeToBuffer
Write output to this buffer. Any input object will be converted to a string If force is true, write even if the setting component has been used with enableOutputOnly=true- Specified by:
writeToBufferin interfaceIBoxContext- Parameters:
o- The object to writeforce- true, write even if output is disabled- Returns:
- This context
-
writeToBuffer
Write output to this buffer. Any input object will be converted to a string- Specified by:
writeToBufferin interfaceIBoxContext- Parameters:
o- The object to write- Returns:
- This context
-
canOutput
Can the current context output to the response stream? Contexts tied to a specific object like a function or class may override this to return false based on their own logic.- Specified by:
canOutputin interfaceIBoxContext
-
flushBuffer
Flush the buffer to the output stream and then clears the local buffers- Specified by:
flushBufferin interfaceIBoxContext- Parameters:
force- true, flush even if output is disabled- Returns:
- This context
-
clearBuffer
Clear the buffer- Specified by:
clearBufferin interfaceIBoxContext- Returns:
- This context
-
getBuffer
Get the buffer- Specified by:
getBufferin interfaceIBoxContext- Returns:
- The buffer
-
pushBuffer
Push a buffer onto the stack. This is mostly so components can capture any output generated in their body- Specified by:
pushBufferin interfaceIBoxContext- Parameters:
buffer- The buffer to push- Returns:
- This context
-
popBuffer
Pop a buffer from the stack- Specified by:
popBufferin interfaceIBoxContext- Returns:
- This context
-
getConfig
Get the contexual config struct. Each context has a chance to add in config of their own to the struct, or override existing config with a new struct of their own design. It depends on whether the context wants its changes to exist for the rest of the entire request or only for code that executes in the current context and below.- Specified by:
getConfigin interfaceIBoxContext- Returns:
- A struct of configuration
-
clearConfigCache
public void clearConfigCache()Contexts can optionallky cache their config. If so, they must override this method to clear the cache when requested, and propagate the request to their parent context- Specified by:
clearConfigCachein interfaceIBoxContext
-
getConfigItem
Convenience method to retrieve a single config item- Specified by:
getConfigItemin interfaceIBoxContext- Parameters:
itemKey- the object key to retrieve- Returns:
- The object value of the key or null if not found
-
getConfigItems
Convenience method to retrieve a config item(s). You can pass in multiple keys separated by commas. It will traverse the keys in order and return the last key requested..// Example: // config = { a: { b: { c: 1 } } } * // getConfigItems( a, b, c ) will return 1- Specified by:
getConfigItemsin interfaceIBoxContext- Parameters:
itemKey- the object key(s)- Returns:
- The object value of the key or null if not found
-
getConfigItem
Convenience method to retrieve a config item with with an optional default- Specified by:
getConfigItemin interfaceIBoxContext- Parameters:
itemKey- the object keydefaultValue- a default value to return- Returns:
- The object value of the key or the default value if not found
-
getRuntime
Get the BoxLang runtime '- Specified by:
getRuntimein interfaceIBoxContext- Returns:
- The runtime
-
getModuleSettings
Get a struct of module settings- Specified by:
getModuleSettingsin interfaceIBoxContext- Parameters:
name- The name of the module- Returns:
- The module settings struct
- Throws:
BoxRuntimeException- If the module was not found
-
getModuleRecord
Get a module record- Specified by:
getModuleRecordin interfaceIBoxContext- Parameters:
name- The name of the module- Returns:
- The module record
- Throws:
BoxRuntimeException- If the module was not found
-
getParentOfType
Serach for an ancestor context of the given type- Specified by:
getParentOfTypein interfaceIBoxContext- Type Parameters:
T- The type of context to search for- Returns:
- The matching parent context, or null if one is not found of this type.
-
getRequestContext
Serach for an ancestor context of RequestBoxContext This is a convenience method for getParentOfType( RequestBoxContext.class ) since it is so common- Specified by:
getRequestContextin interfaceIBoxContext- Returns:
- The matching parent RequestBoxContext, or null if one is not found of this type.
-
getApplicationContext
Serach for an ancestor context of ApplicationBoxContext This is a convenience method for getParentOfType( ApplicationBoxContext.class ) since it is so common- Specified by:
getApplicationContextin interfaceIBoxContext- Returns:
- The matching parent ApplicationBoxContext, or null if one is not found of this type.
-
putAttachment
-------------------------------------------------------------------------- Attachable Delegation --------------------------------------------------------------------------- Specified by:
putAttachmentin interfaceIBoxAttachable- Type Parameters:
T- The type of the value to attach.- Parameters:
key- The key to attach the value to.
-
getAttachment
Description copied from interface:IBoxAttachableGet the attachment for the given key.- Specified by:
getAttachmentin interfaceIBoxAttachable- Parameters:
key- The key to get the attachment for.- Returns:
- The attachment for the given key, or null if there is none.
-
hasAttachment
Description copied from interface:IBoxAttachableVerify if an attachment is present for the given key.- Specified by:
hasAttachmentin interfaceIBoxAttachable- Parameters:
key-- Returns:
- true if an attachment is present for the given key, false otherwise.
-
removeAttachment
Description copied from interface:IBoxAttachableRemove an attachment, returning its previous value.- Specified by:
removeAttachmentin interfaceIBoxAttachable- Parameters:
key- The key to remove the attachment for.- Returns:
- The previous value attached to the key, or null if there was none.
-
getAttachmentKeys
Description copied from interface:IBoxAttachableGet the keys of all attachments.- Specified by:
getAttachmentKeysin interfaceIBoxAttachable
-
computeAttachmentIfAbsent
Description copied from interface:IBoxAttachableComput an attachment if it is not already present. If an attachment for this key was already set, return the original value.- Specified by:
computeAttachmentIfAbsentin interfaceIBoxAttachable- Parameters:
key- The key to attach the value to.mappingFunction- The function to compute the value to attach.
-