Author: ningjiang
Date: Sat Jun 7 22:05:31 2008
New Revision: 664441
URL: http://svn.apache.org/viewvc?rev=664441&view=rev
Log:
CAMEL-475 patch applied with thanks to Jonathan
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java
(with props)
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setBody.xml
(with props)
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java
(with props)
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml
(with props)
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/idempotent/MemoryMessageIdRepository.java
activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyAggregationStrategy.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=664441&r1=664440&r2=664441&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
Sat Jun 7 22:05:31 2008
@@ -1121,7 +1121,8 @@
*/
public ExpressionClause<ProcessorType<Type>> setBody() {
ExpressionClause<ProcessorType<Type>> clause = new
ExpressionClause<ProcessorType<Type>>((Type) this);
- process(ProcessorBuilder.setBody(clause));
+ SetBodyType answer = new SetBodyType(clause);
+ addOutput(answer);
return clause;
}
@@ -1129,7 +1130,9 @@
* Adds a processor which sets the body on the IN message
*/
public Type setBody(Expression expression) {
- return process(ProcessorBuilder.setBody(expression));
+ SetBodyType answer = new SetBodyType(expression);
+ addOutput(answer);
+ return (Type) this;
}
/**
@@ -1165,8 +1168,7 @@
* Adds a processor which sets the body on the OUT message
*/
public ExpressionClause<ProcessorType<Type>> transform() {
- ExpressionClause<ProcessorType<Type>> clause = new
ExpressionClause<ProcessorType<Type>>(
- (Type) this);
+ ExpressionClause<ProcessorType<Type>> clause = new
ExpressionClause<ProcessorType<Type>>((Type) this);
TransformType answer = new TransformType(clause);
addOutput(answer);
return clause;
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java?rev=664441&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java
(added)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java
Sat Jun 7 22:05:31 2008
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.ProcessorBuilder;
+import org.apache.camel.spi.RouteContext;
+
+/**
+ * Represents an XML <setBody/> element.
+ */
[EMAIL PROTECTED](name = "setBody")
[EMAIL PROTECTED](XmlAccessType.FIELD)
+public class SetBodyType extends ExpressionNode {
+
+ public SetBodyType() {
+ }
+
+ public SetBodyType(Expression expression) {
+ super(expression);
+ }
+
+ @Override
+ public String toString() {
+ return "SetBody[ " + getExpression() + "]";
+ }
+
+ @Override
+ public Processor createProcessor(RouteContext routeContext) throws
Exception {
+ Expression expr = getExpression().createExpression(routeContext);
+ return ProcessorBuilder.setBody(expr);
+ }
+}
Propchange:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/idempotent/MemoryMessageIdRepository.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/idempotent/MemoryMessageIdRepository.java?rev=664441&r1=664440&r2=664441&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/idempotent/MemoryMessageIdRepository.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/idempotent/MemoryMessageIdRepository.java
Sat Jun 7 22:05:31 2008
@@ -36,7 +36,7 @@
}
/**
- * Creates a new MemoryMessageIdRepository with a memory based respository.
+ * Creates a new MemoryMessageIdRepository with a memory based repository.
* <b>Warning</b> this method should only really be used for testing as it
* will involve keeping all message IDs in RAM.
*/
@@ -45,7 +45,7 @@
}
/**
- * Creates a new MemoryMessageIdRepository with a memory based respository.
+ * Creates a new MemoryMessageIdRepository with a memory based repository.
* <b>Warning</b> this method should only really be used for testing as it
* will involve keeping all message IDs in RAM.
*/
@@ -55,7 +55,7 @@
/**
* Creates a new MemoryMessageIdRepository using the given [EMAIL
PROTECTED] Map} to
- * use to store the processed Message ID objects. Warning be cafeful of the
+ * use to store the processed Message ID objects. Warning be careful of the
* implementation of Map you use as if you are not careful it could be a
* memory leak.
*/
Modified:
activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index?rev=664441&r1=664440&r2=664441&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
(original)
+++
activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
Sat Jun 7 22:05:31 2008
@@ -45,6 +45,7 @@
RoutesType
RoutingSlipType
ServiceActivationType
+SetBodyType
SetHeaderType
SplitterType
ThrottlerType
Modified:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java?rev=664441&r1=664440&r2=664441&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
(original)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
Sat Jun 7 22:05:31 2008
@@ -88,6 +88,14 @@
assertExpression(node.getExpression(), "simple", "${in.body} extra
data!");
assertChildTo(route, "mock:end", 1);
}
+
+ public void testParseSetBodyXml() throws Exception {
+ RouteType route = assertOneRoute("setBody.xml");
+ assertFrom(route, "direct:start");
+ SetBodyType node = assertSetBody(route);
+ assertExpression(node.getExpression(), "simple", "${in.body} extra
data!");
+ assertChildTo(route, "mock:end", 1);
+ }
public void testParseSetHeaderXml() throws Exception {
RouteType route = assertOneRoute("setHeader.xml");
@@ -292,7 +300,12 @@
protected TransformType assertTransform(ProcessorType<?> route) {
ProcessorType<?> processor = route.getOutputs().get(0);
return assertIsInstanceOf(TransformType.class, processor);
- }
+ }
+
+ protected SetBodyType assertSetBody(ProcessorType<?> route) {
+ ProcessorType<?> processor = route.getOutputs().get(0);
+ return assertIsInstanceOf(SetBodyType.class, processor);
+ }
protected ChoiceType assertChoice(ProcessorType<?> route) {
ProcessorType<?> processor = assertOneElement(route.getOutputs());
Modified:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyAggregationStrategy.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyAggregationStrategy.java?rev=664441&r1=664440&r2=664441&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyAggregationStrategy.java
(original)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyAggregationStrategy.java
Sat Jun 7 22:05:31 2008
@@ -36,7 +36,7 @@
}
/**
- * An expression used to determine if the aggreagation is complete
+ * An expression used to determine if the aggregation is complete
*/
public boolean isCompleted(@Header(name = "aggregated")
Integer aggregated) {
Added:
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setBody.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setBody.xml?rev=664441&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setBody.xml
(added)
+++
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setBody.xml
Sat Jun 7 22:05:31 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<routes id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="direct:start"/>
+ <setBody>
+ <simple>${in.body} extra data!</simple>
+ </setBody>
+ <to uri="mock:end"/>
+ </route>
+</routes>
Propchange:
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setBody.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setBody.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/camel-core/src/test/resources/org/apache/camel/model/setBody.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java?rev=664441&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java
Sat Jun 7 22:05:31 2008
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import static
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringSetBodyTest extends ContextTestSupport {
+
+ public void testSendAMessageWhosInBodyIsTransformed() throws Exception {
+ MockEndpoint resultEndpoint = getMockEndpoint("mock:end");
+ resultEndpoint.expectedBodiesReceived("Hello World!");
+
+ sendBody("direct:start", "Hello");
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this,
"org/apache/camel/spring/processor/setBody.xml");
+ }
+}
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml?rev=664441&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml
Sat Jun 7 22:05:31 2008
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <!-- START SNIPPET: example -->
+ <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="direct:start"/>
+ <setBody>
+ <simple>${in.body} World!</simple>
+ </setBody>
+ <to uri="mock:end"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+
+</beans>
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml