org.apache.camel.spring
Class CamelContextFactoryBean

java.lang.Object
  extended by org.apache.camel.model.IdentifiedType
      extended by org.apache.camel.spring.CamelContextFactoryBean
All Implemented Interfaces:
EventListener, RouteContainer, DisposableBean, FactoryBean, InitializingBean, ApplicationContextAware, ApplicationListener

public class CamelContextFactoryBean
extends IdentifiedType
implements RouteContainer, FactoryBean, InitializingBean, DisposableBean, ApplicationContextAware, ApplicationListener

A Spring FactoryBean to create and initialize a SpringCamelContext and install routes either explicitly configured in Spring XML or found by searching the classpath for Java classes which extend RouteBuilder using the nested setPackages(String[]).

Version:
$Revision: 782046 $

Constructor Summary
CamelContextFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  SpringCamelContext createContext()
          Create the context
protected  ResolverUtil createResolverUtil()
          The factory method for create the ResolverUtil
 void destroy()
           
protected  void findRouteBuilders()
          Strategy method to try find RouteBuilder instances on the classpath
 List<Routes> getAdditionalBuilders()
           
 ApplicationContext getApplicationContext()
           
 BeanPostProcessor getBeanPostProcessor()
           
 List<RouteBuilderRef> getBuilderRefs()
           
 CamelJMXAgentType getCamelJMXAgent()
           
 SpringCamelContext getContext()
           
 ClassLoader getContextClassLoaderOnStart()
           
 DataFormatsType getDataFormats()
           
 Long getDelay()
           
 String getErrorHandlerRef()
           
 List<InterceptType> getIntercepts()
           
 Object getObject()
           
 Class getObjectType()
           
 String[] getPackages()
           
 PropertiesType getProperties()
           
 RouteBuilder getRouteBuilder()
           
 List<RouteType> getRoutes()
           
 Boolean getShouldStartContext()
           
 Boolean getTrace()
           
 Boolean getUseJmx()
          Deprecated. Please the jmxAgent element instead. Will be removed in Camel 2.0.
protected  void installRoutes()
          Strategy to install all available routes into the context
 boolean isJmxEnabled()
          Deprecated. Please the jmxAgent element instead. Will be removed in Camel 2.0.
 boolean isSingleton()
           
 void onApplicationEvent(ApplicationEvent event)
           
 void setApplicationContext(ApplicationContext applicationContext)
           
 void setAutowireRouteBuilders(Boolean autowireRouteBuilders)
          If enabled this will force all RouteBuilder classes configured in the Spring ApplicationContext to be registered automatically with this CamelContext.
 void setBeanPostProcessor(BeanPostProcessor postProcessor)
           
 void setBuilderRefs(List<RouteBuilderRef> builderRefs)
           
 void setCamelJMXAgent(CamelJMXAgentType agent)
           
 void setContext(SpringCamelContext context)
           
 void setDataFormats(DataFormatsType dataFormats)
           
 void setDelay(Long delay)
           
 void setErrorHandlerRef(String errorHandlerRef)
          Sets the name of the error handler object used to default the error handling strategy
 void setIntercepts(List<InterceptType> intercepts)
           
 void setPackages(String[] packages)
          Sets the package names to be recursively searched for Java classes which extend RouteBuilder to be auto-wired up to the SpringCamelContext as a route.
 void setProperties(PropertiesType properties)
           
 void setRouteBuilder(RouteBuilder routeBuilder)
          Set a single RouteBuilder to be used to create the default routes on startup
 void setRouteBuilders(RouteBuilder[] builders)
          Set a collection of RouteBuilder instances to be used to create the default routes on startup
 void setRoutes(List<RouteType> routes)
           
 void setShouldStartContext(Boolean shouldStartContext)
           
 void setTrace(Boolean trace)
           
 void setUseJmx(Boolean useJmx)
          Deprecated. Please the jmxAgent element instead. Will be removed in Camel 2.0.
 
Methods inherited from class org.apache.camel.model.IdentifiedType
getId, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CamelContextFactoryBean

public CamelContextFactoryBean()
Method Detail

getObject

public Object getObject()
                 throws Exception
Specified by:
getObject in interface FactoryBean
Throws:
Exception

getObjectType

public Class getObjectType()
Specified by:
getObjectType in interface FactoryBean

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean

