org.apache.camel.spring
Class SpringCamelContext

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.DefaultCamelContext
          extended by org.apache.camel.spring.SpringCamelContext
All Implemented Interfaces:
org.apache.camel.CamelContext, org.apache.camel.model.ModelCamelContext, org.apache.camel.RuntimeConfiguration, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.StatefulService, org.apache.camel.SuspendableService, Aware, DisposableBean, InitializingBean, ApplicationContextAware
Direct Known Subclasses:
OsgiSpringCamelContext

public class SpringCamelContext
extends org.apache.camel.impl.DefaultCamelContext
implements InitializingBean, DisposableBean, ApplicationContextAware

A Spring aware implementation of CamelContext which will automatically register itself with Springs lifecycle methods plus allows spring to be used to customize a any Type Converters as well as supporting accessing components and beans via the Spring ApplicationContext

Version:

Field Summary
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
SpringCamelContext()
           
SpringCamelContext(ApplicationContext applicationContext)
           
 
Method Summary
 void afterPropertiesSet()
           
protected  org.apache.camel.Endpoint convertBeanToEndpoint(String uri, Object bean)
           
protected  EventEndpoint createEventEndpoint()
           
protected  org.apache.camel.spi.Injector createInjector()
           
protected  org.apache.camel.spi.ManagementMBeanAssembler createManagementMBeanAssembler()
           
protected  org.apache.camel.spi.Registry createRegistry()
           
 void destroy()
           
 ApplicationContext getApplicationContext()
           
 EventEndpoint getEventEndpoint()
          Deprecated. 
 boolean isShutdownEager()
          Whether to shutdown this SpringCamelContext eager (first) when Spring ApplicationContext is being stopped.
 void onApplicationEvent(ApplicationEvent event)
           
 void setApplicationContext(ApplicationContext applicationContext)
           
 void setEventEndpoint(EventEndpoint eventEndpoint)
          Deprecated. 
static void setNoStart(boolean b)
           
 void setShutdownEager(boolean shutdownEager)
           
static SpringCamelContext springCamelContext(ApplicationContext applicationContext)
           
static SpringCamelContext springCamelContext(ApplicationContext applicationContext, boolean maybeStart)
           
static SpringCamelContext springCamelContext(String configLocations)
           
 String toString()
           
 
Methods inherited from class org.apache.camel.impl.DefaultCamelContext
addComponent, addEndpoint, addEndpointToRegistry, addInterceptStrategy, addLifecycleStrategy, addRegisterEndpointCallback, addRouteDefinition, addRouteDefinitions, addRoutes, addService, addStartupListener, createComponentResolver, createConsumerTemplate, createConsumerTemplate, createEndpoint, createManagementStrategy, createProducerTemplate, createProducerTemplate, createRouteStaticEndpointJson, createRouteStaticEndpointJson, createTypeConverter, disableJMX, doResume, doStart, doStartOrResumeRoutes, doStop, doSuspend, findComponents, forceLazyInitialization, forceStopLazyInitialization, getApplicationContextClassLoader, getClassResolver, getComponent, getComponent, getComponent, getComponentDocumentation, getComponentNames, getComponentResolver, getDataFormatResolver, getDataFormats, getDebugger, getDefaultBacklogDebugger, getDefaultBacklogTracer, getDefaultFactoryFinder, getDefaultTracer, getDelayer, getEndpoint, getEndpoint, getEndpointKey, getEndpointKey, getEndpointMap, getEndpoints, getErrorHandlerBuilder, getErrorHandlerExecutorService, getExecutorServiceManager, getExecutorServiceStrategy, getFactoryFinder, getInflightRepository, getInjector, getInterceptStrategies, getLanguageNames, getLanguageResolver, getLifecycleStrategies, getManagementMBeanAssembler, getManagementName, getManagementNameStrategy, getManagementStrategy, getName, getNameStrategy, getNodeIdFactory, getPackageScanClassResolver, getProcessorFactory, getProducerServicePool, getProperties, getPropertiesComponent, getProperty, getPropertyPrefixToken, getPropertySuffixToken, getRegistry, getRegistry, getRoute, getRouteDefinition, getRouteDefinitions, getRoutes, getRouteServices, getRouteStartupOrder, getRouteStatus, getRuntimeEndpointRegistry, getShutdownRoute, getShutdownRunningTask, getShutdownStrategy, getStreamCachingStrategy, getTypeConverter, getTypeConverterRegistry, getUnitOfWorkFactory, getUptime, getUuidGenerator, hasComponent, hasEndpoint, hasService, isAllowUseOriginalMessage, isAutoCreateComponents, isAutoStartup, isHandleFault, isLazyLoadTypeConverters, isMessageHistory, isSetupRoutes, isStartingRoutes, isStreamCaching, isTracing, isTypeConverterStatisticsEnabled, isUseBreadcrumb, isUseMDCLogging, loadRoutesDefinition, logRouteState, lookupPropertiesComponent, normalizeEndpointUri, removeComponent, removeEndpoints, removeRoute, removeRouteDefinition, removeRouteDefinition, removeRouteDefinitions, removeService, resolveDataFormat, resolveDataFormatDefinition, resolveLanguage, resolvePropertyPlaceholders, resumeRoute, resumeRouteService, routeSupportsSuspension, safelyStartRouteServices, safelyStartRouteServices, setAllowUseOriginalMessage, setApplicationContextClassLoader, setAutoCreateComponents, setAutoStartup, setClassResolver, setComponentResolver, setContextCounter, setDataFormatResolver, setDataFormats, setDebugger, setDefaultBacklogDebugger, setDefaultBacklogTracer, setDefaultTracer, setDelayer, setErrorHandlerBuilder, setExecutorServiceManager, setFactoryFinderResolver, setHandleFault, setInflightRepository, setInjector, setInterceptStrategies, setJndiContext, setLanguageResolver, setLazyLoadTypeConverters, setLifecycleStrategies, setManagementMBeanAssembler, setManagementName, setManagementNameStrategy, setManagementStrategy, setMessageHistory, setName, setNameStrategy, setNodeIdFactory, setPackageScanClassResolver, setProcessorFactory, setProducerServicePool, setProperties, setRegistry, setRoutes, setRuntimeEndpointRegistry, setShutdownRoute, setShutdownRunningTask, setShutdownStrategy, setStreamCaching, setStreamCachingStrategy, setTracing, setTypeConverter, setTypeConverterRegistry, setTypeConverterStatisticsEnabled, setUnitOfWorkFactory, setupRoutes, setUseBreadcrumb, setUseMDCLogging, setUuidGenerator, shouldStartRoutes, shutdownRoute, shutdownRoute, shutdownRouteService, start, startAllRoutes, startRoute, startRoute, startRouteDefinitions, startRouteService, stopRoute, stopRoute, stopRoute, stopRoute, stopRouteService, stopRouteService, suspendRoute, suspendRoute, suspendRouteService
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doShutdown, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.CamelContext
getStatus, getVersion, stop
 
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
 

