You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/09/07 09:50:39 UTC

[4/5] git commit: Tests Work with Weld 2 now

Tests Work with Weld 2 now


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0a241dd9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0a241dd9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0a241dd9

Branch: refs/heads/master
Commit: 0a241dd992188e78e0f2ddf6fdad7ed91c34d7a8
Parents: 3e997e2
Author: Antoine Sabot-Durand <an...@sabot-durand.net>
Authored: Fri Nov 8 06:01:57 2013 +0100
Committer: Antoine Sabot-Durand <an...@sabot-durand.net>
Committed: Fri Nov 8 06:01:57 2013 +0100

----------------------------------------------------------------------
 .../camel/cdi/internal/CamelExtension.java      | 47 +++++++++++---------
 .../cdi/internal/DelegateInjectionTarget.java   | 10 ++---
 2 files changed, 30 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0a241dd9/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java
index b93fb54..955fd09 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/CamelExtension.java
@@ -69,7 +69,9 @@ public class CamelExtension implements Extension {
     CamelContextMap camelContextMap;
 
     private final Set<Bean<?>> eagerBeans = new HashSet<Bean<?>>();
+
     private final Map<String, CamelContextConfig> camelContextConfigMap = new HashMap<String, CamelContextConfig>();
+
     private final List<CamelContextBean> camelContextBeans = new ArrayList<CamelContextBean>();
 
     public CamelExtension() {
@@ -92,24 +94,23 @@ public class CamelExtension implements Extension {
      * @param process Annotated type.
      * @throws Exception In case of exceptions.
      */
-    protected void contextAwareness(@Observes ProcessAnnotatedType<CamelContextAware> process)
-        throws Exception {
-        AnnotatedType<CamelContextAware> annotatedType = process.getAnnotatedType();
-        Class<CamelContextAware> javaClass = annotatedType.getJavaClass();
-        if (CamelContextAware.class.isAssignableFrom(javaClass)) {
-            Method method = javaClass.getMethod("setCamelContext", CamelContext.class);
-            AnnotatedTypeBuilder<CamelContextAware> builder = new AnnotatedTypeBuilder<CamelContextAware>()
-                    .readFromType(javaClass)
-                    .addToMethod(method, new InjectLiteral());
-            process.setAnnotatedType(builder.create());
-        }
+    protected void contextAwareness(@Observes ProcessAnnotatedType<? extends CamelContextAware> process)
+            throws Exception {
+        AnnotatedType at = process.getAnnotatedType();
+
+        Method method = at.getJavaClass().getMethod("setCamelContext", CamelContext.class);
+        AnnotatedTypeBuilder builder = new AnnotatedTypeBuilder<CamelContextAware>()
+                .readFromType(at)
+                .addToMethod(method, new InjectLiteral());
+        process.setAnnotatedType(builder.create());
+
     }
 
-    protected <T> void detectRouteBuilders(@Observes ProcessAnnotatedType<T> process)
-        throws Exception {
-        AnnotatedType<T> annotatedType = process.getAnnotatedType();
+    protected  void detectRouteBuilders(@Observes ProcessAnnotatedType<?> process)
+            throws Exception {
+        AnnotatedType annotatedType = process.getAnnotatedType();
         ContextName annotation = annotatedType.getAnnotation(ContextName.class);
-        Class<T> javaClass = annotatedType.getJavaClass();
+        Class javaClass = annotatedType.getJavaClass();
         if (annotation != null && isRoutesBean(javaClass)) {
             addRouteBuilderBean(process, annotation);
         }
@@ -203,7 +204,8 @@ public class CamelExtension implements Extension {
     }
 
     /**
-     * Lets detect all producer methods createing instances of {@link RouteBuilder} which are annotated with {@link org.apache.camel.cdi.ContextName}
+     * Lets detect all producer methods createing instances of {@link RouteBuilder} which are annotated with {@link org
+     * .apache.camel.cdi.ContextName}
      * so they can be auto-registered
      */
     public void detectProducerRoutes(@Observes ProcessProducerMethod<?, ?> event) {
@@ -219,7 +221,7 @@ public class CamelExtension implements Extension {
      * Lets force the CDI container to create all beans annotated with @Consume so that the consumer becomes active
      */
     public void startConsumeBeans(@Observes AfterDeploymentValidation event, BeanManager beanManager)
-        throws Exception {
+            throws Exception {
         for (CamelContextBean bean : camelContextBeans) {
             String name = bean.getCamelContextName();
             CamelContext context = getCamelContext(name, beanManager);
@@ -227,7 +229,7 @@ public class CamelExtension implements Extension {
                 throw new IllegalStateException(
                         "CamelContext '" + name + "' has not been injected into the CamelContextMap");
             }
-            bean.configureCamelContext((CdiCamelContext)context);
+            bean.configureCamelContext((CdiCamelContext) context);
         }
 
         for (Bean<?> bean : eagerBeans) {
@@ -241,9 +243,9 @@ public class CamelExtension implements Extension {
     /**
      * Lets perform injection of all beans which use Camel annotations
      */
-    public void onInjectionTarget(@Observes ProcessInjectionTarget<Object> event) {
-        final InjectionTarget<Object> injectionTarget = event.getInjectionTarget();
-        AnnotatedType<Object> annotatedType = event.getAnnotatedType();
+    public void onInjectionTarget(@Observes ProcessInjectionTarget<?> event) {
+        final InjectionTarget injectionTarget = event.getInjectionTarget();
+        AnnotatedType annotatedType = event.getAnnotatedType();
         final Class<Object> beanClass = annotatedType.getJavaClass();
         // TODO this is a bit of a hack - what should the bean name be?
         final String beanName = injectionTarget.toString();
@@ -345,6 +347,7 @@ public class CamelExtension implements Extension {
     }
 
     protected boolean isRoutesBean(Class<?> returnType) {
-        return (RoutesBuilder.class.isAssignableFrom(returnType) || RouteContainer.class.isAssignableFrom(returnType)) && !Modifier.isAbstract(returnType.getModifiers());
+        return (RoutesBuilder.class.isAssignableFrom(returnType) || RouteContainer.class.isAssignableFrom(returnType)) &&
+                !Modifier.isAbstract(returnType.getModifiers());
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/0a241dd9/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java
index e8e267f..dbd97d1 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/internal/DelegateInjectionTarget.java
@@ -16,16 +16,16 @@
  */
 package org.apache.camel.cdi.internal;
 
-import java.util.Set;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InjectionTarget;
+import java.util.Set;
 
 /**
  * A helper class for creating delegate implementations of {@link InjectionTarget}
  */
-public abstract class DelegateInjectionTarget implements InjectionTarget<Object> {
-    private final InjectionTarget<Object> delegate;
+public abstract class DelegateInjectionTarget implements InjectionTarget {
+    private final InjectionTarget delegate;
 
     public DelegateInjectionTarget(InjectionTarget<Object> delegate) {
         this.delegate = delegate;
@@ -42,7 +42,7 @@ public abstract class DelegateInjectionTarget implements InjectionTarget<Object>
     }
 
     @Override
-    public void inject(Object instance, CreationalContext<Object> ctx) {
+    public void inject(Object instance, CreationalContext ctx) {
         delegate.inject(instance, ctx);
     }
 
@@ -57,7 +57,7 @@ public abstract class DelegateInjectionTarget implements InjectionTarget<Object>
     }
 
     @Override
-    public Object produce(CreationalContext<Object> creationalContext) {
+    public Object produce(CreationalContext creationalContext) {
         return delegate.produce(creationalContext);
     }
 }