Author: davsclaus Date: Sat Jun 11 08:13:59 2011 New Revision: 1134549 URL: http://svn.apache.org/viewvc?rev=1134549&view=rev Log: CAMEL-4044: Polished
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java?rev=1134549&r1=1134548&r2=1134549&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java Sat Jun 11 08:13:59 2011 @@ -238,7 +238,7 @@ public class RouteService extends Servic protected void startChildService(Route route, List<Service> services) throws Exception { for (Service service : services) { - LOG.debug("Starting {}", service); + LOG.debug("Starting child service on route: {} -> {}", route.getId(), service); for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) { strategy.onServiceAdd(camelContext, service, route); } @@ -249,6 +249,7 @@ public class RouteService extends Servic protected void stopChildService(Route route, Set<Service> services, boolean shutdown) throws Exception { for (Service service : services) { + LOG.debug("Stopping child service on route: {} -> {}", route.getId(), service); for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) { strategy.onServiceRemove(camelContext, service, route); } Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java?rev=1134549&r1=1134548&r2=1134549&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java Sat Jun 11 08:13:59 2011 @@ -18,7 +18,6 @@ package org.apache.camel.model; import java.util.AbstractList; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; @@ -34,6 +33,7 @@ import org.apache.camel.processor.Choice import org.apache.camel.processor.FilterProcessor; import org.apache.camel.spi.RouteContext; import org.apache.camel.util.CollectionStringBuffer; +import org.apache.camel.util.ObjectHelper; /** * Represents an XML <choice/> element @@ -53,7 +53,10 @@ public class ChoiceDefinition extends Pr @Override public List<ProcessorDefinition> getOutputs() { + // wrap the outputs into a list where we can on the inside control the when/otherwise + // but make it appear as a list on the outside return new AbstractList<ProcessorDefinition>() { + public ProcessorDefinition get(int index) { if (index < whenClauses.size()) { return whenClauses.get(index); @@ -61,8 +64,9 @@ public class ChoiceDefinition extends Pr if (index == whenClauses.size()) { return otherwise; } - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException("Index " + index + " is out of bounds with size " + size()); } + public boolean add(ProcessorDefinition def) { if (def instanceof WhenDefinition) { return whenClauses.add((WhenDefinition)def); @@ -70,28 +74,34 @@ public class ChoiceDefinition extends Pr otherwise = (OtherwiseDefinition)def; return true; } - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Expected either a WhenDefinition or OtherwiseDefinition but was " + + ObjectHelper.classCanonicalName(def)); } + public int size() { return whenClauses.size() + (otherwise == null ? 0 : 1); } + public void clear() { whenClauses.clear(); otherwise = null; } + public ProcessorDefinition set(int index, ProcessorDefinition element) { if (index < whenClauses.size()) { if (element instanceof WhenDefinition) { return whenClauses.set(index, (WhenDefinition)element); } - throw new IllegalArgumentException(); + throw new IllegalArgumentException("Expected WhenDefinition but was " + + ObjectHelper.classCanonicalName(element)); } else if (index == whenClauses.size()) { ProcessorDefinition old = otherwise; otherwise = (OtherwiseDefinition)element; return old; } - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException("Index " + index + " is out of bounds with size " + size()); } + public ProcessorDefinition remove(int index) { if (index < whenClauses.size()) { return whenClauses.remove(index); @@ -100,7 +110,7 @@ public class ChoiceDefinition extends Pr otherwise = null; return old; } - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException("Index " + index + " is out of bounds with size " + size()); } }; }