jfun.yan
Interface ComponentMap

All Superinterfaces:
java.io.Serializable
All Known Subinterfaces:
Container, Registrar
All Known Implementing Classes:
DefaultContainer, DelegatingComponentMap, DelegatingContainer, ImmutablePreferredContainer, InheritedRegistrar, ManualContainer, ManualWiringContainer, MonitoringContainer, ProxyContainer, SimpleContainer, SimpleRegistrar, SingletonContainer, SingletonProxyContainer, TransformingContainer

public interface ComponentMap
extends java.io.Serializable

A map that is used to retrieve Component by key or type.

Codehaus.org.

Author:
Ben Yu

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.
 Component getComponent(java.lang.Object key)
          Gets a Component identified by a key.
<T> Component<T>
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.
<T> java.util.List<Component<T>>
getComponentsOfType(java.lang.Class<T> type)
          Gets all component objects that are of a certain type.
 Dependency getDependency(java.lang.Object key, ComponentMap cmap)
          Gets the Dependency object for a component key.
 Dependency getDependencyOfType(java.lang.Class type, ComponentMap cmap)
          Gets the Dependency object for a component instance type.
 java.util.Set keys()
          Get all the component keys.
 

Method Detail

getComponent

Component getComponent(java.lang.Object key)
Gets a Component identified by a key.

Parameters:
key - the component key.
Returns:
the Component object or null if a component with the given key is not found.

keys

java.util.Set keys()
Get all the component keys.

Returns:
the component keys.

getComponents

java.util.Collection getComponents()
Gets all components stored in this map.

Returns:
the components. The returned Collection contains 0 or more Component objects.

getComponentOfType

<T> Component<T> getComponentOfType(java.lang.Class<T> type)
                                throws AmbiguousComponentResolutionException
Gets a Component object of a certain type. Subtype relationship is honored. So that a Component with type String is considered with type CharSequence as well. If more than one Component is found with the given type, AmbiguousComponentResolutionException is thrown. null is returned if no such component is found.

Parameters:
type - the component instance type.
Returns:
the Component object.
Throws:
AmbiguousComponentResolutionException

containsKey

boolean containsKey(java.lang.Object key)
Whether a Component with a certain key is contained in the map.

Parameters:
key - the component key.
Returns:
true if the key exists in the map.

containsType

boolean containsType(java.lang.Class type)
Whether a Component of a certain type or its sub-type is contained in the map.

Parameters:
type - the type of the component.
Returns:
true if the type or its sub-type exists in the map.

getComponentsOfType

<T> java.util.List<Component<T>> getComponentsOfType(java.lang.Class<T> type)
Gets all component objects that are of a certain type.

Parameters:
type - the component instance type.
Returns:
the list of the components with this type.

getDependency

Dependency getDependency(java.lang.Object key,
                         ComponentMap cmap)
Gets the Dependency object for a component key.

Parameters:
key - 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.
Returns:
the Dependency object.

getDependencyOfType

Dependency getDependencyOfType(java.lang.Class type,
                               ComponentMap cmap)
Gets the Dependency object for a component instance type.

Parameters:
type - 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.
Returns:
the Dependency object.