camel git commit: CAMEL-8683: Using load balancer in onException adds duplicate outputs for each route defined

2015-04-23 Thread davsclaus
Repository: camel
Updated Branches:
  refs/heads/master 963506415 - 22cf585a4


CAMEL-8683: Using load balancer in onException adds duplicate outputs for each 
route defined


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

Branch: refs/heads/master
Commit: 22cf585a4770fcd825c505c16776874d12617dff
Parents: 9635064
Author: Claus Ibsen davscl...@apache.org
Authored: Thu Apr 23 15:48:02 2015 +0200
Committer: Claus Ibsen davscl...@apache.org
Committed: Thu Apr 23 15:48:02 2015 +0200

--
 .../camel/model/LoadBalanceDefinition.java  | 68 ++--
 .../camel/model/LoadBalancerDefinition.java | 36 ---
 .../CustomLoadBalancerDefinition.java   | 24 ++-
 .../AdviceWithOnExceptionAndInterceptTest.java  | 26 
 .../OnExceptionLoadBalancerDoubleIssueTest.java | 58 +
 ...gOnExceptionLoadBalancerDoubleIssueTest.java | 33 ++
 .../OnExceptionLoadBalancerDoubleIssueTest.xml  | 58 +
 7 files changed, 221 insertions(+), 82 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/22cf585a/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
--
diff --git 
a/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java 
b/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
index c2d8291..32ec236 100644
--- a/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
@@ -18,11 +18,9 @@ package org.apache.camel.model;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlElements;
@@ -50,9 +48,6 @@ import org.apache.camel.util.CollectionStringBuffer;
 @XmlRootElement(name = loadBalance)
 @XmlAccessorType(XmlAccessType.FIELD)
 public class LoadBalanceDefinition extends 