Constructor Detail

SpringCamelContext

public SpringCamelContext()

SpringCamelContext

public SpringCamelContext(ApplicationContext applicationContext)
Method Detail

setNoStart

public static void setNoStart(boolean b)

springCamelContext

public static SpringCamelContext springCamelContext(ApplicationContext applicationContext)
                                             throws Exception
Throws:
Exception

springCamelContext

public static SpringCamelContext springCamelContext(ApplicationContext applicationContext,
                                                    boolean maybeStart)
                                             throws Exception
Throws:
Exception

springCamelContext

public static SpringCamelContext springCamelContext(String configLocations)
                                             throws Exception
Throws:
Exception

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface DisposableBean
Throws:
Exception

onApplicationEvent

public void onApplicationEvent(ApplicationEvent event)

getApplicationContext

public ApplicationContext getApplicationContext()

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException

getEventEndpoint

@Deprecated
public EventEndpoint getEventEndpoint()
Deprecated. 


setEventEndpoint

@Deprecated
public void setEventEndpoint(EventEndpoint eventEndpoint)
Deprecated. 


isShutdownEager

public boolean isShutdownEager()
Whether to shutdown this SpringCamelContext eager (first) when Spring ApplicationContext is being stopped.

Important: This option is default true which ensures we shutdown Camel before other beans. Setting this to false restores old behavior in earlier Camel releases, which can be used for special cases to behave as before.

Returns:
true to shutdown eager (first), false to shutdown last

setShutdownEager

public void setShutdownEager(boolean shutdownEager)
See Also:
isShutdownEager()

createInjector

protected org.apache.camel.spi.Injector createInjector()
Overrides:
createInjector in class org.apache.camel.impl.DefaultCamelContext

createManagementMBeanAssembler

protected org.apache.camel.spi.ManagementMBeanAssembler createManagementMBeanAssembler()
Overrides:
createManagementMBeanAssembler in class org.apache.camel.impl.DefaultCamelContext

createEventEndpoint

protected EventEndpoint createEventEndpoint()

convertBeanToEndpoint

protected org.apache.camel.Endpoint convertBeanToEndpoint(String uri,
                                                          Object bean)
Overrides:
convertBeanToEndpoint in class org.apache.camel.impl.DefaultCamelContext

createRegistry

protected org.apache.camel.spi.Registry createRegistry()
Overrides:
createRegistry in class org.apache.camel.impl.DefaultCamelContext

toString

public String toString()
Overrides:
toString in class org.apache.camel.impl.DefaultCamelContext


Apache Camel