camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1389815 - in /camel/branches/camel-2.10.x: ./ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/spi...
Date Tue, 25 Sep 2012 11:34:26 GMT
Author: davsclaus
Date: Tue Sep 25 11:34:25 2012
New Revision: 1389815

URL: http://svn.apache.org/viewvc?rev=1389815&view=rev
Log:
CAMEL-5647: EIPs using custom aggregation strategy should fail if not possible to find in
registry

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/EnrichDefinition.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerDefinition.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/LoadBalancerDefinition.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/MulticastDefinition.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/ProcessDefinition.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
    camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/model/ProcessorTypeConfigurationTest.java
    camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
    camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1389813

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
Tue Sep 25 11:34:25 2012
@@ -102,10 +102,7 @@ public class ErrorHandlerBuilderRef exte
             }
         } else {
             // use specific configured error handler
-            answer = routeContext.lookup(ref, ErrorHandlerBuilder.class);
-            if (answer == null) {
-                throw new IllegalArgumentException("ErrorHandlerBuilder with id " + ref +
" not found in registry.");
-            }
+            answer = routeContext.mandatoryLookup(ref, ErrorHandlerBuilder.class);
         }
 
         return answer;

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
Tue Sep 25 11:34:25 2012
@@ -41,6 +41,7 @@ import org.apache.camel.processor.UnitOf
 import org.apache.camel.spi.InterceptStrategy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.spi.RoutePolicy;
