org.apache.aries.blueprint.container
Class BlueprintRepository

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

public class BlueprintRepository
extends java.lang.Object
implements Repository, ExecutionContext

The default repository implementation


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

removeRecipe

public void removeRecipe(java.lang.String name)
Description copied from interface: Repository
Remove an uninstantiated recipe

Specified by:
removeRecipe in interface Repository

create

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

createAll

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

getAllRecipes

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

getAllRecipes

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

validate

public void validate()

destroy

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

getInstanceLock

public java.lang.Object getInstanceLock()
Description copied from interface: Repository
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 java.util.LinkedList<Recipe> getStack()

containsObject

public boolean containsObject(java.lang.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 java.lang.Object getObject(java.lang.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(java.lang.String name,
                          java.lang.Object object)
Specified by:
addFullObject in interface ExecutionContext

addPartialObject

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

removePartialObject

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

getPartialObject

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

convert

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

canConvert

public boolean canConvert(java.lang.Object value,
                          ReifiedType type)
Specified by:
canConvert in interface ExecutionContext

loadClass

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


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