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 2011/06/04 17:57:30 UTC
svn commit: r1131420 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
test/java/org/apache/camel/processor/intercept/ParentChildInterceptStrategyTest.java
Author: davsclaus
Date: Sat Jun 4 15:57:29 2011
New Revision: 1131420
URL: http://svn.apache.org/viewvc?rev=1131420&view=rev
Log:
CAMEL-4052: JAXB will now invoke setId so we know if its a custom assigned id when defining routes in XML.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/ParentChildInterceptStrategyTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java?rev=1131420&r1=1131419&r2=1131420&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java Sat Jun 4 15:57:29 2011
@@ -34,15 +34,11 @@ import org.apache.camel.spi.NodeIdFactor
* @version
*/
@XmlType(name = "optionalIdentifiedDefinition")
-@XmlAccessorType(XmlAccessType.FIELD)
+@XmlAccessorType(XmlAccessType.PROPERTY)
public abstract class OptionalIdentifiedDefinition<T extends OptionalIdentifiedDefinition<T>> {
- @XmlAttribute
- @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
- @XmlID
private String id;
@XmlTransient
private boolean customId;
- @XmlElement
private DescriptionDefinition description;
/**
@@ -55,6 +51,9 @@ public abstract class OptionalIdentified
/**
* Sets the value of the id property.
*/
+ @XmlAttribute
+ @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
+ @XmlID
public void setId(String value) {
this.id = value;
customId = true;
@@ -64,6 +63,7 @@ public abstract class OptionalIdentified
return description;
}
+ @XmlElement
public void setDescription(DescriptionDefinition description) {
this.description = description;
}
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/ParentChildInterceptStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/ParentChildInterceptStrategyTest.java?rev=1131420&r1=1131419&r2=1131420&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/ParentChildInterceptStrategyTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/ParentChildInterceptStrategyTest.java Sat Jun 4 15:57:29 2011
@@ -52,7 +52,8 @@ public class ParentChildInterceptStrateg
assertEquals("Parent when2 -> target task-d", LIST.get(3));
assertEquals("Parent otherwise -> target task-e", LIST.get(4));
assertEquals("Parent route -> target choice", LIST.get(5));
- assertEquals("Parent route -> target task-done", LIST.get(6));
+ // the last one has no custom id so its using its label instead
+ assertEquals("Parent route -> target mock:done", LIST.get(6));
}
@Override
@@ -73,7 +74,7 @@ public class ParentChildInterceptStrateg
.otherwise().id("otherwise")
.to("mock:e").id("task-e")
.end()
- .to("mock:done").id("task-done");
+ .to("mock:done");
}
};
}
@@ -83,8 +84,12 @@ public class ParentChildInterceptStrateg
@Override
public Processor wrapProcessorInInterceptors(final CamelContext context, final ProcessorDefinition<?> definition,
final Processor target, final Processor nextTarget) throws Exception {
- String targetId = definition.getId();
- String parentId = definition.getParent() != null ? definition.getParent().getId() : "";
+ String targetId = definition.hasCustomIdAssigned() ? definition.getId() : definition.getLabel();
+ ProcessorDefinition parent = definition.getParent();
+ String parentId = "";
+ if (parent != null) {
+ parentId = parent.hasCustomIdAssigned() ? parent.getId() : parent.getLabel();
+ }
LIST.add("Parent " + parentId + " -> target " + targetId);