org.objectweb.easybeans.component
Class ComponentRegistry

java.lang.Object
  extended by org.objectweb.easybeans.component.ComponentRegistry
All Implemented Interfaces:
EZBComponentRegistry

public class ComponentRegistry
extends java.lang.Object
implements EZBComponentRegistry

Registry that manages components. It allows to get components.

Author:
Florent Benoit

Field Summary
private  java.util.Map<java.lang.String,EZBComponent> components
          Map of components.
Name <--> Implementation of the component
private  JLog logger
          Logger.
 
Constructor Summary
ComponentRegistry()
          Constructor.
 
Method Summary
 EZBComponent getComponent(java.lang.String componentName)
          Allow to get a reference on another component.
 java.lang.String getComponentName(EZBComponent component)
           
<T extends EZBComponent>
java.util.List<T>
getComponents(java.lang.Class<T> itf)
          Get the components that implements the given interface.
 void register(java.lang.String componentName, EZBComponent component)
          Register a component.
 void unregister(EZBComponent component)
          Unregister a component.
 void unregister(java.lang.String componentName)
          Unregister a component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private JLog logger
Logger.


components

private java.util.Map<java.lang.String,EZBComponent> components
Map of components.
Name <--> Implementation of the component

Constructor Detail

ComponentRegistry

public ComponentRegistry()
Constructor.

Method Detail

register

public void register(java.lang.String componentName,
                     EZBComponent component)
              throws EZBComponentException
Register a component.

Specified by:
register in interface EZBComponentRegistry
Parameters:
componentName - the name of the component to register
component - the component to register.
Throws:
EZBComponentException - if registering fails.

unregister

public void unregister(java.lang.String componentName)
                throws EZBComponentException
Unregister a component.

Specified by:
unregister in interface EZBComponentRegistry
Parameters:
componentName - the component name to unregister.
Throws:
EZBComponentException - if unregistering fails.

unregister

public void unregister(EZBComponent component)
                throws EZBComponentException
Unregister a component.

Specified by:
unregister in interface EZBComponentRegistry
Parameters:
component - the instance of the component to unregister.
Throws:
EZBComponentException - if unregistering fails.

getComponent

public EZBComponent getComponent(java.lang.String componentName)
Allow to get a reference on another component.

Specified by:
getComponent in interface EZBComponentRegistry
Parameters:
componentName - the name of the component
Returns:
the component.

getComponentName

public java.lang.String getComponentName(EZBComponent component)
Specified by:
getComponentName in interface EZBComponentRegistry
Parameters:
component - EZBComponent instance.
Returns:
Returns the component name from the EZBComponent instance.

getComponents

public <T extends EZBComponent> java.util.List<T> getComponents(java.lang.Class<T> itf)
Get the components that implements the given interface.

Specified by:
getComponents in interface EZBComponentRegistry
Type Parameters:
T - an interface extending EZBComponent.
Parameters:
itf - the given interface
Returns:
an array of components implementing the given interface