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 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
 Future<Object> addFullObject(String name, Future<Object> object)
          Try to add a full object and return the already registered future if available
 void addPartialObject(String name, Object object)
           
 boolean canConvert(Object value, org.osgi.service.blueprint.container.ReifiedType type)
           
 boolean containsObject(String name)
          Does this context contain a object with the specified name.
 Object convert(Object value, org.osgi.service.blueprint.container.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.
 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.
 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)
           
 void removePartialObject(String name)
           
 void removeRecipe(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 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 not 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

removeRecipe

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

Specified by:
removeRecipe in interface Repository

create

public Object create(String name)
              throws org.osgi.service.blueprint.container.ComponentDefinitionException
Specified by:
create in interface Repository
Throws:
org.osgi.service.blueprint.container.ComponentDefinitionException

createAll

public Map<String,Object> createAll(Collection<String> names)
                             throws org.osgi.service.blueprint.container.ComponentDefinitionException
Specified by:
createAll in interface Repository
Throws:
org.osgi.service.blueprint.container.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

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

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 Future<Object> addFullObject(String name,
                                    Future<Object> object)
Description copied from interface: ExecutionContext
Try to add a full object and return the already registered future if available

Specified by:
addFullObject in interface ExecutionContext
Returns:

addPartialObject

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

getPartialObject

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

removePartialObject

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

convert

public Object convert(Object value,
                      org.osgi.service.blueprint.container.ReifiedType type)
               throws Exception
Specified by:
convert in interface ExecutionContext
Throws:
Exception

canConvert

public boolean canConvert(Object value,
                          org.osgi.service.blueprint.container.ReifiedType type)
Specified by:
canConvert in interface ExecutionContext

loadClass

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


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