Class DefaultExecutionContext

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Repository repository
      The source of recipes and existing objects.
      private java.util.LinkedList<Recipe> stack
      Before each recipe is executed it is pushed on the stack.
      private java.util.SortedMap<java.lang.String,​java.util.List<Reference>> unresolvedRefs
      The unresolved references by name.
    • Method Summary

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

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

      • repository

        private Repository repository
        The source of recipes and existing objects.
      • stack

        private final java.util.LinkedList<Recipe> stack
        Before each recipe is executed it is pushed on the stack. The stack is used to detect circular dependencies and so a recipe can access the caller recipe (e.g. UnsetPropertiesRecipe returns a map of the caller's unset properties)
      • unresolvedRefs

        private final java.util.SortedMap<java.lang.String,​java.util.List<Reference>> unresolvedRefs
        The unresolved references by name.
    • Constructor Detail

      • DefaultExecutionContext

        public DefaultExecutionContext()
      • DefaultExecutionContext

        public DefaultExecutionContext​(Repository repository)
    • Method Detail

      • push

        public void push​(Recipe recipe)
        Description copied from class: ExecutionContext
        Adds a recipe to the top of the execution stack. If the recipe is already on the stack, a CircularDependencyException is thrown.
        Specified by:
        push in class ExecutionContext
        Parameters:
        recipe - the recipe to add to the stack
      • pop

        public Recipe pop()
        Description copied from class: ExecutionContext
        Removes the top recipe from the execution stack.
        Specified by:
        pop in class ExecutionContext
        Returns:
        the top recipe on the stack
      • getStack

        public java.util.LinkedList<Recipe> getStack()
        Description copied from class: ExecutionContext
        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.
        Specified by:
        getStack in class ExecutionContext
        Returns:
        a snapshot of the current execution stack
      • getRepository

        public Repository getRepository()
      • setRepository

        public void setRepository​(Repository repository)
      • containsObject

        public boolean containsObject​(java.lang.String name)
        Description copied from class: ExecutionContext
        Does this context contain a object with the specified name.
        Specified by:
        containsObject in class ExecutionContext
        Parameters:
        name - the unique name of the object instance
        Returns:
        true if this context contain a object with the specified name
      • getObject

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

        public void addObject​(java.lang.String name,
                              java.lang.Object object)
        Description copied from class: ExecutionContext
        Add an object to the repository.
        Specified by:
        addObject in class ExecutionContext
        Parameters:
        name - the unique name of the object instance
        object - the object instance
      • addReference

        public void addReference​(Reference reference)
        Description copied from class: ExecutionContext
        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.
        Specified by:
        addReference in class ExecutionContext
        Parameters:
        reference - the reference to set
      • getUnresolvedRefs

        public java.util.SortedMap<java.lang.String,​java.util.List<Reference>> getUnresolvedRefs()
        Description copied from class: ExecutionContext
        Gets the unresolved references by name.
        Specified by:
        getUnresolvedRefs in class ExecutionContext
        Returns:
        the unresolved references by name
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
        Description copied from class: ExecutionContext
        Gets the class loader used for loading of all classes during the life of this execution context
        Specified by:
        getClassLoader in class ExecutionContext
        Returns:
        the class loader for loading classes in this context