org.apache.camel
Interface CamelContext

All Superinterfaces:
Service
All Known Implementing Classes:
DefaultCamelContext

public interface CamelContext
extends Service

Interface used to represent the context used to configure routes and the policies to use during message exchanges between endpoints.

Version:
$Revision: 47152 $

Method Summary
 void addComponent(String componentName, Component component)
          Adds a component to the context.
 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
 Endpoint addSingletonEndpoint(String uri, Endpoint endpoint)
          Adds the endpoint to the context using the given URI.
<E extends Exchange>
ProducerTemplate<E>
createProducerTemplate()
          Creates a new ProducerTemplate
 Component getComponent(String componentName)
          Gets a component from the context by name.
<T extends Component>
T
getComponent(String name, Class<T> componentType)
          Gets a component from the context by name and specifying the expected type of component.
 Endpoint getEndpoint(String uri)
          Resolves the given URI to an Endpoint.
<T extends Endpoint>
T
getEndpoint(String name, Class<T> endpointType)
          Resolves the given name to an Endpoint of the specified type.
 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
 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.
 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.
 TypeConverter getTypeConverter()
          Returns the type converter used to coerce types from one type to another
 Component removeComponent(String componentName)
          Removes a previously added component.
 Endpoint removeSingletonEndpoint(String uri)
          Removes the singleton endpoint with the given URI
 Language resolveLanguage(String language)
          Resolves a language for creating expressions
 void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
          Sets the default error handler builder which is inherited by the routes
 void setRoutes(List<Route> routes)
          Sets the routes for this context, replacing any current routes
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

Method Detail

getName

String getName()
Gets the name of the this context.

Returns:
the name

addComponent

void addComponent(String componentName,
                  Component component)
Adds a component to the context.

Parameters:
componentName - the name the component is registered as
component - the component

getComponent

Component getComponent(String componentName)
Gets a component from the context by name.

Parameters:
componentName - the name of the component
Returns:
the component

getComponent

<T extends Component> T getComponent(String name,
                                     Class<T> componentType)
Gets a component from the context by name and specifying the expected type of component.

Parameters:
name - the name to lookup
componentType - the expected type
Returns:
the component

removeComponent

Component removeComponent(String componentName)
Removes a previously added component.

Parameters:
componentName - the component name to remove
Returns:
the previously added component or null if it had not been previously added.

getOrCreateComponent

Component getOrCreateComponent(String componentName,
                               Callable<Component> factory)
Gets the a previously added component by name or lazily creates the component using the factory Callback.

Parameters:
componentName - the name of the component
factory - used to create a new component instance if the component was not previously added.
Returns:
the component

getEndpoint

Endpoint getEndpoint(String uri)
Resolves the given URI to an 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.

Parameters:
uri - the URI of the endpoint
Returns:
the endpoint

getEndpoint

<T extends Endpoint> T getEndpoint(String name,
                                   Class<T> endpointType)
Resolves the given name to an 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.

Parameters:
name - the name of the endpoint
endpointType - the expected type
Returns:
the endpoint

getSingletonEndpoints

Collection<Endpoint> getSingletonEndpoints()
Returns the collection of all registered singleton endpoints.

Returns:
all the singleton endpoints

addSingletonEndpoint

Endpoint addSingletonEndpoint(String uri,
                              Endpoint endpoint)
                              throws Exception
Adds the endpoint to the context using the given URI. The endpoint will be registered as a singleton.

Parameters:
uri - the URI to be used to resolve this endpoint
endpoint - the endpoint to be added to the context
Returns:
the old endpoint that was previously registered to the context if there was already an endpoint for that URI
Throws:
Exception - if the new endpoint could not be started or the old endpoint could not be stopped

removeSingletonEndpoint

Endpoint removeSingletonEndpoint(String uri)
                                 throws Exception
Removes the singleton endpoint with the given URI

Parameters:
uri - the URI to be used to remove
Returns:
the endpoint that was removed or null if there is no endpoint for this URI
Throws:
Exception - if endpoint could not be stopped

getRouteDefinitions

List<RouteType> getRouteDefinitions()
Returns a list of the current route definitions

Returns:
list of the current route definitions

getRoutes

List<Route> getRoutes()
Returns the current routes in this context

Returns:
the current routes

setRoutes

void setRoutes(List<Route> routes)
Sets the routes for this context, replacing any current routes

Parameters:
routes - the new routes to use

addRoutes

void addRoutes(Collection<Route> routes)
               throws Exception
Adds a collection of routes to this context

Parameters:
routes - the routes to add
Throws:
Exception - if the routes could not be created for whatever reason

addRoutes

void addRoutes(Routes builder)
               throws Exception
Adds a collection of routes to this context using the given builder to build them

Parameters:
builder - the builder which will create the routes and add them to this context
Throws:
Exception - if the routes could not be created for whatever reason

addRouteDefinitions

void addRouteDefinitions(Collection<RouteType> routeDefinitions)
                         throws Exception
Adds a collection of route definitions to the context

Parameters:
routeDefinitions - the route definitions to add
Throws:
Exception - if the route definition could not be created for whatever reason

getExchangeConverter

ExchangeConverter getExchangeConverter()
Returns the converter of exchanges from one type to another

Returns:
the converter

getTypeConverter

TypeConverter getTypeConverter()
Returns the type converter used to coerce types from one type to another

Returns:
the converter

getRegistry

Registry getRegistry()
Returns the registry used to lookup components by name and type such as the Spring ApplicationContext, JNDI or the OSGi Service Registry

Returns:
the registry

getInjector

Injector getInjector()
Returns the injector used to instantiate objects by type

Returns:
the injector

getLifecycleStrategy

LifecycleStrategy getLifecycleStrategy()
Returns the lifecycle strategy used to handle lifecycle notification

Returns:
the lifecycle strategy

resolveLanguage

Language resolveLanguage(String language)
Resolves a language for creating expressions

Parameters:
language - name of the language
Returns:
the resolved language

createProducerTemplate

<E extends Exchange> ProducerTemplate<E> createProducerTemplate()
Creates a new ProducerTemplate

Returns:
the template

addInterceptStrategy

void addInterceptStrategy(InterceptStrategy interceptStrategy)
Adds the given interceptor strategy

Parameters:
interceptStrategy - the strategy

getErrorHandlerBuilder

ErrorHandlerBuilder getErrorHandlerBuilder()
Gets the default error handler builder which is inherited by the routes

Returns:
the builder

setErrorHandlerBuilder

void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder)
Sets the default error handler builder which is inherited by the routes

Parameters:
errorHandlerBuilder - the builder


Copyright © 2008 IONA Open Source Community. All Rights Reserved.