public class SimpleComponentPool extends java.lang.Object implements ComponentPool
ComponentPool
.
This class is thread safe for the addition an removal of components. It is not thread safe for configuration an saving. This is left to the calling code. Oddjob for instance achieves thread safety for for these operations by locking on State.
Constructor and Description |
---|
SimpleComponentPool() |
Modifier and Type | Method and Description |
---|---|
java.lang.Iterable<ComponentTrinity> |
allTrinities()
Provide a way of iterating over all trinities.
|
void |
configure(java.lang.Object component)
Configure the component.
|
ArooaContext |
contextFor(java.lang.Object either)
Get the components
ArooaContext . |
java.lang.String |
getIdFor(java.lang.Object either)
Provide the Id for either a component or it's proxy.
|
java.lang.String |
registerComponent(ComponentTrinity componentTrinity,
java.lang.String id)
Register a
ComponentTrinity . |
boolean |
remove(java.lang.Object either)
Remove a component.
|
void |
save(java.lang.Object component)
Possibly save the component to a persistent store, if everything
is in place for this to happen.
|
ComponentTrinity |
trinityFor(java.lang.Object either)
Get the
ComponentTrinity for either the component or
proxy. |
ComponentTrinity |
trinityForContext(ArooaContext context)
Get the
ComponentTrinity for the given ArooaContext . |
ComponentTrinity |
trinityForId(java.lang.String id)
Provide the
ComponentTrinity for a given id, if possible. |
public void configure(java.lang.Object component) throws ArooaConfigurationException
ComponentPool
contextFor(component).getRuntime().configure().
configure
in interface ComponentPool
component
- The component or it's proxy.ArooaConfigurationException
public void save(java.lang.Object component) throws ComponentPersistException
ComponentPool
If a ComponentPersister
is in operation and the component
was registered with an id then the ComponentPersister is
invoked with the component.
save
in interface ComponentPool
component
- A component or it's proxy.ComponentPersistException
public boolean remove(java.lang.Object either) throws ComponentPersistException
ComponentPool
remove
in interface ComponentPool
either
- A component or it's proxy.ComponentPersistException
public ArooaContext contextFor(java.lang.Object either)
ComponentPool
ArooaContext
.contextFor
in interface ComponentPool
either
- The component or the proxy.public ComponentTrinity trinityForContext(ArooaContext context)
ComponentPool
ComponentTrinity
for the given ArooaContext
.
This is required for ContextHierarchyServiceFinder
.
trinityForContext
in interface ComponentPool
context
- A context;public ComponentTrinity trinityFor(java.lang.Object either)
ComponentPool
ComponentTrinity
for either the component or
proxy.
trinityFor
in interface ComponentPool
either
- Either the component or the proxy.public ComponentTrinity trinityForId(java.lang.String id)
ComponentPool
ComponentTrinity
for a given id, if possible.trinityForId
in interface ComponentPool
id
- The id.public java.lang.String getIdFor(java.lang.Object either)
ComponentPool
getIdFor
in interface ComponentPool
either
- Either a component or it's proxy.public java.lang.Iterable<ComponentTrinity> allTrinities()
ComponentPool
allTrinities
in interface ComponentPool
public java.lang.String registerComponent(ComponentTrinity componentTrinity, java.lang.String id)
ComponentPool
ComponentTrinity
.registerComponent
in interface ComponentPool
componentTrinity
- The trinity.id
- The id. May be null.