|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.camel.impl.ServiceSupport
org.apache.camel.impl.DefaultCamelContext
public class DefaultCamelContext
Represents the context used to configure routes and the policies to use.
| Constructor Summary | |
|---|---|
DefaultCamelContext()
|
|
DefaultCamelContext(Context jndiContext)
Creates the CamelContext using the given JNDI context as the
registry |
|
DefaultCamelContext(Registry registry)
Creates the CamelContext using the given registry |
|
| Method Summary | ||
|---|---|---|
void |
addComponent(String componentName,
Component component)
Adds a component to the context. |
|
Endpoint |
addEndpoint(String uri,
Endpoint endpoint)
Adds the endpoint to the context using the given URI. |
|
protected Endpoint |
addEndpointToRegistry(String uri,
Endpoint endpoint)
Strategy to add the given endpoint to the internal endpoint registry |
|
void |
addInterceptStrategy(InterceptStrategy interceptStrategy)
Adds the given interceptor strategy |
|
void |
addRegisterEndpointCallback(EndpointStrategy strategy)
Registers a callback to allow you to do custom
logic when an Endpoint is about to be registered to the CamelContext endpoint registry. |
|
void |
addRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
Adds a collection of route definitions to the context |
|
void |
addRoutes(RoutesBuilder builder)
Adds a collection of routes to this context using the given builder to build them |
|
void |
addService(Object object)
Adds a service, starting it so that it will be stopped with this context |
|
Endpoint |
addSingletonEndpoint(String uri,
Endpoint endpoint)
|
|
protected Endpoint |
convertBeanToEndpoint(String uri,
Object bean)
Strategy method for attempting to convert the bean from a Registry to an endpoint using
some kind of transformation or wrapper |
|
protected ComponentResolver |
createComponentResolver()
Lazily create a default implementation |
|
ConsumerTemplate |
createConsumerTemplate()
Creates a new ConsumerTemplate. |
|
protected Endpoint |
createEndpoint(String uri)
A pluggable strategy to allow an endpoint to be created without requiring a component to be its factory, such as for looking up the URI inside some Registry |
|
protected ExchangeConverter |
createExchangeConverter()
Lazily create a default implementation |
|
protected Injector |
createInjector()
Lazily create a default implementation |
|
ProducerTemplate |
createProducerTemplate()
Creates a new ProducerTemplate. |
|
protected Registry |
createRegistry()
Lazily create a default implementation |
|
protected TypeConverter |
createTypeConverter()
Lazily create a default implementation |
|
protected void |
doStart()
|
|
protected void |
doStop()
|
|
protected void |
forceLazyInitialization()
Lets force some lazy initialization to occur upfront before we start any components and create routes |
|
ClassResolver |
getClassResolver()
Returns the class resolver to be used for loading/lookup of classes. |
|
Component |
getComponent(String name)
Gets a component from the context by name. |
|
|
getComponent(String name,
Class<T> componentType)
Gets a component from the context by name and specifying the expected type of component. |
|
List<String> |
getComponentNames()
Gets a readonly list of names of the components currently registered |
|
ComponentResolver |
getComponentResolver()
|
|
Map<String,DataFormatDefinition> |
getDataFormats()
Gets the data formats that can be referenced in the routes. |
|
FactoryFinder |
getDefaultFactoryFinder()
Gets the default FactoryFinder which will be used for the loading the factory class from META-INF |
|
Long |
getDelay()
|
|
Endpoint |
getEndpoint(String uri)
Resolves the given URI to an Endpoint. |
|
|
getEndpoint(String name,
Class<T> endpointType)
Resolves the given name to an Endpoint of the specified type. |
|
protected String |
getEndpointKey(String uri,
Endpoint endpoint)
|
|
Map<String,Endpoint> |
getEndpointMap()
Returns a new Map containing all of the active endpoints with the key of the map being their unique key. |
|
Collection<Endpoint> |
getEndpoints()
Returns the collection of all registered endpoints. |
|
Collection<Endpoint> |
getEndpoints(String uri)
Returns the collection of all registered endpoints for a uri or an empty collection. |
|
ErrorHandlerBuilder |
getErrorHandlerBuilder()
Gets the default error handler builder which is inherited by the routes |
|
ExchangeConverter |
getExchangeConverter()
Returns the converter of exchanges from one type to another |
|
FactoryFinder |
getFactoryFinder(String path)
Gets the FactoryFinder which will be used for the loading the factory class from META-INF in the given path |
|
Boolean |
getHandleFault()
|
|
Injector |
getInjector()
Returns the injector used to instantiate objects by type |
|
List<InterceptStrategy> |
getInterceptStrategies()
Gets the interceptor strategies |
|
List<String> |
getLanguageNames()
Gets a readonly list with the names of the languages currently registered. |
|
LanguageResolver |
getLanguageResolver()
|
|
LifecycleStrategy |
getLifecycleStrategy()
Returns the lifecycle strategy used to handle lifecycle notification |
|
String |
getName()
Gets the name of the this context. |
|
Component |
getOrCreateComponent(String componentName,
Callable<Component> factory)
Gets the a previously added component by name or lazily creates the component using the factory Callback. |
|
PackageScanClassResolver |
getPackageScanClassResolver()
Returns the package scanning class resolver |
|
ServicePool<Endpoint,Producer> |
getProducerServicePool()
Gets the service pool for Producer pooling. |
|
Map<String,String> |
getProperties()
Gets the properties that can be referenced in the camel context |
|
Registry |
getRegistry()
Returns the registry used to lookup components by name and type such as the Spring ApplicationContext, JNDI or the OSGi Service Registry |
|
List<RouteDefinition> |
getRouteDefinitions()
Returns a list of the current route definitions |
|
List<Route> |
getRoutes()
Returns the current routes in this context |
|
protected Map<String,RouteService> |
getRouteServices()
|
|
ServiceStatus |
getRouteStatus(RouteDefinition route)
Returns the current status of the given route |
|
ServiceStatus |
getRouteStatus(String key)
Returns the status of the service of the given ID or null if there is no service created yet |
|
Collection<Endpoint> |
getSingletonEndpoints()
Returns the collection of all registered singleton endpoints. |
|
Boolean |
getStreamCaching()
|
|
Boolean |
getTrace()
|
|
TypeConverter |
getTypeConverter()
Returns the type converter used to coerce types from one type to another |
|
TypeConverterRegistry |
getTypeConverterRegistry()
Returns the type converter registry where type converters can be added or looked up |
|
boolean |
isAutoCreateComponents()
|
|
long |
isDelayEnabled()
Returns the delay in millis if delaying has been enabled. |
|
boolean |
isHandleFaultEnabled()
Returns true if handle fault has been enabled |
|
boolean |
isStreamCacheEnabled()
Returns true if tracing has been enabled or disabled via the setTrace(Boolean) method
or it has not been specified then default to the camel.streamCache system property |
|
boolean |
isTraceEnabled()
Returns true if tracing has been enabled |
|
Component |
removeComponent(String componentName)
Removes a previously added component. |
|
Collection<Endpoint> |
removeEndpoints(String uri)
Removes all endpoints with the given URI |
|
void |
removeRouteDefinition(RouteDefinition routeDefinition)
|
|
boolean |
removeRouteDefinition(String key)
Removes the route definition with the given key. |
|
void |
removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
Removes a collection of route definitions from the context - stopping any previously running routes if any of them are actively running |
|
Endpoint |
removeSingletonEndpoint(String uri)
|
|
Language |
resolveLanguage(String language)
Resolves a language for creating expressions |
|
void |
setAutoCreateComponents(boolean autoCreateComponents)
|
|
void |
setClassResolver(ClassResolver classResolver)
Sets the class resolver to be use |
|
void |
setComponentResolver(ComponentResolver componentResolver)
|
|
void |
setDataFormats(Map<String,DataFormatDefinition> dataFormats)
Sets the data formats that can be referenced in the routes. |
|
void |
setDelay(Long delay)
|
|
void |
setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
Sets the default error handler builder which is inherited by the routes |
|
void |
setExchangeConverter(ExchangeConverter exchangeConverter)
|
|
void |
setFactoryFinderResolver(FactoryFinderResolver resolver)
Sets the factory finder resolver to use. |
|
void |
setHandleFault(Boolean handleFault)
|
|
void |
setInjector(Injector injector)
|
|
void |
setInterceptStrategies(List<InterceptStrategy> interceptStrategies)
|
|
void |
setJndiContext(Context jndiContext)
Sets the registry to the given JNDI context |
|
void |
setLanguageResolver(LanguageResolver languageResolver)
|
|
void |
setLifecycleStrategy(LifecycleStrategy lifecycleStrategy)
|
|
void |
setName(String name)
Sets the name of the this context. |
|
void |
setPackageScanClassResolver(PackageScanClassResolver packageScanClassResolver)
Sets the package scanning class resolver to use |
|
void |
setProducerServicePool(ServicePool<Endpoint,Producer> producerServicePool)
Sets a pluggable service pool to use for Producer pooling. |
|
void |
setProperties(Map<String,String> properties)
Sets the properties that can be referenced in the camel context |
|
void |
setRegistry(Registry registry)
|
|
void |
setRoutes(List<Route> routes)
|
|
void |
setStreamCaching(Boolean cache)
Sets whether stream caching is enabled or not (default is disabled). |
|
void |
setTrace(Boolean trace)
|
|
void |
setTracing(Boolean tracing)
Sets whether tracing is enabled or not (default is disabled). |
|
void |
setTypeConverter(TypeConverter typeConverter)
|
|
void |
setTypeConverterRegistry(TypeConverterRegistry typeConverterRegistry)
|
|
protected boolean |
shouldStartRoutes()
Should we start newly added routes? |
|
void |
start()
Starts the service |
|
void |
startRoute(RouteDefinition route)
Starts the given route if it has been previously stopped |
|
protected void |
startRouteDefinitions(Collection<RouteDefinition> list)
|
|
protected void |
startRouteService(RouteService routeService)
Starts the given route service |
|
void |
stopRoute(RouteDefinition route)
Stops the given route. |
|
void |
stopRoute(String key)
Stops the route denoted by the given RouteType id |
|
String |
toString()
|
|
| Methods inherited from class org.apache.camel.impl.ServiceSupport |
|---|
addChildService, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, removeChildService, stop |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.camel.Service |
|---|
stop |
| Constructor Detail |
|---|
public DefaultCamelContext()
public DefaultCamelContext(Context jndiContext)
CamelContext using the given JNDI context as the
registry
public DefaultCamelContext(Registry registry)
CamelContext using the given registry
| Method Detail |
|---|
public String getName()
CamelContext
getName in interface CamelContextpublic void setName(String name)
public void addComponent(String componentName,
Component component)
CamelContext
addComponent in interface CamelContextcomponentName - the name the component is registered ascomponent - the componentpublic Component getComponent(String name)
CamelContext
getComponent in interface CamelContextname - the name of the component
public <T extends Component> T getComponent(String name,
Class<T> componentType)
CamelContext
getComponent in interface CamelContextname - the name to lookupcomponentType - the expected type
public Component removeComponent(String componentName)
CamelContext
removeComponent in interface CamelContextcomponentName - the component name to remove
public Component getOrCreateComponent(String componentName,
Callable<Component> factory)
CamelContext
getOrCreateComponent in interface CamelContextcomponentName - the name of the componentfactory - used to create a new component instance if the component was not previously added.
public Collection<Endpoint> getEndpoints()
CamelContext
getEndpoints in interface CamelContextpublic Map<String,Endpoint> getEndpointMap()
CamelContext
getEndpointMap in interface CamelContextpublic Collection<Endpoint> getEndpoints(String uri)
CamelContext
getEndpoints in interface CamelContexturi - the URI of the endpoints
public Collection<Endpoint> getSingletonEndpoints()
CamelContext
getSingletonEndpoints in interface CamelContext
public Endpoint addEndpoint(String uri,
Endpoint endpoint)
throws Exception
CamelContext
addEndpoint in interface CamelContexturi - the URI to be used to resolve this endpointendpoint - the endpoint to be added to the context
Exception - if the new endpoint could not be started or the old
singleton endpoint could not be stopped
public Collection<Endpoint> removeEndpoints(String uri)
throws Exception
CamelContext
removeEndpoints in interface CamelContexturi - the URI to be used to remove
Exception - if at least one endpoint could not be stopped
public Endpoint addSingletonEndpoint(String uri,
Endpoint endpoint)
throws Exception
Exception
public Endpoint removeSingletonEndpoint(String uri)
throws Exception
Exceptionpublic Endpoint getEndpoint(String uri)
CamelContextEndpoint. If the URI has a singleton endpoint
registered, then the singleton is returned. Otherwise, a new Endpoint is created
and if the endpoint is a singleton it is registered as a singleton endpoint.
getEndpoint in interface CamelContexturi - the URI of the endpoint
public <T extends Endpoint> T getEndpoint(String name,
Class<T> endpointType)
CamelContextEndpoint of the specified type.
If the name has a singleton endpoint registered, then the singleton is returned.
Otherwise, a new Endpoint is created and if the endpoint is a
singleton it is registered as a singleton endpoint.
getEndpoint in interface CamelContextname - the name of the endpointendpointType - the expected type
public void addRegisterEndpointCallback(EndpointStrategy strategy)
CamelContextcallback to allow you to do custom
logic when an Endpoint is about to be registered to the CamelContext endpoint registry.
When a callback is added it will be executed on the already registered endpoints allowing you to catch-up
addRegisterEndpointCallback in interface CamelContextstrategy - callback to be invoked
protected Endpoint addEndpointToRegistry(String uri,
Endpoint endpoint)
uri - uri of endpointendpoint - the endpoint to add
public List<Route> getRoutes()
CamelContext
getRoutes in interface CamelContextpublic void setRoutes(List<Route> routes)
public void addRoutes(RoutesBuilder builder)
throws Exception
CamelContext
addRoutes in interface CamelContextbuilder - the builder which will create the routes and add them to this context
Exception - if the routes could not be created for whatever reason
public void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
throws Exception
CamelContext
addRouteDefinitions in interface CamelContextrouteDefinitions - the route definitions to add
Exception - if the route definition could not be created for whatever reasonpublic boolean removeRouteDefinition(String key)
public void removeRouteDefinitions(Collection<RouteDefinition> routeDefinitions)
throws Exception
CamelContext
removeRouteDefinitions in interface CamelContextrouteDefinitions - route definitions
Exception - if the route definition could not be removed for whatever reason
public void removeRouteDefinition(RouteDefinition routeDefinition)
throws Exception
Exceptionpublic ServiceStatus getRouteStatus(RouteDefinition route)
CamelContext
getRouteStatus in interface CamelContextroute - the route
public ServiceStatus getRouteStatus(String key)
public void startRoute(RouteDefinition route)
throws Exception
CamelContext
startRoute in interface CamelContextroute - the route to start
Exception - is thrown if the route could not be started for whatever reason
public void stopRoute(RouteDefinition route)
throws Exception
CamelContextCamelContext.getRouteDefinitions()
unless you use the CamelContext.removeRouteDefinitions(java.util.Collection)
stopRoute in interface CamelContextroute - the route to stop
Exception - is thrown if the route could not be stopped for whatever reason
public void stopRoute(String key)
throws Exception
Exception
public void addService(Object object)
throws Exception
Exceptionpublic Language resolveLanguage(String language)
CamelContext
resolveLanguage in interface CamelContextlanguage - name of the language
public ExchangeConverter getExchangeConverter()
CamelContext
getExchangeConverter in interface CamelContextpublic void setExchangeConverter(ExchangeConverter exchangeConverter)
public TypeConverter getTypeConverter()
CamelContext
getTypeConverter in interface CamelContextpublic void setTypeConverter(TypeConverter typeConverter)
public TypeConverterRegistry getTypeConverterRegistry()
CamelContext
getTypeConverterRegistry in interface CamelContextpublic void setTypeConverterRegistry(TypeConverterRegistry typeConverterRegistry)
public Injector getInjector()
CamelContext
getInjector in interface CamelContextpublic void setInjector(Injector injector)
public ComponentResolver getComponentResolver()
public void setComponentResolver(ComponentResolver componentResolver)
public LanguageResolver getLanguageResolver()
public void setLanguageResolver(LanguageResolver languageResolver)
public boolean isAutoCreateComponents()
public void setAutoCreateComponents(boolean autoCreateComponents)
public Registry getRegistry()
CamelContext
getRegistry in interface CamelContextpublic void setJndiContext(Context jndiContext)
jndiContext - is the JNDI context to use as the registrysetRegistry(org.apache.camel.spi.Registry)public void setRegistry(Registry registry)
public LifecycleStrategy getLifecycleStrategy()
CamelContext
getLifecycleStrategy in interface CamelContextpublic void setLifecycleStrategy(LifecycleStrategy lifecycleStrategy)
public List<RouteDefinition> getRouteDefinitions()
CamelContext
getRouteDefinitions in interface CamelContextpublic List<InterceptStrategy> getInterceptStrategies()
CamelContext
getInterceptStrategies in interface CamelContextpublic void setInterceptStrategies(List<InterceptStrategy> interceptStrategies)
public void addInterceptStrategy(InterceptStrategy interceptStrategy)
CamelContext
addInterceptStrategy in interface CamelContextinterceptStrategy - the strategypublic boolean isStreamCacheEnabled()
setTrace(Boolean) method
or it has not been specified then default to the camel.streamCache system property
public Boolean getStreamCaching()
public void setStreamCaching(Boolean cache)
CamelContext
setStreamCaching in interface CamelContextcache - whether stream caching is enabled or notpublic void setTracing(Boolean tracing)
CamelContextthis#addInterceptStrategy(org.apache.camel.spi.InterceptStrategy) if you
want to add a custom Tracer where you
can custome the tracing options and formatting as you like.
setTracing in interface CamelContexttracing - whether tracing is enabled or not.public boolean isHandleFaultEnabled()
public Boolean getHandleFault()
public void setHandleFault(Boolean handleFault)
public boolean isTraceEnabled()
public Boolean getTrace()
public void setTrace(Boolean trace)
public long isDelayEnabled()
public Long getDelay()
public void setDelay(Long delay)
public ProducerTemplate createProducerTemplate()
CamelContext
createProducerTemplate in interface CamelContextpublic ConsumerTemplate createConsumerTemplate()
CamelContext
createConsumerTemplate in interface CamelContextpublic ErrorHandlerBuilder getErrorHandlerBuilder()
CamelContext
getErrorHandlerBuilder in interface CamelContextpublic void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
setErrorHandlerBuilder in interface CamelContexterrorHandlerBuilder - the builderpublic void setProducerServicePool(ServicePool<Endpoint,Producer> producerServicePool)
CamelContextProducer pooling.
setProducerServicePool in interface CamelContextproducerServicePool - the poolpublic ServicePool<Endpoint,Producer> getProducerServicePool()
CamelContextProducer pooling.
getProducerServicePool in interface CamelContext
public void start()
throws Exception
Service
start in interface Servicestart in class ServiceSupportException
protected void doStart()
throws Exception
doStart in class ServiceSupportException
protected void doStop()
throws Exception
doStop in class ServiceSupportException
protected void startRouteDefinitions(Collection<RouteDefinition> list)
throws Exception
Exception
protected void startRouteService(RouteService routeService)
throws Exception
Exceptionprotected void forceLazyInitialization()
protected ExchangeConverter createExchangeConverter()
protected TypeConverter createTypeConverter()
protected Injector createInjector()
protected ComponentResolver createComponentResolver()
protected Registry createRegistry()
protected Endpoint createEndpoint(String uri)
Registry
uri - the uri for the endpoint to be created
protected Endpoint convertBeanToEndpoint(String uri,
Object bean)
Registry to an endpoint using
some kind of transformation or wrapper
uri - the uri for the endpoint (and name in the registry)bean - the bean to be converted to an endpoint, which will be not null
protected boolean shouldStartRoutes()
public void setDataFormats(Map<String,DataFormatDefinition> dataFormats)
CamelContext
setDataFormats in interface CamelContextdataFormats - the data formatspublic Map<String,DataFormatDefinition> getDataFormats()
CamelContext
getDataFormats in interface CamelContextpublic Map<String,String> getProperties()
CamelContext
getProperties in interface CamelContextpublic void setProperties(Map<String,String> properties)
CamelContext
setProperties in interface CamelContextproperties - propertiespublic FactoryFinder getDefaultFactoryFinder()
CamelContext
getDefaultFactoryFinder in interface CamelContextpublic void setFactoryFinderResolver(FactoryFinderResolver resolver)
CamelContext
setFactoryFinderResolver in interface CamelContextresolver - the factory finder resolver
public FactoryFinder getFactoryFinder(String path)
throws NoFactoryAvailableException
CamelContext
getFactoryFinder in interface CamelContextpath - the META-INF path
NoFactoryAvailableException - is thrown if a factory could not be foundpublic ClassResolver getClassResolver()
CamelContext
getClassResolver in interface CamelContextpublic void setClassResolver(ClassResolver classResolver)
CamelContext
setClassResolver in interface CamelContextclassResolver - the resolverpublic PackageScanClassResolver getPackageScanClassResolver()
CamelContext
getPackageScanClassResolver in interface CamelContextpublic void setPackageScanClassResolver(PackageScanClassResolver packageScanClassResolver)
CamelContext
setPackageScanClassResolver in interface CamelContextpackageScanClassResolver - the resolverpublic List<String> getComponentNames()
CamelContext
getComponentNames in interface CamelContextpublic List<String> getLanguageNames()
CamelContext
getLanguageNames in interface CamelContext
protected String getEndpointKey(String uri,
Endpoint endpoint)
protected Map<String,RouteService> getRouteServices()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||