Interface BeanDirectory

All Known Subinterfaces:
BeanRegistry, RemoteDirectory
All Known Implementing Classes:
LinkedBeanRegistry, MBeanDirectory, SimpleBeanDirectory, SimpleBeanRegistry

public interface BeanDirectory
Something that is able to provide components by a path.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> Iterable<T>
    Get all objects in the directory of the required type.
    Provide all the Ids in the directory.
    Find the id for the given component.
    lookup(String path)
    Get the value which is either a bean or the property of a bean.
    <T> T
    lookup(String path, Class<T> required)
    Get a value, as above, but also convert it into to given type.
  • Method Details

    • lookup

      Object lookup(String path) throws ArooaPropertyException
      Get the value which is either a bean or the property of a bean.

      The path can be either:

      • The id of a bean e.g. mybean
      • A simple property of a bean e.g. mybean.simple
      • An indexed property of a bean e.g. mybean.indexed[1]
      • A mapped property of a bean e.g. mybean.mapped(key)
      • A nested property of a bean e.g. mybean.complex.simple
      • A nested beanownerid/mybean
      • Most combinations of the above.
      Parameters:
      path - The path.
      Returns:
      The resultant value or null.
      Throws:
      ArooaPropertyException - If property access fails.
    • lookup

      <T> T lookup(String path, Class<T> required) throws ArooaPropertyException, ArooaConversionException
      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.

      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.
      ArooaPropertyException - If property access fails.
    • getIdFor

      String getIdFor(Object bean)
      Find the id for the given component.
      Parameters:
      bean - The component.
      Returns:
      The id or null if none can be found.
    • getAllIds

      default Collection<String> getAllIds()
      Provide all the Ids in the directory. This was added to support Scripting with Graalvm. It isn't implemented everywhere yet, so may throw an UnsupportedOperationException for a bit.
      Returns:
      A Collection of Ids. Never null.
      Since:
      1.6
    • getAllByType

      <T> Iterable<T> getAllByType(Class<T> type)
      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...

      Type Parameters:
      T - The required type.
      Parameters:
      type - The type.
      Returns:
      An Iterable for matches. Never null.