org.oddjob.arooa.registry
Interface ComponentPool

All Known Implementing Classes:
SimpleComponentPool

public interface ComponentPool

A ComponentPool provides access to the Components created by parsing an ArooaConfiguration.

Author:
rob

Method Summary
 Iterable<ComponentTrinity> allTrinities()
          Provide a way of iterating over all trinities.
 void configure(Object component)
          Configure the component.
 ArooaContext contextFor(Object either)
          Get the components ArooaContext.
 String getIdFor(Object either)
          Provide the Id for either a component or it's proxy.
 void registerComponent(ComponentTrinity trinity, String id)
          Register a ComponentTrinity.
 void remove(Object either)
          Remove a component.
 void save(Object either)
          Possibly save the component to a persistent store, if everything is in place for this to happen.
 ComponentTrinity trinityForId(String id)
          Provide the ComponentTrinity for a given id, if possible.
 

Method Detail

configure

void configure(Object component)
               throws ArooaConfigurationException
Configure the component. The is a shortcut method equivalent to contextFor(component).getRuntime().configure().

Parameters:
component - The component or it's proxy.
Throws:
ArooaConfigurationException

save

void save(Object either)
          throws ComponentPersistException
Possibly save the component to a persistent store, if everything is in place for this to happen.

If a ComponentPersister is in operation and the component was registered with an id then the ComponentPersister is invoked with the component.

Parameters:
either - or it's proxy.
Throws:
ComponentPersistException

remove

void remove(Object either)
            throws ComponentPersistException
Remove a component.

Throws:
ComponentPersistException

contextFor

ArooaContext contextFor(Object either)
Get the components ArooaContext.

Parameters:
either - The component or the proxy.
Returns:
The context or null if the component/proxy is not in this pool.

registerComponent

void registerComponent(ComponentTrinity trinity,
                       String id)
Register a ComponentTrinity.

Parameters:
trinity - The trinity.
id - The id. May be null.

getIdFor

String getIdFor(Object either)
Provide the Id for either a component or it's proxy.

Parameters:
either - Either a component or it's proxy.
Returns:
The id, or null if the component wasn't registered with an id, or the component doesn't exist in pool.

trinityForId

ComponentTrinity trinityForId(String id)
Provide the ComponentTrinity for a given id, if possible.

Parameters:
id - The id.
Returns:
The trinity, or null if none exists for the given id.

allTrinities

Iterable<ComponentTrinity> allTrinities()
Provide a way of iterating over all trinities.

Returns:
An Iterable of trinities. Will never be null.