Class ThreadComponentBoxContext

java.lang.Object
ortus.boxlang.runtime.context.BaseBoxContext
ortus.boxlang.runtime.context.ThreadComponentBoxContext
All Implemented Interfaces:
Serializable, IBoxContext, IJDBCCapableContext, IBoxAttachable

public class ThreadComponentBoxContext extends BaseBoxContext implements IJDBCCapableContext
This context represents a thread started by the bx:thread component.
See Also:
  • Field Details

    • localScope

      protected IScope localScope
      The thread local scope
    • attributesScope

      protected IScope attributesScope
      The thread attributes scope
    • variablesScope

      protected IScope variablesScope
      The parent's variables scope
    • thread

      protected Thread thread
      The Thread
    • threadName

      protected Key threadName
      The BoxLang name of the thread as registered in the thread manager.
  • Constructor Details

    • ThreadComponentBoxContext

      public ThreadComponentBoxContext(IBoxContext parent, RequestThreadManager threadManager, Key threadName, IStruct attributes)
      Creates a new execution context with a bounded function instance and parent context
      Parameters:
      parent - The parent context
      threadManager - The thread manager
      threadName - The name of the thread
  • Method Details

    • setThread

      public ThreadComponentBoxContext setThread(Thread thread)
      Set the thread
      Returns:
      THis context
    • getVisibleScopes

      public IStruct getVisibleScopes(IStruct scopes, boolean nearby, boolean shallow)
      Description copied from class: BaseBoxContext
      This is mostly for the debugger. It returns all visible scopes from this context.
      Specified by:
      getVisibleScopes in interface IBoxContext
      Overrides:
      getVisibleScopes in class BaseBoxContext
      Returns:
      A struct containing all contextual and lexically visible scopes
    • isKeyVisibleScope

      public boolean isKeyVisibleScope(Key key, boolean nearby, boolean shallow)
      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:
      isKeyVisibleScope in interface IBoxContext
      Overrides:
      isKeyVisibleScope in class BaseBoxContext
      Parameters:
      key - The key to check for visibility
      nearby - true, check only scopes that are nearby to the current execution context
      shallow - 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
    • scopeFindNearby

      public IBoxContext.ScopeSearchResult scopeFindNearby(Key key, IScope defaultScope, boolean shallow, boolean forAssign)
      Search for a variable in "nearby" scopes
      Specified by:
      scopeFindNearby in interface IBoxContext
      Overrides:
      scopeFindNearby in class BaseBoxContext
      Parameters:
      key - The key to search for
      defaultScope - The default scope to use if the key is not found
      shallow - Whether to search only the "nearby" scopes or all scopes
      forAssign - true, this is for an assignment operation
      Returns:
      The search result
    • scopeFind

      public IBoxContext.ScopeSearchResult scopeFind(Key key, IScope defaultScope, boolean forAssign)
      Search for a variable in scopes
      Specified by:
      scopeFind in interface IBoxContext
      Overrides:
      scopeFind in class BaseBoxContext
      Parameters:
      key - The key to search for
      defaultScope - The default scope to use if the key is not found
      forAssign - true, this is for an assignment operation
      Returns:
      The search result
    • getScope

      public IScope getScope(Key name) throws ScopeNotFoundException
      Look for a scope by name
      Specified by:
      getScope in interface IBoxContext
      Overrides:
      getScope in class BaseBoxContext
      Parameters:
      name - The name of the scope to look for
      Returns:
      The scope reference to use
      Throws:
      ScopeNotFoundException - If the scope was not found in any context
    • getScopeNearby

      public IScope getScopeNearby(Key name, boolean shallow) throws ScopeNotFoundException
      Look for a "nearby" scope by name
      Specified by:
      getScopeNearby in interface IBoxContext
      Overrides:
      getScopeNearby in class BaseBoxContext
      Parameters:
      name - The name of the scope to look for
      shallow - true, do not delegate to parent or default scope if not found
      Returns:
      The scope reference to use
      Throws:
      ScopeNotFoundException - If the scope was not found in any context
    • getDefaultAssignmentScope

      public IScope getDefaultAssignmentScope()
      Get the default variable assignment scope for this context
      Specified by:
      getDefaultAssignmentScope in interface IBoxContext
      Overrides:
      getDefaultAssignmentScope in class BaseBoxContext
      Returns:
      The scope reference to use
    • registerUDF

      public void registerUDF(UDF udf, boolean override)
      Description copied from class: BaseBoxContext
      Register a UDF with the local context choosing to override.
      Specified by:
      registerUDF in interface IBoxContext
      Overrides:
      registerUDF in class BaseBoxContext
      Parameters:
      udf - The UDF to register
      override - true, override any existing UDF with the same name
    • getThread

      public Thread getThread()
      Get the thread
      Returns:
      The thread
    • getConnectionManager

      public ConnectionManager getConnectionManager()
      Get the ConnectionManager, which is the central point for managing database connections and transactions.
      Specified by:
      getConnectionManager in interface IJDBCCapableContext
    • shutdownConnections

      public void shutdownConnections()
      Shutdown the ConnectionManager and release any resources.
      Specified by:
      shutdownConnections in interface IJDBCCapableContext
    • shutdown

      public void shutdown()
      Description copied from interface: IBoxContext
      This is an optional method on contexts which require shutdown outside of its constructor
      Specified by:
      shutdown in interface IBoxContext