getContextClassLoaderOnStart

public ClassLoader getContextClassLoaderOnStart()

getAdditionalBuilders

public List<Routes> getAdditionalBuilders()

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)
Specified by:
onApplicationEvent in interface ApplicationListener

getContext

public SpringCamelContext getContext()
                              throws Exception
Throws:
Exception

setContext

public void setContext(SpringCamelContext context)

getRoutes

public List<RouteType> getRoutes()
Specified by:
getRoutes in interface RouteContainer

setRoutes

public void setRoutes(List<RouteType> routes)
Specified by:
setRoutes in interface RouteContainer

getIntercepts

public List<InterceptType> getIntercepts()

setIntercepts

public void setIntercepts(List<InterceptType> intercepts)

getRouteBuilder

public RouteBuilder getRouteBuilder()

setRouteBuilder

public void setRouteBuilder(RouteBuilder routeBuilder)
Set a single RouteBuilder to be used to create the default routes on startup


setRouteBuilders

public void setRouteBuilders(RouteBuilder[] builders)
Set a collection of RouteBuilder instances to be used to create the default routes on startup


getApplicationContext

public ApplicationContext getApplicationContext()

setApplicationContext

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

getProperties

public PropertiesType getProperties()

setProperties

public void setProperties(PropertiesType properties)

getPackages

public String[] getPackages()

setPackages

public void setPackages(String[] packages)
Sets the package names to be recursively searched for Java classes which extend RouteBuilder to be auto-wired up to the SpringCamelContext as a route. Note that classes are excluded if they are specifically configured in the spring.xml

Parameters:
packages - the package names which are recursively searched

setBeanPostProcessor

public void setBeanPostProcessor(BeanPostProcessor postProcessor)

getBeanPostProcessor

public BeanPostProcessor getBeanPostProcessor()

isJmxEnabled

public boolean isJmxEnabled()
Deprecated. Please the jmxAgent element instead. Will be removed in Camel 2.0.

This method merely retrieves the value of the "useJmx" attribute and does not consider the "disabled" flag in jmxAgent element. The useJmx attribute will be removed in 2.0. Please the jmxAgent element instead.


getUseJmx

public Boolean getUseJmx()
Deprecated. Please the jmxAgent element instead. Will be removed in Camel 2.0.


setUseJmx

public void setUseJmx(Boolean useJmx)
Deprecated. Please the jmxAgent element instead. Will be removed in Camel 2.0.


setCamelJMXAgent

public void setCamelJMXAgent(CamelJMXAgentType agent)

getTrace

public Boolean getTrace()

setTrace

public void setTrace(Boolean trace)

getDelay

public Long getDelay()

setDelay

public void setDelay(Long delay)

getCamelJMXAgent

public CamelJMXAgentType getCamelJMXAgent()

getBuilderRefs

public List<RouteBuilderRef> getBuilderRefs()

setBuilderRefs

public void setBuilderRefs(List<RouteBuilderRef> builderRefs)

setAutowireRouteBuilders

public void setAutowireRouteBuilders(Boolean autowireRouteBuilders)
If enabled this will force all RouteBuilder classes configured in the Spring ApplicationContext to be registered automatically with this CamelContext.


getErrorHandlerRef

public String getErrorHandlerRef()

setErrorHandlerRef

public void setErrorHandlerRef(String errorHandlerRef)
Sets the name of the error handler object used to default the error handling strategy

Parameters:
errorHandlerRef - the Spring bean ref of the error handler

getShouldStartContext

public Boolean getShouldStartContext()

setShouldStartContext

public void setShouldStartContext(Boolean shouldStartContext)

createContext

protected SpringCamelContext createContext()
Create the context


installRoutes

protected void installRoutes()
                      throws Exception
Strategy to install all available routes into the context

Throws:
Exception

findRouteBuilders

protected void findRouteBuilders()
                          throws Exception,
                                 InstantiationException
Strategy method to try find RouteBuilder instances on the classpath

Throws:
Exception
InstantiationException

createResolverUtil

protected ResolverUtil createResolverUtil()
The factory method for create the ResolverUtil

Returns:
a new instance of ResolverUtil

setDataFormats

public void setDataFormats(DataFormatsType dataFormats)

getDataFormats

public DataFormatsType getDataFormats()


Apache CAMEL