ProcessorDefinitionLoadBalanceDefinition {
-@XmlAttribute
-@Deprecated
-private String ref;
 @XmlElements({
 @XmlElement(required = false, name = failover, type = 
FailoverLoadBalancerDefinition.class),
 @XmlElement(required = false, name = random, type = 
RandomLoadBalancerDefinition.class),
@@ -88,21 +83,6 @@ public class LoadBalanceDefinition extends 
ProcessorDefinitionLoadBalanceDefini
 return true;
 }
 
-public String getRef() {
-return ref;
-}
-
-/**
- * To use a custom load balancer.
- * This option is deprecated, use the custom load balancer type instead.
- *
- * @deprecated use custom load balancer
- */
-@Deprecated
-public void setRef(String ref) {
-this.ref = ref;
-}
-
 public LoadBalancerDefinition getLoadBalancerType() {
 return loadBalancerType;
 }
@@ -117,30 +97,26 @@ public class LoadBalanceDefinition extends 
ProcessorDefinitionLoadBalanceDefini
 loadBalancerType = loadbalancer;
 }
 
-protected Processor createOutputsProcessor(RouteContext routeContext,
-CollectionProcessorDefinition? outputs) throws Exception {
-
-LoadBalancer loadBalancer = 
LoadBalancerDefinition.getLoadBalancer(routeContext, loadBalancerType, ref);
-for (ProcessorDefinition? processorType : outputs) {
-Processor processor = createProcessor(routeContext, processorType);
-loadBalancer.addProcessor(processor);
-}
-return loadBalancer;
-}
-
 @Override
 public Processor createProcessor(RouteContext routeContext) throws 
Exception {
-LoadBalancer loadBalancer = 
LoadBalancerDefinition.getLoadBalancer(routeContext, loadBalancerType, ref);
-for (ProcessorDefinition? processorType : getOutputs()) {
-// output must not be another load balancer
-// check for instanceof as the code below as there is compilation 
errors on earlier versions of JDK6
-// on Windows boxes or with IBM JDKs etc.
-if (LoadBalanceDefinition.class.isInstance(processorType)) {
-throw new IllegalArgumentException(Loadbalancer already 
configured to:  + loadBalancerType + . Cannot set it to:  + processorType);
+// the load balancer is stateful so we should only create it once in 
case its used from a context scoped error 

[2/2] camel git commit: CAMEL-8683: Using load balancer in onException adds duplicate outputs for each route defined

2015-04-23 Thread davsclaus
CAMEL-8683: Using load balancer in onException adds duplicate outputs for each 
route defined


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

Branch: refs/heads/camel-2.15.x
Commit: 31fac12620f0b493be51d872acbd8c33e5f2835c
Parents: 7f13dcf
Author: Claus Ibsen davscl...@apache.org
Authored: Thu Apr 23 15:48:02 2015 +0200
Committer: Claus Ibsen davscl...@apache.org
Committed: Thu Apr 23 15:55:19 2015 +0200

--
 .../camel/model/LoadBalanceDefinition.java  | 68 ++--
 .../camel/model/LoadBalancerDefinition.java | 36 ---
 .../CustomLoadBalancerDefinition.java   | 24 ++-
 .../AdviceWithOnExceptionAndInterceptTest.java  | 26 
 .../OnExceptionLoadBalancerDoubleIssueTest.java | 58 +
 ...gOnExceptionLoadBalancerDoubleIssueTest.java | 33 ++
 .../OnExceptionLoadBalancerDoubleIssueTest.xml  | 58 +
 7 files changed, 221 insertions(+), 82 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/camel/blob/31fac126/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
--
diff --git 
a/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java 
b/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
index c2d8291..32ec236 100644
--- a/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
@@ -18,11 +18,9 @@ package org.apache.camel.model;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlElements;
@@ -50,9 +48,6 @@ import org.apache.camel.util.CollectionStringBuffer;
 @XmlRootElement(name = loadBalance)
 @XmlAccessorType(XmlAccessType.FIELD)
 public class LoadBalanceDefinition extends 
ProcessorDefinitionLoadBalanceDefinition {
-@XmlAttribute
-@Deprecated
-private String ref;
 @XmlElements({
 @XmlElement(required = false, name = failover, type = 
FailoverLoadBalancerDefinition.class),
 @XmlElement(required = false, name = random, type = 
RandomLoadBalancerDefinition.class),
@@ -88,21 +83,6 @@ public class LoadBalanceDefinition extends 
ProcessorDefinitionLoadBalanceDefini
 return true;
 }
 
-public String getRef() {
-return ref;
-}
-
-/**
- * To use a custom load balancer.
- * This option is deprecated, use the custom load balancer type instead.
- *
- * @deprecated use custom load balancer
- */
-@Deprecated
-public void setRef(String ref) {
-this.ref = ref;
-}
-
 public LoadBalancerDefinition getLoadBalancerType() {
 return loadBalancerType;
 }
@@ -117,30 +97,26 @@ public class LoadBalanceDefinition extends 
ProcessorDefinitionLoadBalanceDefini
 loadBalancerType = loadbalancer;
 }
 
-protected Processor createOutputsProcessor(RouteContext routeContext,
-CollectionProcessorDefinition? outputs) throws Exception {
-
-LoadBalancer loadBalancer = 
LoadBalancerDefinition.getLoadBalancer(routeContext, loadBalancerType, ref);
-for (ProcessorDefinition? processorType : outputs) {
-Processor processor = createProcessor(routeContext, processorType);
-loadBalancer.addProcessor(processor);
-}
-return loadBalancer;
-}
-
 @Override
 public Processor createProcessor(RouteContext routeContext) throws 
Exception {
-LoadBalancer loadBalancer = 
LoadBalancerDefinition.getLoadBalancer(routeContext, loadBalancerType, ref);
-for (ProcessorDefinition? processorType : getOutputs()) {
-// output must not be another load balancer
-// check for instanceof as the code below as there is compilation 
errors on earlier versions of JDK6
-// on Windows boxes or with IBM JDKs etc.
-if (LoadBalanceDefinition.class.isInstance(processorType)) {
-throw new IllegalArgumentException(Loadbalancer already 
configured to:  + loadBalancerType + . Cannot set it to:  + processorType);
+// the load balancer is stateful so we should only create it once in 
case its used from a context scoped error handler
+
+LoadBalancer loadBalancer =