camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r930893 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/builder/ main/java/org/apache/camel/impl/ main/java/org/apache/camel/util/ test/java/org/apache/camel/impl/
Date Mon, 05 Apr 2010 16:13:12 GMT
Author: davsclaus
Date: Mon Apr  5 16:13:12 2010
New Revision: 930893

URL: http://svn.apache.org/viewvc?rev=930893&view=rev
Log:
CAMEL-2550: @EndpointInject validates only one of uri or ref attribute has been set. Removed
@deprecated class.

Removed:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FileExpressionBuilder.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CustomProducerServicePoolTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=930893&r1=930892&r2=930893&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Mon
Apr  5 16:13:12 2010
@@ -948,9 +948,6 @@ public class DefaultCamelContext extends
         return errorHandlerBuilder;
     }
 
-    /**
-     * Sets the default error handler builder which is inherited by the routes
-     */
     public void setErrorHandlerBuilder(ErrorHandlerBuilder errorHandlerBuilder) {
         this.errorHandlerBuilder = errorHandlerBuilder;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java?rev=930893&r1=930892&r2=930893&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java Mon
Apr  5 16:13:12 2010
@@ -127,23 +127,27 @@ public final class CamelContextHelper {
     /**
      * Evaluates the @EndpointInject annotation using the given context
      */
-    public static Endpoint getEndpointInjection(CamelContext camelContext, String uri, String
name, String injectionPointName, boolean mandatory) {
+    public static Endpoint getEndpointInjection(CamelContext camelContext, String uri, String
ref, String injectionPointName, boolean mandatory) {
+        if (ObjectHelper.isNotEmpty(uri) && ObjectHelper.isNotEmpty(ref)) {
+            throw new IllegalArgumentException("Both uri and name is provided, only either
one is allowed: uri=" + uri + ", ref=" + ref);
+        }
+
         Endpoint endpoint;
         if (isNotEmpty(uri)) {
             endpoint = camelContext.getEndpoint(uri);
         } else {
-            // if a name is given then it should be possible to lookup
+            // if a ref is given then it should be possible to lookup
             // otherwise we do not catch situations where there is a typo etc
-            if (isNotEmpty(name)) {
-                endpoint = mandatoryLookup(camelContext, name, Endpoint.class);
+            if (isNotEmpty(ref)) {
+                endpoint = mandatoryLookup(camelContext, ref, Endpoint.class);
             } else {
-                if (isEmpty(name)) {
-                    name = injectionPointName;
+                if (isEmpty(ref)) {
+                    ref = injectionPointName;
                 }
                 if (mandatory) {
-                    endpoint = mandatoryLookup(camelContext, name, Endpoint.class);
+                    endpoint = mandatoryLookup(camelContext, ref, Endpoint.class);
                 } else {
-                    endpoint = lookup(camelContext, name, Endpoint.class);
+                    endpoint = lookup(camelContext, ref, Endpoint.class);
                 }
             }
         }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java?rev=930893&r1=930892&r2=930893&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
Mon Apr  5 16:13:12 2010
@@ -74,7 +74,7 @@ public class CamelPostProcessorHelperTes
 
         MyEndpointInjectBeanProducerTemplate bean = new MyEndpointInjectBeanProducerTemplate();
         Method method = bean.getClass().getMethod("setProducer", ProducerTemplate.class);
-        
+
         EndpointInject endpointInject = method.getAnnotation(EndpointInject.class);
         Class<?>[] parameterTypes = method.getParameterTypes();
         for (Class type : parameterTypes) {
@@ -97,7 +97,7 @@ public class CamelPostProcessorHelperTes
 
         MyEndpointBeanProducer bean = new MyEndpointBeanProducer();
         Method method = bean.getClass().getMethod("setProducer", Producer.class);
-        
+
         EndpointInject endpointInject = method.getAnnotation(EndpointInject.class);
         Class<?>[] parameterTypes = method.getParameterTypes();
         for (Class type : parameterTypes) {
@@ -230,6 +230,24 @@ public class CamelPostProcessorHelperTes
         }
     }
 
+    public void testEndpointInjectBothUriAndRef() throws Exception {
+        CamelPostProcessorHelper helper = new CamelPostProcessorHelper(context);
+
+        MyEndpointBothUriAndRef bean = new MyEndpointBothUriAndRef();
+        Field field = bean.getClass().getField("producer");
+
+        EndpointInject endpointInject = field.getAnnotation(EndpointInject.class);
+        Class<?> type = field.getType();
+        String propertyName = "producer";
+
+        try {
+            Object value = helper.getInjectionValue(type, endpointInject.uri(), endpointInject.ref(),
propertyName);
+            fail("Should throw exception");
+        } catch (IllegalArgumentException e) {
+            assertEquals("Both uri and name is provided, only either one is allowed: uri=seda:foo,
ref=myEndpoint", e.getMessage());
+        }
+    }
+
     public class MyConsumeBean {
 
         @Consume(uri = "seda:foo")
@@ -339,4 +357,15 @@ public class CamelPostProcessorHelperTes
 
     }
 
+    public class MyEndpointBothUriAndRef {
+
+        @EndpointInject(uri = "seda:foo", ref = "myEndpoint")
+        public ProducerTemplate producer;
+
+        public void send(Exchange exchange) throws Exception {
+            producer.send(exchange);
+        }
+
+    }
+
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CustomProducerServicePoolTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CustomProducerServicePoolTest.java?rev=930893&r1=930892&r2=930893&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CustomProducerServicePoolTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/CustomProducerServicePoolTest.java
Mon Apr  5 16:13:12 2010
@@ -71,6 +71,14 @@ public class CustomProducerServicePoolTe
 
         private Producer producer;
 
+        public void setCapacity(int capacity) {
+            // noop
+        }
+
+        public int getCapacity() {
+            return 0;
+        }
+
         public Producer addAndAcquire(Endpoint endpoint, Producer producer) {
             if (endpoint instanceof MyEndpoint) {
                 return producer;



Mime
View raw message