org.oddjob.arooa.registry
Class LinkedBeanRegistry

java.lang.Object
  extended by org.oddjob.arooa.registry.SimpleBeanRegistry
      extended by org.oddjob.arooa.registry.LinkedBeanRegistry
All Implemented Interfaces:
BeanDirectory, BeanRegistry

public class LinkedBeanRegistry
extends SimpleBeanRegistry


Field Summary
 
Fields inherited from class org.oddjob.arooa.registry.SimpleBeanRegistry
RESERVED_CHARACTERS
 
Constructor Summary
LinkedBeanRegistry(BeanDirectory existingDirectory, PropertyAccessor propertyAccessor, ArooaConverter converter)
           
 
Method Summary
<T> Iterable<T>
getAllByType(Class<T> type)
          Get all objects in the directory of the required type.
 String getIdFor(Object bean)
          Find the id for the given component.
 Object lookup(String path)
          First try our local registry then the parent.
<T> T
lookup(String path, Class<T> required)
          Get a value, as above, but also convert it into to given type.
 
Methods inherited from class org.oddjob.arooa.registry.SimpleBeanRegistry
register, remove, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinkedBeanRegistry

public LinkedBeanRegistry(BeanDirectory existingDirectory,
                          PropertyAccessor propertyAccessor,
                          ArooaConverter converter)
Method Detail

lookup

public Object lookup(String path)
First try our local registry then the parent.

Specified by:
lookup in interface BeanDirectory
Overrides:
lookup in class SimpleBeanRegistry
Returns:
The resultant value or null.

lookup

public <T> T lookup(String path,
                    Class<T> required)
         throws ArooaConversionException
Description copied from interface: BeanDirectory
Get a value, as above, but also convert it into to given type.

Conversion in the directory is required when the client code has no access to the converters required, for instance in a nested Oddjob.

Specified by:
lookup in interface BeanDirectory
Overrides:
lookup in class SimpleBeanRegistry
Type Parameters:
T - The required type.
Parameters:
path - The full path
required - The required type.
Returns:
An object of the required type or null if none can be found.
Throws:
ArooaConversionException - If an object can be found but it can't be converted into the required type.

getIdFor

public String getIdFor(Object bean)
Description copied from class: SimpleBeanRegistry
Find the id for the given component.

Specified by:
getIdFor in interface BeanDirectory
Overrides:
getIdFor in class SimpleBeanRegistry
Parameters:
bean - The component.
Returns:
The id or null if none can be found.

getAllByType

public <T> Iterable<T> getAllByType(Class<T> type)
Description copied from interface: BeanDirectory
Get all objects in the directory of the required type.

Why an Iterable not a Collection or Set? It was thought that this would force read only use. Maybe it should be an array...

Specified by:
getAllByType in interface BeanDirectory
Overrides:
getAllByType in class SimpleBeanRegistry
Type Parameters:
T - The required type.
Parameters:
type - The type.
Returns:
An Iterable for matches. Never null.