Class DefaultRegistry

  • All Implemented Interfaces:
    org.apache.camel.CamelContextAware, org.apache.camel.spi.BeanRepository, org.apache.camel.spi.Registry

    public class DefaultRegistry
    extends Object
    implements org.apache.camel.spi.Registry, org.apache.camel.CamelContextAware
    The default Registry which supports using a given first-choice repository to lookup the beans, such as Spring, JNDI, OSGi etc. And to use a secondary SimpleRegistry as the fallback repository to lookup and bind beans.

    Notice that beans in the fallback registry are not managed by the first-choice registry, so these beans may not support dependency injection and other features that the first-choice registry may offer.

    • Field Detail

      • camelContext

        protected org.apache.camel.CamelContext camelContext
      • repositories

        protected List<org.apache.camel.spi.BeanRepository> repositories
      • fallbackRegistry

        protected org.apache.camel.spi.Registry fallbackRegistry
    • Constructor Detail

      • DefaultRegistry

        public DefaultRegistry​(org.apache.camel.spi.BeanRepository... repositories)
        Creates a registry that uses the given BeanRepository as first choice bean repository to lookup beans. Will fallback and use SimpleRegistry as fallback registry if the beans cannot be found in the first choice bean repository. The fallback registry can customized via setFallbackRegistry(Registry).
        Parameters:
        repositories - the first choice repositories such as Spring, JNDI, OSGi etc.
      • DefaultRegistry

        public DefaultRegistry​(Collection<org.apache.camel.spi.BeanRepository> repositories)
        Creates a registry that uses the given BeanRepository as first choice bean repository to lookup beans. Will fallback and use SimpleRegistry as fallback registry if the beans cannot be found in the first choice bean repository. The fallback registry can customized via setFallbackRegistry(Registry).
        Parameters:
        repositories - the first choice repositories such as Spring, JNDI, OSGi etc.
    • Method Detail

      • getFallbackRegistry

        public org.apache.camel.spi.Registry getFallbackRegistry()
        Gets the fallback Registry
      • setFallbackRegistry

        public void setFallbackRegistry​(org.apache.camel.spi.Registry fallbackRegistry)
        To use a custom Registry as fallback.
      • getCamelContext

        public org.apache.camel.CamelContext getCamelContext()
        Specified by:
        getCamelContext in interface org.apache.camel.CamelContextAware
      • setCamelContext

        public void setCamelContext​(org.apache.camel.CamelContext camelContext)
        Specified by:
        setCamelContext in interface org.apache.camel.CamelContextAware
      • getRepositories

        public List<org.apache.camel.spi.BeanRepository> getRepositories()
        Gets the bean repositories.
        Returns:
        the bean repositories, or null if none are in use.
      • bind

        public void bind​(String id,
                         Class<?> type,
                         Object bean)
                  throws org.apache.camel.RuntimeCamelException
        Specified by:
        bind in interface org.apache.camel.spi.Registry
        Throws:
        org.apache.camel.RuntimeCamelException
      • lookupByName

        public Object lookupByName​(String name)
        Specified by:
        lookupByName in interface org.apache.camel.spi.BeanRepository
      • lookupByNameAndType

        public <T> T lookupByNameAndType​(String name,
                                         Class<T> type)
        Specified by:
        lookupByNameAndType in interface org.apache.camel.spi.BeanRepository
      • findByTypeWithName

        public <T> Map<String,​T> findByTypeWithName​(Class<T> type)
        Specified by:
        findByTypeWithName in interface org.apache.camel.spi.BeanRepository
      • findByType

        public <T> Set<T> findByType​(Class<T> type)
        Specified by:
        findByType in interface org.apache.camel.spi.BeanRepository