public class DefaultRegistry
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.spi.Registry, org.apache.camel.spi.LocalBeanRepositoryAware, 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 ThreadLocal<org.apache.camel.spi.BeanRepository> |
localRepository |
protected boolean |
localRepositoryEnabled |
protected List<org.apache.camel.spi.BeanRepository> |
repositories |
protected org.apache.camel.spi.Registry |
supplierRegistry |
| 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) |
void |
bind(String id,
Class<?> type,
Supplier<Object> bean) |
void |
bindAsPrototype(String id,
Class<?> type,
Supplier<Object> bean) |
protected void |
doStop() |
<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 |
org.apache.camel.spi.BeanRepository |
getLocalBeanRepository() |
List<org.apache.camel.spi.BeanRepository> |
getRepositories()
Gets the bean repositories.
|
org.apache.camel.spi.Registry |
getSupplierRegistry()
Gets the supplier
Registry |
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. |
void |
setLocalBeanRepository(org.apache.camel.spi.BeanRepository repository)
Sets a special local bean repository (ie thread local) that take precedence and will use first, if a bean exists.
|
void |
setSupplierRegistry(org.apache.camel.spi.Registry supplierRegistry)
To use a custom
Registry for suppliers. |
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doStart, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprotected org.apache.camel.CamelContext camelContext
protected final ThreadLocal<org.apache.camel.spi.BeanRepository> localRepository
protected volatile boolean localRepositoryEnabled
protected List<org.apache.camel.spi.BeanRepository> repositories
protected org.apache.camel.spi.Registry fallbackRegistry
protected org.apache.camel.spi.Registry supplierRegistry
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 void setLocalBeanRepository(org.apache.camel.spi.BeanRepository repository)
setLocalBeanRepository in interface org.apache.camel.spi.LocalBeanRepositoryAwarepublic org.apache.camel.spi.BeanRepository getLocalBeanRepository()
getLocalBeanRepository in interface org.apache.camel.spi.LocalBeanRepositoryAwarepublic org.apache.camel.spi.Registry getFallbackRegistry()
Registrypublic void setFallbackRegistry(org.apache.camel.spi.Registry fallbackRegistry)
Registry as fallback.public org.apache.camel.spi.Registry getSupplierRegistry()
Registrypublic void setSupplierRegistry(org.apache.camel.spi.Registry supplierRegistry)
Registry for suppliers.public org.apache.camel.CamelContext getCamelContext()
getCamelContext in interface org.apache.camel.CamelContextAwarepublic void setCamelContext(org.apache.camel.CamelContext camelContext)
setCamelContext in interface org.apache.camel.CamelContextAwarepublic 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.Registryorg.apache.camel.RuntimeCamelExceptionpublic void bind(String id, Class<?> type, Supplier<Object> bean) throws org.apache.camel.RuntimeCamelException
bind in interface org.apache.camel.spi.Registryorg.apache.camel.RuntimeCamelExceptionpublic void bindAsPrototype(String id, Class<?> type, Supplier<Object> bean) throws org.apache.camel.RuntimeCamelException
bindAsPrototype in interface org.apache.camel.spi.Registryorg.apache.camel.RuntimeCamelExceptionpublic Object lookupByName(String name)
lookupByName in interface org.apache.camel.spi.BeanRepositorypublic <T> T lookupByNameAndType(String name, Class<T> type)
lookupByNameAndType in interface org.apache.camel.spi.BeanRepositorypublic <T> Map<String,T> findByTypeWithName(Class<T> type)
findByTypeWithName in interface org.apache.camel.spi.BeanRepositorypublic <T> Set<T> findByType(Class<T> type)
findByType in interface org.apache.camel.spi.BeanRepositoryApache Camel