public class DefaultRegistry extends Object implements org.apache.camel.spi.Registry, org.apache.camel.CamelContextAware
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.Modifier and Type | Field and Description |
---|---|
protected org.apache.camel.CamelContext |
camelContext |
protected org.apache.camel.spi.Registry |
fallbackRegistry |
protected List<org.apache.camel.spi.BeanRepository> |
repositories |
Constructor and Description |
---|
DefaultRegistry()
Creates a default registry that uses
SimpleRegistry as the fallback registry. |
DefaultRegistry(org.apache.camel.spi.BeanRepository... repositories)
Creates a registry that uses the given
BeanRepository as first choice bean repository to lookup beans. |
DefaultRegistry(Collection<org.apache.camel.spi.BeanRepository> repositories)
Creates a registry that uses the given
BeanRepository as first choice bean repository to lookup beans. |
Modifier and Type | Method and Description |
---|---|
void |
bind(String id,
Class<?> type,
Object bean) |
<T> Set<T> |
findByType(Class<T> type) |
<T> Map<String,T> |
findByTypeWithName(Class<T> type) |
org.apache.camel.CamelContext |
getCamelContext() |
org.apache.camel.spi.Registry |
getFallbackRegistry()
Gets the fallback
Registry |
List<org.apache.camel.spi.BeanRepository> |
getRepositories()
Gets the bean repositories.
|
Object |
lookupByName(String name) |
<T> T |
lookupByNameAndType(String name,
Class<T> type) |
void |
setCamelContext(org.apache.camel.CamelContext camelContext) |
void |
setFallbackRegistry(org.apache.camel.spi.Registry fallbackRegistry)
To use a custom
Registry as fallback. |
protected org.apache.camel.CamelContext camelContext
protected List<org.apache.camel.spi.BeanRepository> repositories
protected org.apache.camel.spi.Registry fallbackRegistry
public DefaultRegistry()
SimpleRegistry
as the fallback registry.
The fallback registry can customized via setFallbackRegistry(Registry)
.public DefaultRegistry(org.apache.camel.spi.BeanRepository... repositories)
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)
.repositories
- the first choice repositories such as Spring, JNDI, OSGi etc.public DefaultRegistry(Collection<org.apache.camel.spi.BeanRepository> repositories)
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)
.repositories
- the first choice repositories such as Spring, JNDI, OSGi etc.public org.apache.camel.spi.Registry getFallbackRegistry()
Registry
public void setFallbackRegistry(org.apache.camel.spi.Registry fallbackRegistry)
Registry
as fallback.public org.apache.camel.CamelContext getCamelContext()
getCamelContext
in interface org.apache.camel.CamelContextAware
public void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext
in interface org.apache.camel.CamelContextAware
public List<org.apache.camel.spi.BeanRepository> getRepositories()
public void bind(String id, Class<?> type, Object bean) throws org.apache.camel.RuntimeCamelException
bind
in interface org.apache.camel.spi.Registry
org.apache.camel.RuntimeCamelException
public Object lookupByName(String name)
lookupByName
in interface org.apache.camel.spi.BeanRepository
public <T> T lookupByNameAndType(String name, Class<T> type)
lookupByNameAndType
in interface org.apache.camel.spi.BeanRepository
public <T> Map<String,T> findByTypeWithName(Class<T> type)
findByTypeWithName
in interface org.apache.camel.spi.BeanRepository
Apache Camel