Interface BeanRepository

All Known Subinterfaces:
Registry

public interface BeanRepository
Represents a bean repository used to lookup components by name and type. This allows Camel to plugin to third-party bean repositories such as Spring, JNDI, OSGi.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> Set<T>
    findByType(Class<T> type)
    Finds beans in the registry by their type.
    <T> Map<String,T>
    Finds beans in the registry by their type.
    default <T> T
    Finds the bean by type, if there is exactly only one instance of the bean
    Looks up a bean in the registry based purely on name, returning the bean or null if it could not be found.
    <T> T
    Looks up a bean in the registry, returning the bean or null if it could not be found.
    default <T> T
    Finds the bean by type, if there is exactly only one instance of the bean
    default Object
    unwrap(Object value)
    Strategy to wrap the value to be stored in the registry.
  • Method Details

    • lookupByName

      Object lookupByName(String name)
      Looks up a bean in the registry based purely on name, returning the bean or null if it could not be found.

      Important: Multiple beans of different types may be bound with the same name, and its encouraged to use the lookupByNameAndType(String, Class) to lookup the bean with a specific type, or to use any of the find methods.

      Parameters:
      name - the name of the bean
      Returns:
      the bean from the registry or null if it could not be found
    • lookupByNameAndType

      <T> T lookupByNameAndType(String name, Class<T> type)
      Looks up a bean in the registry, returning the bean or null if it could not be found.
      Parameters:
      name - the name of the bean
      type - the type of the required bean
      Returns:
      the bean from the registry or null if it could not be found
    • findByTypeWithName

      <T> Map<String,T> findByTypeWithName(Class<T> type)
      Finds beans in the registry by their type.
      Parameters:
      type - the type of the beans
      Returns:
      the types found, with their bean ids as the key. Returns an empty Map if none found.
    • findByType

      <T> Set<T> findByType(Class<T> type)
      Finds beans in the registry by their type.
      Parameters:
      type - the type of the beans
      Returns:
      the types found. Returns an empty Set if none found.
    • findSingleByType

      default <T> T findSingleByType(Class<T> type)
      Finds the bean by type, if there is exactly only one instance of the bean
      Parameters:
      type - the type of the beans
      Returns:
      the single bean instance, or null if none found or there are more than one bean of the given type.
    • mandatoryFindSingleByType

      default <T> T mandatoryFindSingleByType(Class<T> type)
      Finds the bean by type, if there is exactly only one instance of the bean
      Parameters:
      type - the type of the beans
      Returns:
      the single bean instance, or throws NoSuchBeanTypeException if not exactly one bean was found.
    • unwrap

      default Object unwrap(Object value)
      Strategy to wrap the value to be stored in the registry.
      Parameters:
      value - the value
      Returns:
      the value to return