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, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener

public class CamelContextFactoryBean
extends IdentifiedType
implements RouteContainer, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, org.springframework.context.ApplicationContextAware, org.springframework.context.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: 641676 $

Constructor Summary
CamelContextFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  SpringCamelContext createContext()
          Create the context
 void destroy()
           
protected  void findRouteBuiders()
          Strategy method to try find RouteBuilder instances on the classpath
 org.springframework.context.ApplicationContext getApplicationContext()
           
 List<RouteBuilderRef> getBuilderRefs()
           
 SpringCamelContext getContext()
           
 String getMbeanServer()
           
 Object getObject()
           
 Class getObjectType()
           
 String[] getPackages()
           
 RouteBuilder getRouteBuilder()
           
 List<RouteType> getRoutes()
           
 Boolean getUseJmx()
           
protected  void installRoutes()
          Strategy to install all available routes into the context
 boolean isJmxEnabled()
           
 boolean isSingleton()
           
 void onApplicationEvent(org.springframework.context.ApplicationEvent event)
           
 void setApplicationContext(org.springframework.context.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 setBuilderRefs(List<RouteBuilderRef> builderRefs)
           
 void setContext(SpringCamelContext context)
           
 void setMbeanServer(String mbeanServer)
           
 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 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 setUseJmx(Boolean useJmx)
           
 
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 org.springframework.beans.factory.FactoryBean
Throws:
Exception

getObjectType

public Class getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
Exception

onApplicationEvent

public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
Specified by:
onApplicationEvent in interface org.springframework.context.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

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 org.springframework.context.ApplicationContext getApplicationContext()

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware

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

getMbeanServer

public String getMbeanServer()

setMbeanServer

public void setMbeanServer(String mbeanServer)

isJmxEnabled

public boolean isJmxEnabled()

getUseJmx

public Boolean getUseJmx()

setUseJmx

public void setUseJmx(Boolean useJmx)

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.


createContext

protected SpringCamelContext createContext()
Create the context


installRoutes

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

Throws:
Exception

findRouteBuiders

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

Throws:
Exception
InstantiationException


Copyright © 2008 Apache Software Foundation. All Rights Reserved.