org.ocltf.common
Class ComponentContainer

java.lang.Object
  extended byorg.ocltf.common.ComponentContainer

public class ComponentContainer
extends java.lang.Object

This handles all registration and retrieval of components within the framework.

Version:
1.0
Author:
Chad Brandon

Constructor Summary
protected ComponentContainer()
          Constructs an instance of ComponentContainer.
 
Method Summary
 java.lang.Object findComponent(java.lang.Class key)
          Finds the component with the specified key.
 java.lang.Object findComponent(java.lang.Object key)
          Finds the component with the specified key.
 java.lang.Object findComponent(java.lang.String key, java.lang.Class type)
          Attempts to find the component with the specified unique key, if it can't be found, the default of the specified type is returned, if no default is set, null is returned.
 java.util.Collection findComponentsOfType(java.lang.Class type)
          Finds all components having the given type.
static ComponentContainer instance()
          Gets the shared instance of this ComponentContainer.
 java.lang.Object registerComponent(java.lang.String key, java.lang.Object component)
          Registers the component in this container with a unique (within this container) key.
 java.lang.Object registerComponentType(java.lang.Class type)
          Registers the component of the specified type.
 java.lang.Object registerComponentType(java.lang.String type)
          Registers the components of the specified type.
 java.lang.Object registerDefaultComponent(java.lang.Class componentInterface, java.lang.Class defaultType)
          Registers the "default" for the specified componentInterface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentContainer

protected ComponentContainer()
Constructs an instance of ComponentContainer.

Method Detail

instance

public static ComponentContainer instance()
Gets the shared instance of this ComponentContainer.

Returns:
PluginDiscoverer the static instance.

findComponent

public java.lang.Object findComponent(java.lang.Object key)
Finds the component with the specified key.

Parameters:
key - the unique key of the component as an Object.
Returns:
Object the component instance.

findComponent

public java.lang.Object findComponent(java.lang.Class key)
Finds the component with the specified key.

Parameters:
key - the unique key as a Class.
Returns:
Object the component instance.

findComponent

public java.lang.Object findComponent(java.lang.String key,
                                      java.lang.Class type)
Attempts to find the component with the specified unique key, if it can't be found, the default of the specified type is returned, if no default is set, null is returned.

Parameters:
key - the unique key of the component.
Returns:
Object the component instance.

findComponentsOfType

public java.util.Collection findComponentsOfType(java.lang.Class type)
Finds all components having the given type.

Parameters:
type - the component type.
Returns:
Collection all components

registerComponent

public java.lang.Object registerComponent(java.lang.String key,
                                          java.lang.Object component)
Registers the component in this container with a unique (within this container) key.

Parameters:
key - the unique key.
Returns:
Object the registered component.

registerDefaultComponent

public java.lang.Object registerDefaultComponent(java.lang.Class componentInterface,
                                                 java.lang.Class defaultType)
Registers the "default" for the specified componentInterface.

Parameters:
componentInterface - the interface for the component.
defaultType - the "default" implementation to use for the componentInterface.
Returns:
Object the registered component.

registerComponentType

public java.lang.Object registerComponentType(java.lang.Class type)
Registers the component of the specified type.

Parameters:
type - the type Class.
Returns:
Object an instance of the type registered.

registerComponentType

public java.lang.Object registerComponentType(java.lang.String type)
Registers the components of the specified type.

Parameters:
type - the name of a type (must have be able to be instantiated into a Class instance)
Returns:
Object an instance of the type registered.


Copyright © 2003-2004 Chad Brandon. All Rights Reserved.