|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjfun.yan.containers.DelegatingContainer
public class DelegatingContainer
The base class for delegating to a Container object. It forwards all method call to the delegated Container object, which makes it handy for customizing a Container object by subclassing.
Codehaus.org.
| Constructor Summary | |
|---|---|
DelegatingContainer(Container yan)
Creates a new DelegatingContainer object. |
|
| Method Summary | ||
|---|---|---|
boolean |
containsKey(java.lang.Object key)
Whether a Component with a certain key is contained in the map. |
|
boolean |
containsType(java.lang.Class type)
Whether a Component of a certain type or its sub-type is contained in the map. |
|
boolean |
equals(java.lang.Object obj)
|
|
Component |
getComponent(java.lang.Object key)
Gets a Component identified by a key. |
|
|
getComponentOfType(java.lang.Class<T> type)
Gets a Component object of a certain type. |
|
java.util.Collection |
getComponents()
Gets all components stored in this map. |
|
|
getComponentsOfType(java.lang.Class<T> type)
Gets all component objects that are of a certain type. |
|
java.lang.Class |
getComponentType(java.lang.Object key)
Get the type of a component identified by a key. |
|
protected Container |
getDelegateTarget()
Gets the Container object being delegated. |
|
Dependency |
getDependency(java.lang.Object key)
Get the dependency for a component key. |
|
Dependency |
getDependency(java.lang.Object key,
ComponentMap cmap)
Gets the Dependency object for a component key. |
|
Dependency |
getDependencyOfType(java.lang.Class type)
Get the dependency for a component type. |
|
Dependency |
getDependencyOfType(java.lang.Class type,
ComponentMap cmap)
Gets the Dependency object for a component instance type. |
|
Factory |
getFactory(java.lang.Object key)
Create an instance of Factory for a component identified by a key. |
|
Factory |
getFactory(java.lang.Object key,
ComponentMap cmap)
Create an instance of Factory for a component identified by a key. |
|
|
getFactoryOfType(java.lang.Class<T> type)
Create an instance of Factory for a component of the provided type. |
|
|
getFactoryOfType(java.lang.Class<T> type,
ComponentMap cmap)
Create an instance of Factory for a component of the provided type. |
|
java.lang.Object |
getInstance(java.lang.Object key)
Create instance for a component identified by a key. |
|
java.lang.Object |
getInstance(java.lang.Object key,
ComponentMap cmap)
Create instance for a component identified by a key. |
|
|
getInstanceOfType(java.lang.Class<T> type)
Create component instance of the provided type. |
|
|
getInstanceOfType(java.lang.Class<T> type,
ComponentMap cmap)
Create component instance of the provided type. |
|
java.util.List |
getInstances()
Create instances of all the components stored in this container. |
|
java.util.List |
getInstances(ComponentMap cmap)
Create instances of all the components stored in this container. |
|
void |
getInstances(java.util.Map store)
Create instances of all the components stored in this container. |
|
void |
getInstances(java.util.Map store,
ComponentMap cmap)
Create instances of all the components stored in this container. |
|
|
getInstancesOfType(java.lang.Class<T> type)
Create component instances of a provided type. |
|
|
getInstancesOfType(java.lang.Class<T> type,
ComponentMap cmap)
Create component instances of a provided type. |
|
int |
hashCode()
|
|
Container |
inherit(Registrar parent)
Create a new Container object which represents "this inherits parent" relationship. |
|
|
instantiateComponent(Creator<T> cc)
Instantiate component instance. |
|
|
instantiateComponent(java.lang.Object key,
Creator<T> cc)
Instantiate component instance. |
|
java.util.Set |
keys()
Get all the component keys. |
|
void |
registerComponent(Component cc)
Register a Component object in the container. |
|
void |
registerComponent(java.lang.Object key,
Component cc)
Register a Component identified by a key. |
|
void |
registerConstructor(java.lang.Class c)
Register a constructor in the container. |
|
void |
registerConstructor(java.lang.Class c,
java.lang.Class[] param_types)
Register a constructor in the container. |
|
void |
registerConstructor(java.lang.Object key,
java.lang.Class c)
Register a constructor in the container. |
|
void |
registerConstructor(java.lang.Object key,
java.lang.Class c,
java.lang.Class[] param_types)
Register a constructor in the container. |
|
void |
registerStaticMethod(java.lang.Class c,
java.lang.String name)
Register a component that uses a static method to create component instance. |
|
void |
registerStaticMethod(java.lang.Class c,
java.lang.String name,
java.lang.Class[] param_types)
Register a component that uses a static method to create component instance. |
|
void |
registerStaticMethod(java.lang.Object key,
java.lang.Class c,
java.lang.String name)
Register a component that uses a static method to create component instance. |
|
void |
registerStaticMethod(java.lang.Object key,
java.lang.Class c,
java.lang.String name,
java.lang.Class[] param_types)
Register a component that uses a static method to create component instance. |
|
void |
registerValue(java.lang.Object v)
Register a value in the container. |
|
void |
registerValue(java.lang.Object key,
java.lang.Object v)
Register a value in the container. |
|
java.lang.String |
toString()
|
|
void |
unregisterComponent(java.lang.Object key)
Unregister a component identified by a key. |
|
void |
unregisterComponentsOfType(java.lang.Class type)
Unregister components of a certain type. |
|
void |
verify()
Verifies the components in this container. |
|
void |
verify(ComponentMap cmap)
Verifies that all the registered components can be satisfied. |
|
java.lang.Class |
verifyComponent(Component cc)
Verifies that a Component is valid using the current container in resolving dependency. |
|
java.lang.Class |
verifyKey(java.lang.Object key)
Verifies a component identified by key. |
|
java.lang.Class |
verifyType(java.lang.Class type)
Verifies a component for a type. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DelegatingContainer(Container yan)
yan - the Container object to delegate to.| Method Detail |
|---|
public Factory getFactory(java.lang.Object key,
ComponentMap cmap)
throws UnresolvedComponentException,
YanException
ContainerFactory for a component identified by a key.
when Factory.create() is called, the component is instantiated.
getFactory in interface Containerkey - the component key.cmap - the container to resolve dependency.
UnresolvedComponentException - if this component cannot be resolved.
YanException - for any other exception.
public Factory getFactory(java.lang.Object key)
throws UnresolvedComponentException,
YanException
ContainerFactory for a component identified by a key.
when Factory.create() is called, the component is instantiated.
getFactory in interface Containerkey - the component key.
UnresolvedComponentException - if this component cannot be resolved.
YanException - for any other exception.
public <T> Factory<T> getFactoryOfType(java.lang.Class<T> type,
ComponentMap cmap)
throws AmbiguousComponentResolutionException,
UnresolvedComponentException,
YanException
ContainerFactory for a component of the provided type.
when Factory.create() is called, the component is instantiated.
getFactoryOfType in interface Containertype - the type.cmap - the container to resolve dependency.
AmbiguousComponentResolutionException - if ambiguity happens.
UnresolvedComponentException - if this component cannot be resolved.
YanException - for any other exception.
public <T> Factory<T> getFactoryOfType(java.lang.Class<T> type)
throws AmbiguousComponentResolutionException,
UnresolvedComponentException,
YanException
ContainerFactory for a component of the provided type.
when Factory.create() is called, the component is instantiated.
getFactoryOfType in interface Containertype - the type.
AmbiguousComponentResolutionException - if ambiguity happens.
UnresolvedComponentException - if this component or any dependent component cannot be resolved.
YanException - for any other exception.
public void getInstances(java.util.Map store,
ComponentMap cmap)
throws ComponentInstantiationException,
CyclicDependencyException,
UnresolvedComponentException,
UnsatisfiedComponentException,
YanException
ContainerThe dependencies are resolved in the current container.
getInstances in interface Containerstore - the java.util.Map object to save the component instances.cmap - the container in which to resolve dependency.
ComponentInstantiationException - wrapper exception for any checked exception thrown out of the actual creation.
CyclicDependencyException - if cyclic dependency is detected.
UnresolvedComponentException - if this component or any dependent component cannot be resolved.
UnsatisfiedComponentException - if some requirement of the component cannot be satisfied.
YanException - for any other exception.
public void getInstances(java.util.Map store)
throws ComponentInstantiationException,
CyclicDependencyException,
UnresolvedComponentException,
UnsatisfiedComponentException,
YanException
Container
getInstances in interface Containerstore - the java.util.Map object to save the component instances.
ComponentInstantiationException - wrapper exception for any checked exception thrown out of the actual creation.
CyclicDependencyException - if cyclic dependency is detected.
UnresolvedComponentException - if this component or any dependent component cannot be resolved.
UnsatisfiedComponentException - if some requirement of the component cannot be satisfied.
YanException - for any other exception.
public <T> T instantiateComponent(java.lang.Object key,
Creator<T> cc)
throws AmbiguousComponentResolutionException,
ComponentInstantiationException,
CyclicDependencyException,
UnresolvedComponentException,
UnsatisfiedComponentException,
YanException
Container
instantiateComponent in interface Containerkey - the key of the component.cc - the component to instantiate.
AmbiguousComponentResolutionException - if ambiguity happens.
ComponentInstantiationException - wrapper exception for any checked exception thrown out of the actual creation.
CyclicDependencyException - if cyclic dependency is detected.
UnresolvedComponentException - if this component or any dependent component cannot be resolved.
UnsatisfiedComponentException - if some requirement of the component cannot be satisfied.
YanException - for any other exception.
public <T> T instantiateComponent(Creator<T> cc)
throws AmbiguousComponentResolutionException,
ComponentInstantiationException,
CyclicDependencyException,
UnresolvedComponentException,
UnsatisfiedComponentException,
YanException
Container
instantiateComponent in interface Containercc - the component to instantiate.
AmbiguousComponentResolutionException - if ambiguity happens.
ComponentInstantiationException - wrapper exception for any checked exception thrown out of the actual creation.
CyclicDependencyException - if cyclic dependency is detected.
UnresolvedComponentException - if this component or any dependent component cannot be resolved.
UnsatisfiedComponentException - if some requirement of the component cannot be satisfied.
YanException - for any other exception.protected final Container getDelegateTarget()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean containsKey(java.lang.Object key)
ComponentMap
containsKey in interface ComponentMapkey - the component key.
public boolean containsType(java.lang.Class type)
ComponentMap
containsType in interface ComponentMaptype - the type of the component.
public Component getComponent(java.lang.Object key)
ComponentMap
getComponent in interface ComponentMapkey - the component key.
public <T> Component<T> getComponentOfType(java.lang.Class<T> type)
ComponentMap
getComponentOfType in interface ComponentMaptype - the component instance type.
public java.util.Collection getComponents()
ComponentMap
getComponents in interface ComponentMappublic <T> java.util.List<Component<T>> getComponentsOfType(java.lang.Class<T> type)
ComponentMap
getComponentsOfType in interface ComponentMaptype - the component instance type.
public java.lang.Class getComponentType(java.lang.Object key)
Container
getComponentType in interface Containerkey - the component key.
public java.lang.Object getInstance(java.lang.Object key)
Container
getInstance in interface Containerkey - the component key.
public java.lang.Object getInstance(java.lang.Object key,
ComponentMap cmap)
Container
getInstance in interface Containerkey - the component key.cmap - the container to resolve dependency.
public <T> T getInstanceOfType(java.lang.Class<T> type)
Container
getInstanceOfType in interface Containertype - the type.
public <T> T getInstanceOfType(java.lang.Class<T> type,
ComponentMap cmap)
Container
getInstanceOfType in interface Containertype - the type.cmap - the container to resolve dependency.
public java.util.List getInstances()
Container
getInstances in interface Containerpublic java.util.List getInstances(ComponentMap cmap)
ContainerThe dependencies are resolved in the current container.
getInstances in interface Containercmap - the container in which to resolve dependency.
public <T> java.util.List<T> getInstancesOfType(java.lang.Class<T> type)
Container
getInstancesOfType in interface Containertype - the type.
public <T> java.util.List<T> getInstancesOfType(java.lang.Class<T> type,
ComponentMap cmap)
Container
getInstancesOfType in interface Containertype - the type.cmap - the container to resolve dependency.
public Dependency getDependency(java.lang.Object key)
Container
getDependency in interface Containerkey - the component key.
public Dependency getDependency(java.lang.Object key,
ComponentMap cmap)
ComponentMap
getDependency in interface ComponentMapkey - The component key.cmap - The ComponentMap object from which the parts of
the component should be obtained.
This parameter is typically passed as 'this' so that the parts are
created in the same container.
When implementing container interaction such as inheritance,
this parameter may be passed as a different ComponentMap object.
public Dependency getDependencyOfType(java.lang.Class type)
Container
getDependencyOfType in interface Containertype - the component type.
public Dependency getDependencyOfType(java.lang.Class type,
ComponentMap cmap)
ComponentMap
getDependencyOfType in interface ComponentMaptype - The component instance type.cmap - The ComponentMap object from which the parts of
the component should be obtained.
This parameter is typically passed as 'this' so that the parts are
created in the same container.
When implementing container interaction such as inheritance,
this parameter may be passed as a different ComponentMap object.
public int hashCode()
hashCode in class java.lang.Objectpublic Container inherit(Registrar parent)
Container
inherit in interface Containerparent - the parent registrar.
public java.util.Set keys()
ComponentMap
keys in interface ComponentMappublic void registerComponent(Component cc)
Container
registerComponent in interface Containercc - the component.
public void registerComponent(java.lang.Object key,
Component cc)
Registrar
registerComponent in interface Registrarkey - the component key.cc - the component.public void registerConstructor(java.lang.Class c)
Container
registerConstructor in interface Containerc - the class containing the constructor.
public void registerConstructor(java.lang.Class c,
java.lang.Class[] param_types)
Container
registerConstructor in interface Containerc - the class containing the constructor.param_types - the parameter types of the constructor.
public void registerConstructor(java.lang.Object key,
java.lang.Class c)
Container
registerConstructor in interface Containerkey - the component key.c - the class containing the constructor.
public void registerConstructor(java.lang.Object key,
java.lang.Class c,
java.lang.Class[] param_types)
Container
registerConstructor in interface Containerkey - the component key.c - the class containing the constructor.param_types - the parameter types of the constructor.
public void registerStaticMethod(java.lang.Class c,
java.lang.String name)
Container
registerStaticMethod in interface Containerc - the class containing the static method.name - the method name.
public void registerStaticMethod(java.lang.Class c,
java.lang.String name,
java.lang.Class[] param_types)
Container
registerStaticMethod in interface Containerc - the class containing the static method.name - the method name.
public void registerStaticMethod(java.lang.Object key,
java.lang.Class c,
java.lang.String name)
Container
registerStaticMethod in interface Containerkey - the component key.c - the class containing the static method.name - the method name.
public void registerStaticMethod(java.lang.Object key,
java.lang.Class c,
java.lang.String name,
java.lang.Class[] param_types)
Container
registerStaticMethod in interface Containerkey - the component key.c - the class containing the static method.name - the method name.param_types - the parameter types.public void registerValue(java.lang.Object v)
Container
registerValue in interface Containerv - the value.
public void registerValue(java.lang.Object key,
java.lang.Object v)
Container
registerValue in interface Containerkey - the key of the value.v - the value.public java.lang.String toString()
toString in class java.lang.Objectpublic void unregisterComponent(java.lang.Object key)
Registrar
unregisterComponent in interface Registrarkey - the component key.public void unregisterComponentsOfType(java.lang.Class type)
Registrar
unregisterComponentsOfType in interface Registrartype - the component instance type.public void verify()
Container
verify in interface Containerpublic void verify(ComponentMap cmap)
Registrar
verify in interface Registrarcmap - the ComponentMap from which
the parts of the registered components are obtained.public java.lang.Class verifyComponent(Component cc)
Container
verifyComponent in interface Containercc - the component to verify.
public java.lang.Class verifyKey(java.lang.Object key)
Container
verifyKey in interface Containerkey - the component key.
public java.lang.Class verifyType(java.lang.Class type)
Container
verifyType in interface Containertype - the component type.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||