org.apache.geronimo.blueprint.container
Class BlueprintRepository

java.lang.Object
  extended by org.apache.geronimo.blueprint.container.BlueprintRepository
All Implemented Interfaces:
ExecutionContext, Repository

public class BlueprintRepository
extends Object
implements Repository, ExecutionContext

The default repository implementation


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.geronimo.blueprint.di.ExecutionContext
ExecutionContext.Holder
 
Constructor Summary
BlueprintRepository(ExtendedBlueprintContainer container)
           
 
Method Summary
 void addFullObject(String name, Object object)
           
 void addPartialObject(String name, Object object)
           
 boolean containsObject(String name)
          Does this context contain a object with the specified name.
 Object convert(Object value, ReifiedType type)
           
 Object create(String name)
           
 Map<String,Object> createAll(Collection<String> names)
           
 void destroy()
           
<T> List<T>
getAllRecipes(Class<T> clazz, String... names)
           
 Set<Recipe> getAllRecipes(String... names)
           
 Object getInstance(String name)
          Return the singleton instance for the given name.
 Object getInstanceLock()
          Lock that should be used to synchronized creation of singletons
 Set<String> getNames()
          Returns the set of all known object names (recipes, instances or default objects)
 Object getObject(String name)
          Gets the object or recipe with the specified name from the repository.
 Object getPartialObject(String name)
           
 Recipe getRecipe(String name)
          Return the recipe for the given name.
 LinkedList<Recipe> getStack()
           
 Class loadClass(String typeName)
           
 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 putRecipe(String name, Recipe recipe)
           
 Object removePartialObject(String name)
           
 void validate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlueprintRepository

public BlueprintRepository(ExtendedBlueprintContainer container)
Method Detail

getInstance

public Object getInstance(String name)
Description copied from interface: Repository
Return the singleton instance for the given name. This method will not create the object if it has been created yet.

Specified by:
getInstance in interface Repository
Returns:
the instance or null

getRecipe

public Recipe getRecipe(String name)
Description copied from interface: Repository
Return the recipe for the given name.

Specified by:
getRecipe in interface ExecutionContext
Specified by:
getRecipe in interface Repository
Returns:
the recipe or null

getNames

public Set<String> getNames()
Description copied from interface: Repository
Returns the set of all known object names (recipes, instances or default objects)

Specified by:
getNames in interface Repository
Returns:

putRecipe

public void putRecipe(String name,
                      Recipe recipe)
Specified by:
putRecipe in interface Repository

create

public Object create(String name)
              throws ComponentDefinitionException
Specified by:
create in interface Repository
Throws:
ComponentDefinitionException

createAll

public Map<String,Object> createAll(Collection<String> names)
                             throws ComponentDefinitionException
Specified by:
createAll in interface Repository
Throws:
ComponentDefinitionException

getAllRecipes

public <T> List<T> getAllRecipes(Class<T> clazz,
                                 String... names)
Specified by:
getAllRecipes in interface Repository

getAllRecipes

public Set<Recipe> getAllRecipes(String... names)
Specified by:
getAllRecipes in interface Repository

validate

public void validate()

destroy

public void destroy()
Specified by:
destroy in interface Repository

getInstanceLock

public Object getInstanceLock()
Description copied from interface: ExecutionContext
Lock that should be used to synchronized creation of singletons

Specified by:
getInstanceLock in interface ExecutionContext
Specified by:
getInstanceLock in interface Repository
Returns:

push

public void push(Recipe recipe)
Description copied from interface: 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 interface ExecutionContext
Parameters:
recipe - the recipe to add to the stack

pop

public Recipe pop()
Description copied from interface: ExecutionContext
Removes the top recipe from the execution stack.

Specified by:
pop in interface ExecutionContext
Returns:
the top recipe on the stack

getStack

public LinkedList<Recipe> getStack()

containsObject

public boolean containsObject(String name)
Description copied from interface: ExecutionContext
Does this context contain a object with the specified name.

Specified by:
containsObject in interface ExecutionContext
Parameters:
name - the unique name of the object instance
Returns:
true if this context contain a object with the specified name

getObject

public Object getObject(String name)
Description copied from interface: ExecutionContext
Gets the object or recipe with the specified name from the repository.

Specified by:
getObject in interface ExecutionContext
Parameters:
name - the unique name of the object instance
Returns:
the object instance, a recipe to build the object or null

addFullObject

public void addFullObject(String name,
                          Object object)
Specified by:
addFullObject in interface ExecutionContext

addPartialObject

public void addPartialObject(String name,
                             Object object)
Specified by:
addPartialObject in interface ExecutionContext

removePartialObject

public Object removePartialObject(String name)
Specified by:
removePartialObject in interface ExecutionContext

getPartialObject

public Object getPartialObject(String name)
Specified by:
getPartialObject in interface ExecutionContext

convert

public Object convert(Object value,
                      ReifiedType type)
               throws Exception
Specified by:
convert in interface ExecutionContext
Throws:
Exception

loadClass

public Class loadClass(String typeName)
                throws ClassNotFoundException
Specified by:
loadClass in interface ExecutionContext
Throws:
ClassNotFoundException


Copyright © 2003-2009 The Apache Software Foundation. All Rights Reserved.