|
||||||||||
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. |
|
void |
addInterceptStrategy(InterceptStrategy interceptStrategy)
Adds the given interceptor strategy |
|
void |
addRouteDefinitions(Collection<RouteType> routeDefinitions)
Adds a collection of route definitions to the context |
|
void |
addRoutes(Collection<Route> routes)
Adds a collection of routes to this context |
|
void |
addRoutes(Routes 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)
Adds the endpoint to the context using the given URI. |
|
protected Endpoint |
convertBeanToEndpoint(String uri,
Object bean)
Attempt 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 |
|
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 |
|
FactoryFinder |
createFactoryFinder()
Create a FactoryFinder which will be used for the loading the factory class from META-INF |
|
FactoryFinder |
createFactoryFinder(String path)
Create a FactoryFinder which will be used for the loading the factory class from META-INF |
|
protected Injector |
createInjector()
Lazily create a default implementation |
|
|
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 |
|
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. |
|
ComponentResolver |
getComponentResolver()
|
|
Map<String,DataFormatType> |
getDataFormats()
Gets the data formats that can be referenced in the routes. |
|
long |
getDelay()
Returns the delay in millis if delaying has been enabled or disabled via the setDelay(Long) method
or it has not been specified then default to the camel.delay system property |
|
Long |
getDelaying()
|
|
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 |
|
Injector |
getInjector()
Returns the injector used to instantiate objects by type |
|
List<InterceptStrategy> |
getInterceptStrategies()
|
|
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. |
|
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<RouteType> |
getRouteDefinitions()
Returns a list of the current route definitions |
|
List<Route> |
getRoutes()
Returns the current routes in this context |
|
Collection<Endpoint> |
getSingletonEndpoints()
Returns the collection of all registered singleton endpoints. |
|
boolean |
getTrace()
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.trace system property |
|
Boolean |
getTracing()
|
|
TypeConverter |
getTypeConverter()
Returns the type converter used to coerce types from one type to another |
|
boolean |
isAutoCreateComponents()
|
|
Component |
removeComponent(String componentName)
Removes a previously added component. |
|
Collection<Endpoint> |
removeEndpoints(String uri)
Removes all endpoints with the given URI |
|
Endpoint |
removeSingletonEndpoint(String uri)
Removes the singleton endpoint with the given URI |
|
Language |
resolveLanguage(String language)
Resolves a language for creating expressions |
|
void |
setAutoCreateComponents(boolean autoCreateComponents)
|
|
void |
setComponentResolver(ComponentResolver componentResolver)
|
|
void |
setDataFormats(Map<String,DataFormatType> 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 |
setFactoryFinderClass(Class<? extends FactoryFinder> finderClass)
|
|
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 |
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)
Sets the routes for this context, replacing any current routes |
|
void |
setTrace(Boolean trace)
|
|
void |
setTypeConverter(TypeConverter typeConverter)
|
|
protected boolean |
shouldStartRoutes()
Should we start newly added routes? |
|
void |
start()
Starts the service |
|
protected void |
startRouteDefinitions(Collection<RouteType> list)
|
|
protected void |
startRoutes(Collection<Route> routeList)
|
Methods inherited from class org.apache.camel.impl.ServiceSupport |
---|
addChildService, getThreadName, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, nextThreadCounter, removeChildService, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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 CamelContext
public void setName(String name)
public void addComponent(String componentName, Component component)
CamelContext
addComponent
in interface CamelContext
componentName
- the name the component is registered ascomponent
- the componentpublic Component getComponent(String name)
CamelContext
getComponent
in interface CamelContext
name
- the name of the component
public <T extends Component> T getComponent(String name, Class<T> componentType)
CamelContext
getComponent
in interface CamelContext
name
- the name to lookupcomponentType
- the expected type
public Component removeComponent(String componentName)
CamelContext
removeComponent
in interface CamelContext
componentName
- the component name to remove
public Component getOrCreateComponent(String componentName, Callable<Component> factory)
CamelContext
getOrCreateComponent
in interface CamelContext
componentName
- 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 CamelContext
public Map<String,Endpoint> getEndpointMap()
CamelContext
getEndpointMap
in interface CamelContext
public Collection<Endpoint> getEndpoints(String uri)
CamelContext
getEndpoints
in interface CamelContext
uri
- 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 CamelContext
uri
- 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 stoppedpublic Collection<Endpoint> removeEndpoints(String uri) throws Exception
CamelContext
removeEndpoints
in interface CamelContext
uri
- the URI to be used to remove
Exception
- if at least one endpoint could not be stoppedpublic Endpoint addSingletonEndpoint(String uri, Endpoint endpoint) throws Exception
CamelContext
addSingletonEndpoint
in interface CamelContext
uri
- 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 endpoint could not be stoppedpublic Endpoint removeSingletonEndpoint(String uri) throws Exception
CamelContext
removeSingletonEndpoint
in interface CamelContext
uri
- the URI to be used to remove
Exception
- if endpoint could not be stoppedpublic Endpoint getEndpoint(String uri)
CamelContext
Endpoint
. 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 CamelContext
uri
- the URI of the endpoint
public <T extends Endpoint> T getEndpoint(String name, Class<T> endpointType)
CamelContext
Endpoint
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 CamelContext
name
- the name of the endpointendpointType
- the expected type
public List<Route> getRoutes()
CamelContext
getRoutes
in interface CamelContext
public void setRoutes(List<Route> routes)
CamelContext
setRoutes
in interface CamelContext
routes
- the new routes to usepublic void addRoutes(Collection<Route> routes) throws Exception
CamelContext
addRoutes
in interface CamelContext
routes
- the routes to add
Exception
- if the routes could not be created for whatever reasonpublic void addRoutes(Routes builder) throws Exception
CamelContext
addRoutes
in interface CamelContext
builder
- the builder which will create the routes and add them to this context
Exception
- if the routes could not be created for whatever reasonpublic void addRouteDefinitions(Collection<RouteType> routeDefinitions) throws Exception
CamelContext
addRouteDefinitions
in interface CamelContext
routeDefinitions
- the route definitions to add
Exception
- if the route definition could not be created for whatever reasonpublic void addService(Object object) throws Exception
Exception
public Language resolveLanguage(String language)
CamelContext
resolveLanguage
in interface CamelContext
language
- name of the language
public ExchangeConverter getExchangeConverter()
CamelContext
getExchangeConverter
in interface CamelContext
public void setExchangeConverter(ExchangeConverter exchangeConverter)
public TypeConverter getTypeConverter()
CamelContext
getTypeConverter
in interface CamelContext
public void setTypeConverter(TypeConverter typeConverter)
public Injector getInjector()
CamelContext
getInjector
in interface CamelContext
public 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 CamelContext
public 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 CamelContext
public void setLifecycleStrategy(LifecycleStrategy lifecycleStrategy)
public List<RouteType> getRouteDefinitions()
CamelContext
getRouteDefinitions
in interface CamelContext
public List<InterceptStrategy> getInterceptStrategies()
public void setInterceptStrategies(List<InterceptStrategy> interceptStrategies)
public void addInterceptStrategy(InterceptStrategy interceptStrategy)
CamelContext
addInterceptStrategy
in interface CamelContext
interceptStrategy
- the strategypublic boolean getTrace()
setTrace(Boolean)
method
or it has not been specified then default to the camel.trace system property
public Boolean getTracing()
public void setTrace(Boolean trace)
public long getDelay()
setDelay(Long)
method
or it has not been specified then default to the camel.delay system property
public Long getDelaying()
public void setDelay(Long delay)
public <E extends Exchange> ProducerTemplate<E> createProducerTemplate()
CamelContext
createProducerTemplate
in interface CamelContext
public ErrorHandlerBuilder getErrorHandlerBuilder()
CamelContext
getErrorHandlerBuilder
in interface CamelContext
public void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
setErrorHandlerBuilder
in interface CamelContext
errorHandlerBuilder
- the builderpublic void start() throws Exception
Service
start
in interface Service
start
in class ServiceSupport
Exception
protected void doStart() throws Exception
doStart
in class ServiceSupport
Exception
protected void startRouteDefinitions(Collection<RouteType> list) throws Exception
Exception
protected void doStop() throws Exception
doStop
in class ServiceSupport
Exception
protected void startRoutes(Collection<Route> routeList) throws Exception
Exception
protected 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,DataFormatType> dataFormats)
CamelContext
setDataFormats
in interface CamelContext
dataFormats
- the data formatspublic Map<String,DataFormatType> getDataFormats()
CamelContext
getDataFormats
in interface CamelContext
public void setFactoryFinderClass(Class<? extends FactoryFinder> finderClass)
public Map<String,String> getProperties()
CamelContext
getProperties
in interface CamelContext
public void setProperties(Map<String,String> properties)
CamelContext
setProperties
in interface CamelContext
public FactoryFinder createFactoryFinder()
CamelContext
createFactoryFinder
in interface CamelContext
public FactoryFinder createFactoryFinder(String path)
CamelContext
createFactoryFinder
in interface CamelContext
path
- the META-INF path
protected String getEndpointKey(String uri, Endpoint endpoint)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |