|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.picocontainer.defaults.DefaultPicoContainer
| Constructor Summary | |
DefaultPicoContainer()
|
|
DefaultPicoContainer(ComponentAdapterFactory componentAdapterFactory)
|
|
| Method Summary | |
void |
addChild(MutablePicoContainer child)
Adds a Child container. |
void |
addOrderedComponentAdapter(ComponentAdapter componentAdapter)
Adds a component instance to the container. |
void |
addParent(MutablePicoContainer parent)
Adds a Parent container. |
ComponentAdapter |
findComponentAdapter(Object componentKey)
Finds a ComponentAdapter matching the key. |
Object |
findComponentInstance(Class componentType)
|
ComponentAdapter |
findImplementingComponentAdapter(Class componentType)
|
Collection |
getChildContainers()
Get the child containers of this container. |
List |
getComponentAdapters()
|
Object |
getComponentInstance(Object componentKey)
Gets a component instance. |
List |
getComponentInstances()
Gets all the registered component instances in the container. |
Collection |
getComponentKeys()
Get all the component keys. |
Object |
getComponentMulticaster()
Shorthand for getComponentMulticaster(boolean, boolean) |
Object |
getComponentMulticaster(boolean callInInstantiationOrder,
boolean callUnmanagedComponents)
Returns an object (in fact, a dynamic proxy) that implements the union of all the interfaces of the currently registered components. |
List |
getParentContainers()
Get the parent containers of this container. |
boolean |
hasComponent(Object componentKey)
Checks for the presence of a particular component. |
void |
registerComponent(ComponentAdapter componentAdapter)
|
Object |
registerComponentImplementation(Class componentImplementation)
Registers a component using the componentImplementation as key. |
Object |
registerComponentImplementation(Object componentKey,
Class componentImplementation)
Registers a component. |
Object |
registerComponentImplementation(Object componentKey,
Class componentImplementation,
Parameter[] parameters)
Registers a component. |
Object |
registerComponentInstance(Object component)
Registers an arbitrary object, using itself as a key. |
Object |
registerComponentInstance(Object componentKey,
Object componentInstance)
Registers an arbitrary object as a compoent in the container. |
Object |
unregisterComponent(Object componentKey)
Unregisters a component. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DefaultPicoContainer(ComponentAdapterFactory componentAdapterFactory)
public DefaultPicoContainer()
| Method Detail |
public final Collection getComponentKeys()
PicoContainer
getComponentKeys in interface PicoContainerpublic List getComponentAdapters()
public void registerComponent(ComponentAdapter componentAdapter)
throws DuplicateComponentKeyRegistrationException
DuplicateComponentKeyRegistrationExceptionpublic Object unregisterComponent(Object componentKey)
MutablePicoContainer
unregisterComponent in interface MutablePicoContainercomponentKey - key of the component to unregister.
public final ComponentAdapter findComponentAdapter(Object componentKey)
throws AmbiguousComponentResolutionException
PicoContainer
findComponentAdapter in interface PicoContainercomponentKey - key of the component.
AmbiguousComponentResolutionException
public Object registerComponentInstance(Object component)
throws PicoRegistrationException
MutablePicoContainer
registerComponentInstance in interface MutablePicoContainercomponent -
PicoRegistrationException
public Object registerComponentInstance(Object componentKey,
Object componentInstance)
throws PicoRegistrationException
MutablePicoContainer
registerComponentInstance in interface MutablePicoContainercomponentKey - a key that identifies the compoent. Must be unique within the conainer.componentInstance - an arbitrary object.
PicoRegistrationException - if registration fails.
public Object registerComponentImplementation(Class componentImplementation)
throws PicoRegistrationException
MutablePicoContainer
registerComponentImplementation in interface MutablePicoContainercomponentImplementation - the concrete component class.
PicoRegistrationException - if registration fails.
public Object getComponentMulticaster(boolean callInInstantiationOrder,
boolean callUnmanagedComponents)
throws PicoInitializationException,
PicoIntrospectionException,
AssignabilityRegistrationException,
NotConcreteRegistrationException
PicoContainerCasting this object to any of those interfaces and then calling a method on it will result in that call being multicast to all the components implementing that given interface.
This is a simple yet extremely powerful way to handle lifecycle of components. Component writers can invent their own lifecycle interfaces, and then use the multicaster to invoke the method in one go.
getComponentMulticaster in interface PicoContainercallInInstantiationOrder - whether or not to call the method in the order of instantiation,
which depends on the components' inter-dependencies.callUnmanagedComponents - whether or not to multicast to components that are not managed
by this container.
PicoInitializationException
PicoIntrospectionException
AssignabilityRegistrationException
NotConcreteRegistrationException
public Object getComponentMulticaster()
throws PicoInitializationException,
PicoIntrospectionException,
AssignabilityRegistrationException,
NotConcreteRegistrationException
PicoContainerPicoContainer.getComponentMulticaster(boolean, boolean)(true, false), which is the most common usage scenario.
getComponentMulticaster in interface PicoContainerPicoInitializationException
PicoIntrospectionException
AssignabilityRegistrationException
NotConcreteRegistrationException
public Object registerComponentImplementation(Object componentKey,
Class componentImplementation)
throws PicoRegistrationException
MutablePicoContainer
registerComponentImplementation in interface MutablePicoContainercomponentKey - a key that identifies the compoent. Must be unique within the conainer.componentImplementation - the concrete component class.
PicoRegistrationException - if registration fails.
public Object registerComponentImplementation(Object componentKey,
Class componentImplementation,
Parameter[] parameters)
throws PicoRegistrationException
MutablePicoContainer
registerComponentImplementation in interface MutablePicoContainercomponentKey - a key that identifies the compoent. Must be unique within the conainer.componentImplementation - the concrete component class.parameters - an array of parameters that gives the container hints about what arguments
to pass to the constructor when it is instantiated.
PicoRegistrationException - if registration fails.public void addOrderedComponentAdapter(ComponentAdapter componentAdapter)
MutablePicoContainerMutablePicoContainer.registerComponentInstance(java.lang.Object)
instead if you wish to register externally instantiated objects.
addOrderedComponentAdapter in interface MutablePicoContainercomponentAdapter - key of the component.
public List getComponentInstances()
throws PicoException
PicoContainer
getComponentInstances in interface PicoContainerPicoException - if one of the components could not be instantiated or dependencies
could not be properly resolved.
public Object getComponentInstance(Object componentKey)
throws PicoException
PicoContainer
getComponentInstance in interface PicoContainercomponentKey - key the component was registered with.
PicoException - if the component could not be instantiated or dependencies
could not be properly resolved.
public Object findComponentInstance(Class componentType)
throws PicoException
PicoExceptionpublic boolean hasComponent(Object componentKey)
PicoContainer
hasComponent in interface PicoContainercomponentKey - key of the component to look for.
public ComponentAdapter findImplementingComponentAdapter(Class componentType)
throws PicoException
PicoExceptionpublic Collection getChildContainers()
PicoContainer
getChildContainers in interface PicoContainerPicoContainer.PicoContainer.getParentContainers()public List getParentContainers()
PicoContainer
getParentContainers in interface PicoContainerPicoContainer.public void addChild(MutablePicoContainer child)
MutablePicoContainerMutablePicoContainer.addParent(org.picocontainer.MutablePicoContainer) is not necessary.
addChild in interface MutablePicoContainerchild - child container.public void addParent(MutablePicoContainer parent)
MutablePicoContainerMutablePicoContainer.addChild(org.picocontainer.MutablePicoContainer) is not necessary.
addParent in interface MutablePicoContainerparent - parent container.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||