...
Method | Description |
---|---|
mockEndpoints | Is used to easily mock all endpoints. See more details and examples at Mock. |
mockEndpoints(pattern) | Is used to easily mock endpoints using a pattern. See more details and examples at Mock. See below for pattern matching. |
weaveById(pattern) | Is used to select node(s) matching by id's, and weave in the following nodes. See below for pattern matching and examples. |
weaveByToString(pattern) | Is used to select nodes(s) matching by their |
weaveByType(Class) | Camel 2.8: Is used to select node(s) matching by their class type (the classes from the org.apache.camel.model package), and weave in the following nodes. See below for examples. |
The pattern
option is used for matching. It uses the same rules as the Intercept, which is applied in the following order:
...
In the example above, we add the following nodes to("mock:a").transform(constant("Bye World"))
after the node with the id "bar"
.
Using weaveByToString
The weaceByToString
weaveByToString
also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to weaveById
, this method uses the toString
representation of the node(s) when matching. This allows you to match nodes, which may not have assigned ids, or to match EIP pattern.
You have to be a bit more careful when using this as the toString
representation can be verbose and contain characters such as [ ] ( ) -> and so forth. That is why using the regular expression matching is the must useable.
...
Notice that we have to use ".*foo.*"
in the pattern to match that "foo"
is present anywhere in the string.
Using weaveByType
Available as of Camel 2.8
The weaveByToType
also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to weaveById
, and weaveByToString
this method uses the class type of the node(s) when matching. This allows you to match EIP pattern by its type.
The weaveByToType
has the same methods as weaceById
and weaveByToString
.
For example to remove a transform from the following route:
Wiki Markup |
---|
{snippet:id=e5|lang=java|title=Route|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTypeTest.java} |
You can do:
Wiki Markup |
---|
{snippet:id=e2|lang=java|title=Remove|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTypeTest.java} |