+import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.ObjectHelper;
 
 /**
@@ -139,7 +140,12 @@ public class DefaultRouteContext impleme
     public <T> Map<String, T> lookupByType(Class<T> type) {
         return getCamelContext().getRegistry().lookupByType(type);
     }
-    
+
+    @Override
+    public <T> T mandatoryLookup(String name, Class<T> type) {
+        return CamelContextHelper.mandatoryLookup(getCamelContext(), name, type);
+    }
+
     public void commit() {
         // now lets turn all of the event driven consumer processors into a single route
         if (!eventDrivenProcessors.isEmpty()) {

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
Tue Sep 25 11:34:25 2012
@@ -259,7 +259,7 @@ public class AggregateDefinition extends
     private AggregationStrategy createAggregationStrategy(RouteContext routeContext) {
         AggregationStrategy strategy = getAggregationStrategy();
         if (strategy == null && strategyRef != null) {
-            strategy = routeContext.lookup(strategyRef, AggregationStrategy.class);
+            strategy = routeContext.mandatoryLookup(strategyRef, AggregationStrategy.class);
         }
 
         if (groupExchanges != null && groupExchanges) {
@@ -284,10 +284,7 @@ public class AggregateDefinition extends
     private AggregationRepository createAggregationRepository(RouteContext routeContext)
{
         AggregationRepository repository = getAggregationRepository();
         if (repository == null && aggregationRepositoryRef != null) {
-            repository = routeContext.lookup(aggregationRepositoryRef, AggregationRepository.class);
-            if (repository == null) {
-                throw new IllegalArgumentException("AggregationRepositoryRef " + aggregationRepositoryRef
+ " not found in registry.");
-            }
+            repository = routeContext.mandatoryLookup(aggregationRepositoryRef, AggregationRepository.class);
         }
         return repository;
     }

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/EnrichDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/EnrichDefinition.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/EnrichDefinition.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/EnrichDefinition.java
Tue Sep 25 11:34:25 2012
@@ -95,7 +95,7 @@ public class EnrichDefinition extends No
 
         Enricher enricher = new Enricher(null, endpoint.createProducer());
         if (aggregationStrategyRef != null) {
-            aggregationStrategy = routeContext.lookup(aggregationStrategyRef, AggregationStrategy.class);
+            aggregationStrategy = routeContext.mandatoryLookup(aggregationStrategyRef, AggregationStrategy.class);
         }
         if (aggregationStrategy == null) {
             enricher.setDefaultAggregationStrategy();

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerDefinition.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerDefinition.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerDefinition.java
Tue Sep 25 11:34:25 2012
@@ -218,7 +218,7 @@ public class IdempotentConsumerDefinitio
      */
     protected IdempotentRepository<?> resolveMessageIdRepository(RouteContext routeContext)
{
         if (messageIdRepositoryRef != null) {
-            idempotentRepository = routeContext.lookup(messageIdRepositoryRef, IdempotentRepository.class);
+            idempotentRepository = routeContext.mandatoryLookup(messageIdRepositoryRef, IdempotentRepository.class);
         }
         return idempotentRepository;
     }

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/LoadBalancerDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/LoadBalancerDefinition.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/LoadBalancerDefinition.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/LoadBalancerDefinition.java
Tue Sep 25 11:34:25 2012
@@ -56,7 +56,7 @@ public class LoadBalancerDefinition exte
     public static LoadBalancer getLoadBalancer(RouteContext routeContext, LoadBalancerDefinition
type, String ref) {
         if (type == null) {
             ObjectHelper.notNull(ref, "ref or loadBalancer");
-            LoadBalancer loadBalancer = routeContext.lookup(ref, LoadBalancer.class);
+            LoadBalancer loadBalancer = routeContext.mandatoryLookup(ref, LoadBalancer.class);
             if (loadBalancer instanceof LoadBalancerDefinition) {
                 type = (LoadBalancerDefinition) loadBalancer;
             } else {

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/MulticastDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/MulticastDefinition.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/MulticastDefinition.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/MulticastDefinition.java
Tue Sep 25 11:34:25 2012
@@ -209,7 +209,7 @@ public class MulticastDefinition extends
 
     protected Processor createCompositeProcessor(RouteContext routeContext, List<Processor>
list) throws Exception {
         if (strategyRef != null) {
-            aggregationStrategy = routeContext.lookup(strategyRef, AggregationStrategy.class);
+            aggregationStrategy = routeContext.mandatoryLookup(strategyRef, AggregationStrategy.class);
         }
         if (aggregationStrategy == null) {
             // default to use latest aggregation strategy

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/PollEnrichDefinition.java
Tue Sep 25 11:34:25 2012
@@ -103,7 +103,7 @@ public class PollEnrichDefinition extend
         }
 
         if (aggregationStrategyRef != null) {
-            aggregationStrategy = routeContext.lookup(aggregationStrategyRef, AggregationStrategy.class);
+            aggregationStrategy = routeContext.mandatoryLookup(aggregationStrategyRef, AggregationStrategy.class);
         }
         if (aggregationStrategy == null) {
             enricher.setDefaultAggregationStrategy();

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/ProcessDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/ProcessDefinition.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/ProcessDefinition.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/ProcessDefinition.java
Tue Sep 25 11:34:25 2012
@@ -86,8 +86,7 @@ public class ProcessDefinition extends N
         Processor answer = processor;
         if (processor == null) {
             ObjectHelper.notNull(ref, "ref", this);
-            answer = routeContext.lookup(getRef(), Processor.class);
-            ObjectHelper.notNull(answer, "registry entry called " + getRef(), this);
+            answer = routeContext.mandatoryLookup(getRef(), Processor.class);
         }
 
         // ensure its wrapped in a Service so we can manage it from eg. JMX

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/RecipientListDefinition.java
Tue Sep 25 11:34:25 2012
@@ -164,7 +164,7 @@ public class RecipientListDefinition<Typ
     
     private AggregationStrategy createAggregationStrategy(RouteContext routeContext) {
         if (aggregationStrategy == null && strategyRef != null) {
-            aggregationStrategy = routeContext.lookup(strategyRef, AggregationStrategy.class);
+            aggregationStrategy = routeContext.mandatoryLookup(strategyRef, AggregationStrategy.class);
         }
         if (aggregationStrategy == null) {
             // fallback to use latest

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/model/WireTapDefinition.java
Tue Sep 25 11:34:25 2012
@@ -97,7 +97,7 @@ public class WireTapDefinition<Type exte
         WireTapProcessor answer = new WireTapProcessor(endpoint, target, getPattern(), threadPool,
shutdownThreadPool);
         answer.setCopy(isCopy());
         if (newExchangeProcessorRef != null) {
-            newExchangeProcessor = routeContext.lookup(newExchangeProcessorRef, Processor.class);
+            newExchangeProcessor = routeContext.mandatoryLookup(newExchangeProcessorRef,
Processor.class);
         }
         if (newExchangeProcessor != null) {
             answer.addNewExchangeProcessor(newExchangeProcessor);

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/spi/RouteContext.java
Tue Sep 25 11:34:25 2012
@@ -89,6 +89,15 @@ public interface RouteContext extends Ru
     <T> T lookup(String name, Class<T> type);
 
     /**
+     * lookup an object by name and type or throws {@link org.apache.camel.NoSuchBeanException}
if not found.
+     *
+     * @param name  the name to lookup
+     * @param type  the expected type
+     * @return the found object
+     */
+    <T> T mandatoryLookup(String name, Class<T> type);
+
+    /**
      * lookup objects by type
      *
      * @param type the expected type

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
Tue Sep 25 11:34:25 2012
@@ -110,7 +110,7 @@ public final class CamelContextHelper {
 
     /**
      * Look up the given named bean in the {@link org.apache.camel.spi.Registry} on the
-     * {@link CamelContext} or throws NoSuchBeanException if not found.
+     * {@link CamelContext} or throws {@link NoSuchBeanException} if not found.
      */
     public static Object mandatoryLookup(CamelContext context, String name) {
         Object answer = lookup(context, name);

Modified: camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/model/ProcessorTypeConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/model/ProcessorTypeConfigurationTest.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/model/ProcessorTypeConfigurationTest.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/model/ProcessorTypeConfigurationTest.java
Tue Sep 25 11:34:25 2012
@@ -34,7 +34,7 @@ public class ProcessorTypeConfigurationT
             });
             fail("Should have thrown IllegalArgumentException");
         } catch (FailedToCreateRouteException e) {
-            assertEquals("registry entry called hello must be specified on: process[ref:hello]",
e.getCause().getMessage());
+            assertEquals("No bean could be found in the registry for: hello of type: org.apache.camel.Processor",
e.getCause().getMessage());
         }
     }
 

Modified: camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java
Tue Sep 25 11:34:25 2012
@@ -17,6 +17,7 @@
 package org.apache.camel.spring.config;
 
 import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.NoSuchBeanException;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spring.SpringTestSupport;
 import org.springframework.context.support.AbstractXmlApplicationContext;
@@ -34,8 +35,8 @@ public class ErrorHandlerCamelContextRef
             fail("Should have thrown an exception");
         } catch (RuntimeCamelException e) {
             FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class,
e.getCause());
-            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class,
cause.getCause());
-            assertEquals("ErrorHandlerBuilder with id foo not found in registry.", iae.getMessage());
+            NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause());
+            assertEquals("No bean could be found in the registry for: foo of type: org.apache.camel.builder.ErrorHandlerBuilder",
nsbe.getMessage());
         }
     }
 

Modified: camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java?rev=1389815&r1=1389814&r2=1389815&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java
Tue Sep 25 11:34:25 2012
@@ -17,6 +17,7 @@
 package org.apache.camel.spring.config;
 
 import org.apache.camel.FailedToCreateRouteException;
+import org.apache.camel.NoSuchBeanException;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spring.SpringTestSupport;
 import org.springframework.context.support.AbstractXmlApplicationContext;
@@ -33,8 +34,8 @@ public class ErrorHandlerRouteContextRef
             super.setUp();
         } catch (RuntimeCamelException e) {
             FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class,
e.getCause());
-            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class,
cause.getCause());
-            assertEquals("ErrorHandlerBuilder with id bar not found in registry.", iae.getMessage());
+            NoSuchBeanException nsbe = assertIsInstanceOf(NoSuchBeanException.class, cause.getCause());
+            assertEquals("No bean could be found in the registry for: bar of type: org.apache.camel.builder.ErrorHandlerBuilder",
nsbe.getMessage());
         }
     }
 



Mime
View raw message