Class RuntimeBoxContext

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

public class RuntimeBoxContext extends BaseBoxContext
This context represents the context of the entire BoxLang Runtime. The runtime is persistent once started, and can be used to process one or more "requests" for execution. The "server" scope here is global and will be shared by all requests.
See Also:
  • Field Details

    • serverScope

      protected IScope serverScope
      The variables scope
  • Constructor Details

    • RuntimeBoxContext

      public RuntimeBoxContext(IBoxContext parent)
      Creates a new execution context with a bounded execution template and parent context
      Parameters:
      parent - The parent context
    • RuntimeBoxContext

      public RuntimeBoxContext()
      Creates a new execution context
  • Method Details

    • startup

      public void startup()
      This is an optional method on contexts which require initialization outside of its constructor In this case we do, since we want modules to collaborate to the runtime context
    • getVisibleScopes

      public IStruct getVisibleScopes(IStruct scopes, boolean nearby, boolean shallow)
      -------------------------------------------------------------------------- Getters + Setters --------------------------------------------------------------------------
      Specified by:
      getVisibleScopes in interface IBoxContext
      Overrides:
      getVisibleScopes in class BaseBoxContext
      Returns:
      A struct containing all contextual and lexically visible scopes
    • scopeFindNearby

      public IBoxContext.ScopeSearchResult scopeFindNearby(Key key, IScope defaultScope, boolean shallow, boolean forAssign)
      Try to get the requested key from the unscoped scope
      Specified by:
      scopeFindNearby in interface IBoxContext
      Overrides:
      scopeFindNearby in class BaseBoxContext
      Parameters:
      key - The key to search for
      defaultScope - The default scope to return if the key is not found
      shallow - true, do not delegate to parent or default scope if not found
      forAssign - true, this is for an assignment operation
      Returns:
      The value of the key if found
    • scopeFind

      public IBoxContext.ScopeSearchResult scopeFind(Key key, IScope defaultScope, boolean forAssign)
      Try to get the requested key from the unscoped scope
      Specified by:
      scopeFind in interface IBoxContext
      Overrides:
      scopeFind in class BaseBoxContext
      Parameters:
      key - The key to search for
      defaultScope - The default scope to return if the key is not found
      forAssign - true, this is for an assignment operation
      Returns:
      The value of the key if found
    • getScope

      public IScope getScope(Key name) throws ScopeNotFoundException
      Get a scope from the context. If not found, the parent context is asked. Don't search for scopes which are local to an execution context
      Specified by:
      getScope in interface IBoxContext
      Overrides:
      getScope in class BaseBoxContext
      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

      public IScope getScopeNearby(Key name, boolean shallow) throws ScopeNotFoundException
      Get a scope from the context. If not found, the parent context is asked. Search all konwn scopes
      Specified by:
      getScopeNearby in interface IBoxContext
      Overrides:
      getScopeNearby in class BaseBoxContext
      Parameters:
      name - The name of the scope to get
      shallow - 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
    • 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
    • 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
    • getConfig

      public IStruct 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:
      getConfig in interface IBoxContext
      Overrides:
      getConfig in class BaseBoxContext
      Returns:
      A struct of configuration