Package org.oddjob.arooa.registry
Class SimpleComponentPool
java.lang.Object
org.oddjob.arooa.registry.SimpleComponentPool
- All Implemented Interfaces:
ComponentPool
An simple implementation of a
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.
- Author:
- rob
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionProvide a way of iterating over all trinities.voidConfigure the component.contextFor(Object either) Get the componentsArooaContext.Provide the Id for either a component or it's proxy.registerComponent(ComponentTrinity componentTrinity, String id) Register aComponentTrinity.booleanRemove a component.voidPossibly save the component to a persistent store, if everything is in place for this to happen.trinityFor(Object either) Get theComponentTrinityfor either the component or proxy.trinityForContext(ArooaContext context) Get theComponentTrinityfor the givenArooaContext.trinityForId(String id) Provide theComponentTrinityfor a given id, if possible.
-
Constructor Details
-
SimpleComponentPool
public SimpleComponentPool()
-
-
Method Details
-
configure
Description copied from interface:ComponentPoolConfigure the component. The is a shortcut method equivalent tocontextFor(component).getRuntime().configure().- Specified by:
configurein interfaceComponentPool- Parameters:
component- The component or it's proxy.- Throws:
ArooaConfigurationException
-
save
Description copied from interface:ComponentPoolPossibly save the component to a persistent store, if everything is in place for this to happen.If a
ComponentPersisteris in operation and the component was registered with an id then the ComponentPersister is invoked with the component.- Specified by:
savein interfaceComponentPool- Parameters:
component- A component or it's proxy.- Throws:
ComponentPersistException
-
remove
Description copied from interface:ComponentPoolRemove a component.- Specified by:
removein interfaceComponentPool- Parameters:
either- A component or it's proxy.- Returns:
- true if the component was removed.
- Throws:
ComponentPersistException
-
contextFor
Description copied from interface:ComponentPoolGet the componentsArooaContext.- Specified by:
contextForin interfaceComponentPool- Parameters:
either- The component or the proxy.- Returns:
- The context or null if the component/proxy is not in this pool.
-
trinityForContext
Description copied from interface:ComponentPoolGet theComponentTrinityfor the givenArooaContext.This is required for
ContextHierarchyServiceFinder.- Specified by:
trinityForContextin interfaceComponentPool- Parameters:
context- A context;- Returns:
- The trinity or null.
-
trinityFor
Description copied from interface:ComponentPoolGet theComponentTrinityfor either the component or proxy.- Specified by:
trinityForin interfaceComponentPool- Parameters:
either- Either the component or the proxy.- Returns:
- The component trinity or null if it can't be found.
-
trinityForId
Description copied from interface:ComponentPoolProvide theComponentTrinityfor a given id, if possible.- Specified by:
trinityForIdin interfaceComponentPool- Parameters:
id- The id.- Returns:
- The trinity, or null if none exists for the given id.
-
getIdFor
Description copied from interface:ComponentPoolProvide the Id for either a component or it's proxy.- Specified by:
getIdForin interfaceComponentPool- 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.
-
allTrinities
Description copied from interface:ComponentPoolProvide a way of iterating over all trinities.- Specified by:
allTrinitiesin interfaceComponentPool- Returns:
- An Iterable of trinities. Will never be null.
-
registerComponent
Description copied from interface:ComponentPoolRegister aComponentTrinity.- Specified by:
registerComponentin interfaceComponentPool- Parameters:
componentTrinity- The trinity.id- The id. May be null.- Returns:
- The new id if one was assigned.
-