Class ExecutionContext

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.ThreadLocal<ExecutionContext> context  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void addObject​(java.lang.String name, java.lang.Object object)
      Add an object to the repository.
      abstract void addReference​(Reference reference)
      Adds a reference to an object to this context.
      abstract boolean containsObject​(java.lang.String name)
      Does this context contain a object with the specified name.
      abstract java.lang.ClassLoader getClassLoader()
      Gets the class loader used for loading of all classes during the life of this execution context
      static ExecutionContext getContext()  
      abstract java.lang.Object getObject​(java.lang.String name)
      Gets the object or recipe with the specified name from the repository.
      abstract java.util.LinkedList<Recipe> getStack()
      Gets a snapshot of the current execution stack.
      abstract java.util.Map<java.lang.String,​java.util.List<Reference>> getUnresolvedRefs()
      Gets the unresolved references by name.
      static boolean isContextSet()  
      abstract Recipe pop()
      Removes the top recipe from the execution stack.
      abstract void push​(Recipe recipe)
      Adds a recipe to the top of the execution stack.
      static ExecutionContext setContext​(ExecutionContext newContext)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Constructor Detail

      • ExecutionContext

        public ExecutionContext()
    • Method Detail

      • isContextSet

        public static boolean isContextSet()
      • push

        public abstract void push​(Recipe recipe)
                           throws CircularDependencyException
        Adds a recipe to the top of the execution stack. If the recipe is already on the stack, a CircularDependencyException is thrown.
        Parameters:
        recipe - the recipe to add to the stack
        Throws:
        CircularDependencyException - if the recipe is already on the stack
      • pop

        public abstract Recipe pop()
        Removes the top recipe from the execution stack.
        Returns:
        the top recipe on the stack
      • getStack

        public abstract java.util.LinkedList<Recipe> getStack()
        Gets a snapshot of the current execution stack. The returned list is a snapshot so any modification of the returned list does not modify the stack contained in this object.
        Returns:
        a snapshot of the current execution stack
      • containsObject

        public abstract boolean containsObject​(java.lang.String name)
        Does this context contain a object with the specified name.
        Parameters:
        name - the unique name of the object instance
        Returns:
        true if this context contain a object with the specified name
      • getObject

        public abstract java.lang.Object getObject​(java.lang.String name)
        Gets the object or recipe with the specified name from the repository.
        Parameters:
        name - the unique name of the object instance
        Returns:
        the object instance, a recipe to build the object or null
      • addObject

        public abstract void addObject​(java.lang.String name,
                                       java.lang.Object object)
        Add an object to the repository.
        Parameters:
        name - the unique name of the object instance
        object - the object instance
        Throws:
        ConstructionException - if another object instance is already registered with the name
      • addReference

        public abstract void addReference​(Reference reference)
        Adds a reference to an object to this context. If an object is already registered under the referenced name, the reference will immedately be set. Otherwise, the reference will be set when an object is added with the referenced name.
        Parameters:
        reference - the reference to set
      • getUnresolvedRefs

        public abstract java.util.Map<java.lang.String,​java.util.List<Reference>> getUnresolvedRefs()
        Gets the unresolved references by name.
        Returns:
        the unresolved references by name
      • getClassLoader

        public abstract java.lang.ClassLoader getClassLoader()
        Gets the class loader used for loading of all classes during the life of this execution context
        Returns:
        the class loader for loading classes in this context