org.apache.camel.cdi.internal
Class CamelExtension

java.lang.Object
  extended by org.apache.camel.cdi.internal.CamelExtension
All Implemented Interfaces:
javax.enterprise.inject.spi.Extension

public class CamelExtension
extends Object
implements javax.enterprise.inject.spi.Extension

Set of camel specific hooks for CDI.


Constructor Summary
CamelExtension()
           
 
Method Summary
protected  void contextAwareness(javax.enterprise.inject.spi.ProcessAnnotatedType<org.apache.camel.CamelContextAware> process)
          Process camel context aware bean definitions.
 void detectConsumeBeans(javax.enterprise.inject.spi.ProcessBean<?> event)
          Lets detect all beans annotated with @Consume and beans of type RouteBuilder which are annotated with ContextName so they can be auto-registered
 void detectProducerRoutes(javax.enterprise.inject.spi.ProcessProducerMethod<?,?> event)
          Lets detect all producer methods createing instances of RouteBuilder which are annotated with ContextName so they can be auto-registered
 void detectRouteBuilderBeans(javax.enterprise.inject.spi.ProcessBean<?> event)
          Lets detect all beans annotated of type RouteBuilder which are annotated with ContextName so they can be auto-registered
protected
<T> void
detectRouteBuilders(javax.enterprise.inject.spi.ProcessAnnotatedType<T> process)
           
protected  void disableDefaultContext(javax.enterprise.inject.spi.ProcessAnnotatedType<org.apache.camel.CamelContext> process)
          Disable creation of default CamelContext bean and rely on context created and managed by extension.
protected  org.apache.camel.CamelContext getCamelContext(String context)
           
static String getCamelContextName(String context, ContextName annotation)
          If no context name is specified then default it to the value from the ContextName annotation
protected  org.apache.camel.impl.DefaultCamelBeanPostProcessor getPostProcessor(String context)
           
 void inject(Object bean)
          Perform injection on an existing bean such as a test case which is created directly by a testing framework.
protected static boolean injectAnnotatedField(Field field)
          Returns true if this field is annotated with @Inject
protected  boolean isRoutesBean(Class<?> returnType)
           
 void onInjectionTarget(javax.enterprise.inject.spi.ProcessInjectionTarget<Object> event)
          Lets perform injection of all beans which use Camel annotations
protected  void registerManagedCamelContext(javax.enterprise.inject.spi.AfterBeanDiscovery abd, javax.enterprise.inject.spi.BeanManager manager)
          Registers managed camel bean.
 void startConsumeBeans(javax.enterprise.inject.spi.AfterDeploymentValidation event, javax.enterprise.inject.spi.BeanManager beanManager)
          Lets force the CDI container to create all beans annotated with @Consume so that the consumer becomes active
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CamelExtension

public CamelExtension()
Method Detail

getCamelContextName

public static String getCamelContextName(String context,
                                         ContextName annotation)
If no context name is specified then default it to the value from the ContextName annotation


contextAwareness

protected void contextAwareness(@Observes
                                javax.enterprise.inject.spi.ProcessAnnotatedType<org.apache.camel.CamelContextAware> process)
                         throws Exception
Process camel context aware bean definitions.

Parameters:
process - Annotated type.
Throws:
Exception - In case of exceptions.

detectRouteBuilders

protected <T> void detectRouteBuilders(@Observes
                                       javax.enterprise.inject.spi.ProcessAnnotatedType<T> process)
                            throws Exception
Throws:
Exception

disableDefaultContext

protected void disableDefaultContext(@Observes
                                     javax.enterprise.inject.spi.ProcessAnnotatedType<org.apache.camel.CamelContext> process)
Disable creation of default CamelContext bean and rely on context created and managed by extension.

Parameters:
process - Annotated type.

registerManagedCamelContext

protected void registerManagedCamelContext(@Observes
                                           javax.enterprise.inject.spi.AfterBeanDiscovery abd,
                                           javax.enterprise.inject.spi.BeanManager manager)
Registers managed camel bean.

Parameters:
abd - After bean discovery event.
manager - Bean manager.

detectConsumeBeans

public void detectConsumeBeans(@Observes
                               javax.enterprise.inject.spi.ProcessBean<?> event)
Lets detect all beans annotated with @Consume and beans of type RouteBuilder which are annotated with ContextName so they can be auto-registered


detectRouteBuilderBeans

public void detectRouteBuilderBeans(@Observes
                                    javax.enterprise.inject.spi.ProcessBean<?> event)
Lets detect all beans annotated of type RouteBuilder which are annotated with ContextName so they can be auto-registered


detectProducerRoutes

public void detectProducerRoutes(@Observes
                                 javax.enterprise.inject.spi.ProcessProducerMethod<?,?> event)
Lets detect all producer methods createing instances of RouteBuilder which are annotated with ContextName so they can be auto-registered


startConsumeBeans

public void startConsumeBeans(@Observes
                              javax.enterprise.inject.spi.AfterDeploymentValidation event,
                              javax.enterprise.inject.spi.BeanManager beanManager)
                       throws Exception
Lets force the CDI container to create all beans annotated with @Consume so that the consumer becomes active

Throws:
Exception

onInjectionTarget

public void onInjectionTarget(@Observes
                              javax.enterprise.inject.spi.ProcessInjectionTarget<Object> event)
Lets perform injection of all beans which use Camel annotations


inject

public void inject(Object bean)
Perform injection on an existing bean such as a test case which is created directly by a testing framework.

This is because BeanProvider.injectFields() does not invoke the onInjectionTarget() method so the injection of @Produce / @EndpointInject and processing of the @Consume annotations are not performed.


getPostProcessor

protected org.apache.camel.impl.DefaultCamelBeanPostProcessor getPostProcessor(String context)

getCamelContext

protected org.apache.camel.CamelContext getCamelContext(String context)

injectAnnotatedField

protected static boolean injectAnnotatedField(Field field)
Returns true if this field is annotated with @Inject


isRoutesBean

protected boolean isRoutesBean(Class<?> returnType)


Apache Camel