Class ScriptingRequestBoxContext

All Implemented Interfaces:
Serializable, IBoxContext, IJDBCCapableContext, IBoxAttachable
Direct Known Subclasses:
JSRScriptingRequestBoxContext

public class ScriptingRequestBoxContext extends RequestBoxContext
This context represents the context of a scripting execution in BoxLang There a variables and request scope present. The request scope may or may not belong here, but we're sort of using the scripting context as the top level context for an execution request right now, so it make the most sense here currently. There may or may NOT be a template defined.
See Also:
  • Field Details

    • variablesScope

      protected IScope variablesScope
      The variables scope
    • requestScope

      protected IScope requestScope
      The request scope
  • Constructor Details

    • ScriptingRequestBoxContext

      public ScriptingRequestBoxContext(IBoxContext parent)
      Creates a new execution context with a parent context
      Parameters:
      parent - The parent context
    • ScriptingRequestBoxContext

      public ScriptingRequestBoxContext(IBoxContext parent, BaseApplicationListener listener)
      Creates a new execution context with a parent context and a specific application listener.
      Parameters:
      parent - The parent context
      listener - The application listener
    • ScriptingRequestBoxContext

      public ScriptingRequestBoxContext(IBoxContext parent, URI template)
      Creates a new execution context with a parent context, and template
      Parameters:
      parent - The parent context
    • ScriptingRequestBoxContext

      public ScriptingRequestBoxContext(URI template)
      Creates a new execution context with a template
      Parameters:
      template - The template to use
    • ScriptingRequestBoxContext

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

    • getSessionID

      public Key getSessionID()
      Get the session ID for this request
      Specified by:
      getSessionID in class RequestBoxContext
      Returns:
      The session ID
    • resetSession

      public void resetSession()
      Invalidate a session
      Specified by:
      resetSession in class RequestBoxContext
    • setSessionID

      public void setSessionID(Key sessionID)
      The session ID can be set externally
      Parameters:
      sessionID - The session ID
    • getVisibleScopes

      public IStruct getVisibleScopes(IStruct scopes, boolean nearby, boolean shallow)
      Get the visible scopes for this context
      Specified by:
      getVisibleScopes in interface IBoxContext
      Overrides:
      getVisibleScopes in class RequestBoxContext
      Parameters:
      scopes - The scopes to add to
      nearby - If nearby scopes should be included
      shallow - If only the top level scopes should be included
      Returns:
      The 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 RequestBoxContext
      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)
      Try to get the requested key from the unscoped scope Meaning it needs to search scopes in order according to it's context. A local lookup is used for the closest context to the executing code
      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 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.
      Specified by:
      scopeFind in interface IBoxContext
      Overrides:
      scopeFind in class RequestBoxContext
      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
    • flushBuffer

      public IBoxContext flushBuffer(boolean force)
      Flush the buffer to the output stream
      Specified by:
      flushBuffer in interface IBoxContext
      Overrides:
      flushBuffer in class BaseBoxContext
      Parameters:
      force - true, flush even if output is disabled
      Returns:
      This context