public class SimpleBeanRegistry extends java.lang.Object implements BeanRegistry
This class is thread safe. Beans may be registered and retrieved by different threads.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
RESERVED_CHARACTERS |
Constructor and Description |
---|
SimpleBeanRegistry()
Constructor for a local registry.
|
SimpleBeanRegistry(PropertyAccessor propertyAccessor,
ArooaConverter converter) |
Modifier and Type | Method and Description |
---|---|
<T> java.lang.Iterable<T> |
getAllByType(java.lang.Class<T> type)
Get all objects in the directory of the required type.
|
java.util.Collection<java.lang.String> |
getAllIds()
Provide all the Ids in the directory.
|
java.lang.String |
getIdFor(java.lang.Object component)
Find the id for the given component.
|
java.lang.Object |
lookup(java.lang.String path)
Get the value which is either a bean or the property of a
bean.
|
<T> T |
lookup(java.lang.String path,
java.lang.Class<T> required)
Get a value, as above, but also convert it into to given
type.
|
void |
register(java.lang.String id,
java.lang.Object component)
Register an object.
|
void |
remove(java.lang.Object component)
Remove a component from the registry if it exists.
|
java.lang.String |
toString() |
public static final java.lang.String RESERVED_CHARACTERS
public SimpleBeanRegistry()
public SimpleBeanRegistry(PropertyAccessor propertyAccessor, ArooaConverter converter)
public <T> java.lang.Iterable<T> getAllByType(java.lang.Class<T> type)
BeanDirectory
Why an Iterable not a Collection or Set? It was thought that this would force read only use. Maybe it should be an array...
getAllByType
in interface BeanDirectory
T
- The required type.type
- The type.public void register(java.lang.String id, java.lang.Object component) throws InvalidIdException
register
in interface BeanRegistry
id
- The id of the object.component
- The object.InvalidIdException
public java.lang.Object lookup(java.lang.String path) throws ArooaPropertyException
BeanDirectory
The path can be either:
lookup
in interface BeanDirectory
path
- The path.ArooaPropertyException
- If property access fails.public <T> T lookup(java.lang.String path, java.lang.Class<T> required) throws ArooaPropertyException, ArooaConversionException
BeanDirectory
Conversion in the directory is required when the client code has no access to the converters required, for instance in a nested Oddjob.
lookup
in interface BeanDirectory
T
- The required type.path
- The full pathrequired
- The required type.ArooaPropertyException
- If property access fails.ArooaConversionException
- If an object can be found but
it can't be converted into the required type.public java.lang.String getIdFor(java.lang.Object component)
getIdFor
in interface BeanDirectory
component
- The component.public java.util.Collection<java.lang.String> getAllIds()
BeanDirectory
UnsupportedOperationException
for a bit.getAllIds
in interface BeanDirectory
public void remove(java.lang.Object component)
remove
in interface BeanRegistry
component
- The component.public java.lang.String toString()
toString
in class java.lang.Object