Author: hadrian
Date: Fri Aug 8 11:08:33 2008
New Revision: 684032
URL: http://svn.apache.org/viewvc?rev=684032&view=rev
Log:
CAMEL-801. Patch applied with many thanks!
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/header/
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/header/HeaderLanguage.java
activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/header
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithArrayHeaderTest.java
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRecipientListWithArrayHeaderTest.java
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithArrayHeader.xml
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/DeadLetterChannel.java
Added:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/header/HeaderLanguage.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/header/HeaderLanguage.java?rev=684032&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/header/HeaderLanguage.java
(added)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/language/header/HeaderLanguage.java
Fri Aug 8 11:08:33 2008
@@ -0,0 +1,42 @@
+/**
+ * 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.language.header;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
+import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.builder.PredicateBuilder;
+import org.apache.camel.spi.Language;
+
+/**
+ * A language for header expressions.
+ */
+public class HeaderLanguage implements Language {
+
+ public static Expression<Exchange> header(String headerName) {
+ return ExpressionBuilder.headerExpression(headerName);
+ }
+
+ public Predicate<Exchange> createPredicate(String expression) {
+ return PredicateBuilder.toPredicate(createExpression(expression));
+ }
+
+ public Expression<Exchange> createExpression(String expression) {
+ return HeaderLanguage.header(expression);
+ }
+}
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=684032&r1=684031&r2=684032&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
Fri Aug 8 11:08:33 2008
@@ -371,12 +371,12 @@
* href="http://activemq.apache.org/camel/recipient-list.html">Recipient
* List</a> pattern.
*
- * @param receipients is the builder of the expression used in the
+ * @param recipients is the builder of the expression used in the
* [EMAIL PROTECTED]
org.apache.camel.processor.RecipientList}
* to decide the destinations
*/
- public Type recipientList(Expression receipients) {
- RecipientListType answer = new RecipientListType(receipients);
+ public Type recipientList(Expression recipients) {
+ RecipientListType answer = new RecipientListType(recipients);
addOutput(answer);
return (Type) this;
}
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java?rev=684032&r1=684031&r2=684032&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
Fri Aug 8 11:08:33 2008
@@ -103,7 +103,7 @@
return data.sync;
}
- // if the exchange is transacted then let the underlysing system
handle the redelivery etc.
+ // if the exchange is transacted then let the underlying system
handle the redelivery etc.
// this DeadLetterChannel is only for non transacted exchanges
if (exchange.isTransacted() && exchange.getException() != null) {
if (LOG.isDebugEnabled()) {
Added:
activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/header
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/header?rev=684032&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/header
(added)
+++
activemq/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/language/header
Fri Aug 8 11:08:33 2008
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.language.header.HeaderLanguage
Added:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithArrayHeaderTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithArrayHeaderTest.java?rev=684032&view=auto
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithArrayHeaderTest.java
(added)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithArrayHeaderTest.java
Fri Aug 8 11:08:33 2008
@@ -0,0 +1,58 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class RecipientListWithArrayHeaderTest extends ContextTestSupport {
+
+ public void testSendingAMessageUsingMulticastReceivesItsOwnExchange()
throws Exception {
+ MockEndpoint x = getMockEndpoint("mock:x");
+ MockEndpoint y = getMockEndpoint("mock:y");
+ MockEndpoint z = getMockEndpoint("mock:z");
+
+ x.expectedBodiesReceived("answer");
+ y.expectedBodiesReceived("answer");
+ z.expectedBodiesReceived("answer");
+
+ sendBody();
+
+ assertMockEndpointsSatisifed();
+ }
+
+ protected void sendBody() {
+ template.sendBodyAndHeader("direct:a", "answer", "recipientListHeader",
+ new String[] {"mock:x", "mock:y", "mock:z"});
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ // START SNIPPET: example
+ from("direct:a").recipientList(header("recipientListHeader"));
+ // END SNIPPET: example
+ }
+ };
+
+ }
+
+}
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRecipientListWithArrayHeaderTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRecipientListWithArrayHeaderTest.java?rev=684032&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRecipientListWithArrayHeaderTest.java
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRecipientListWithArrayHeaderTest.java
Fri Aug 8 11:08:33 2008
@@ -0,0 +1,28 @@
+/**
+ * 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.processor.RecipientListWithArrayHeaderTest;
+import static
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringRecipientListWithArrayHeaderTest extends
RecipientListWithArrayHeaderTest {
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this,
+
"org/apache/camel/spring/processor/recipientListWithArrayHeader.xml");
+ }
+}
Added:
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithArrayHeader.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithArrayHeader.xml?rev=684032&view=auto
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithArrayHeader.xml
(added)
+++
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithArrayHeader.xml
Fri Aug 8 11:08:33 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
+ ">
+
+ <!--
+ from("direct:a").recipientList(header("recipientListHeader"));
+ -->
+ <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="direct:a"/>
+ <recipientList>
+ <header>recipientListHeader</header>
+ </recipientList>
+ </route>
+ </camelContext>
+
+</beans>