activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r521058 - in /activemq/camel/trunk/camel-spring: ./ src/main/resources/org/apache/camel/spring/ src/test/java/org/apache/camel/spring/ src/test/java/org/apache/camel/xbean/ src/test/resources/org/apache/camel/spring/ src/test/resources/org/...
Date Thu, 22 Mar 2007 00:49:27 GMT
Author: chirino
Date: Wed Mar 21 17:49:27 2007
New Revision: 521058

URL: http://svn.apache.org/viewvc?view=rev&rev=521058
Log:
Got the <process> element working

Added:
    activemq/camel/trunk/camel-spring/README.txt
    activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringRouteBuilderTest.java
    activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/examples.xml
    activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/spring_route_builder_test.xml
Removed:
    activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/xbean/
    activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/xbean/
Modified:
    activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd

Added: activemq/camel/trunk/camel-spring/README.txt
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/README.txt?view=auto&rev=521058
==============================================================================
--- activemq/camel/trunk/camel-spring/README.txt (added)
+++ activemq/camel/trunk/camel-spring/README.txt Wed Mar 21 17:49:27 2007
@@ -0,0 +1,36 @@
+=============================================================================
+ Camel Spring Integration
+=============================================================================
+
+Overview
+--------------------------------------------------------------------------
+ 
+ This module provides a nice Spring 2.0 xml extension so that you can 
+ build Camel routes in spring with a very consice XML format that is very
+ similar the to Camel Fluid api.
+
+ Where in Java you would do a:
+
+   from("queue:a").to("queue:b")
+
+ The spring configuration equivalent would be as follows:
+
+   <route>
+     <from uri="queue:a"/>
+     <to uri="queue:b"/>
+   </route>
+
+Developers
+--------------------------------------------------------------------------
+ 
+ As new features are added to the Camel builders, you will need to 
+ update the XSD that spring uses to validate the XML syntax.  I think the
+ easiest way to do that is to generate the XSD from an example XML file.
+ 
+ I've been using trang for that purpose.  Once installed, you can run:
+ 
+   trang -I xml -O xsd src/test/resources/org/apache/camel/spring/examples.xml src/main/resources/org/apache/camel/spring/generated-camel-1.0.xsd
+
+ To generate the XSD, there are some spring specifics mostly in the header
+ that trang does not get right, so then what's left is a manual  cut and paste from 
+ the generated-camel-1.0.xsd to the camel-1.0.xsd

Modified: activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd?view=diff&rev=521058&r1=521057&r2=521058
==============================================================================
--- activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd
(original)
+++ activemq/camel/trunk/camel-spring/src/main/resources/org/apache/camel/spring/camel-1.0.xsd
Wed Mar 21 17:49:27 2007
@@ -9,37 +9,51 @@
   >
  
   <xs:import namespace="http://www.springframework.org/schema/beans"/>
-
   <xs:element name="routeBuilder">
     <xs:complexType>
       <xs:complexContent>
-          <xs:extension base="s:identifiedType">
-		      <xs:sequence>
-		        <xs:element maxOccurs="unbounded" ref="c:route"/>
-		      </xs:sequence>
-	      </xs:extension>
+        <xs:extension base="s:identifiedType">
+		  <xs:sequence>
+		    <xs:element minOccurs="0" maxOccurs="unbounded" ref="c:route"/>
+		  </xs:sequence>
+	    </xs:extension>
   	  </xs:complexContent>
     </xs:complexType>
   </xs:element>
+  
   <xs:element name="route">
     <xs:complexType>
       <xs:sequence>
         <xs:element ref="c:from"/>
+        <xs:element minOccurs="0" maxOccurs="unbounded" ref="c:intercept"/>
         <xs:element minOccurs="0" ref="c:choice"/>
-        <xs:choice minOccurs="0">
-          <xs:element ref="c:filter"/>
-          <xs:element ref="c:intercept"/>
-        </xs:choice>
+        <xs:element minOccurs="0" maxOccurs="unbounded" ref="c:filter"/>
         <xs:choice minOccurs="0">
           <xs:element ref="c:to"/>
-          <xs:element ref="c:processor"/>
+          <xs:element ref="c:process"/>
         </xs:choice>
       </xs:sequence>
     </xs:complexType>
   </xs:element>
+  
   <xs:element name="from">
     <xs:complexType>
-      <xs:attribute name="uri" use="required" type="xs:NMTOKEN"/>
+      <xs:attribute name="endpoint" type="xs:NMTOKEN"/>
+      <xs:attribute name="endpoints" type="xs:NMTOKEN"/>
+      <xs:attribute name="uri" type="xs:NMTOKEN"/>
+      <xs:attribute name="uris" type="xs:NMTOKEN"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="intercept">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element maxOccurs="unbounded" ref="c:interceptor"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="interceptor">
+    <xs:complexType>
+      <xs:attribute name="interceptor" use="required"/>
     </xs:complexType>
   </xs:element>
   <xs:element name="choice">
@@ -69,18 +83,9 @@
     </xs:complexType>
   </xs:element>
   <xs:element name="filter" type="c:predicate"/>
-  <xs:element name="intercept">
-    <xs:complexType>
-      <xs:sequence>
-        <xs:element maxOccurs="unbounded" ref="s:bean"/>
-      </xs:sequence>
-    </xs:complexType>
-  </xs:element>
-  <xs:element name="processor">
+  <xs:element name="process">
     <xs:complexType>
-      <xs:sequence>
-        <xs:element ref="s:bean"/>
-      </xs:sequence>
+      <xs:attribute name="ref" use="required"/>
     </xs:complexType>
   </xs:element>
   <xs:complexType name="predicate">
@@ -111,7 +116,10 @@
       <xs:sequence>
         <xs:element minOccurs="0" maxOccurs="unbounded" ref="c:uri"/>
       </xs:sequence>
+      <xs:attribute name="endpoint" type="xs:NMTOKEN"/>
+      <xs:attribute name="endpoints" type="xs:NMTOKEN"/>
       <xs:attribute name="uri" type="xs:NMTOKEN"/>
+      <xs:attribute name="uris" type="xs:NMTOKEN"/>
     </xs:complexType>
   </xs:element>
   <xs:element name="uri" type="xs:NMTOKEN"/>

Added: activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringRouteBuilderTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringRouteBuilderTest.java?view=auto&rev=521058
==============================================================================
--- activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringRouteBuilderTest.java
(added)
+++ activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringRouteBuilderTest.java
Wed Mar 21 17:49:27 2007
@@ -0,0 +1,91 @@
+/*
+ * 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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.builder.RouteBuilderTest;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * TODO: re-implement the route building logic using spring and 
+ * then test it by overriding the buildXXX methods in the RouteBuilderTest
+ * 
+ * @version $Revision: 520164 $
+ */
+public class SpringRouteBuilderTest extends RouteBuilderTest {
+	private ClassPathXmlApplicationContext ctx;
+
+	@Override
+	protected void setUp() throws Exception {
+		super.setUp();
+		ctx = new ClassPathXmlApplicationContext("org/apache/camel/spring/spring_route_builder_test.xml");
+	}
+
+	@Override
+	protected void tearDown() throws Exception {
+		ctx.close();
+		super.tearDown();
+	}
+
+	@Override
+	@SuppressWarnings("unchecked")
+	protected RouteBuilder<Exchange> buildSimpleRoute() {
+		RouteBuilder<Exchange> builder = (RouteBuilder<Exchange>) ctx.getBean("buildSimpleRoute");
+		assertNotNull(builder);
+		return builder;
+	}
+	
+	@Override
+	protected RouteBuilder<Exchange> buildCustomProcessor() {
+		myProcessor = (Processor<Exchange>) ctx.getBean("myProcessor");
+		RouteBuilder<Exchange> builder = (RouteBuilder<Exchange>) ctx.getBean("buildCustomProcessor");
+		assertNotNull(builder);
+		return builder;
+	}
+	
+	@Override
+	protected RouteBuilder<Exchange> buildCustomProcessorWithFilter() {
+		// TODO Auto-generated method stub
+		return super.buildCustomProcessorWithFilter();
+	}
+	
+	@Override
+	protected RouteBuilder<Exchange> buildRouteWithInterceptor() {
+		// TODO Auto-generated method stub
+		return super.buildRouteWithInterceptor();
+	}
+	
+	@Override
+	protected RouteBuilder<Exchange> buildSimpleRouteWithChoice() {
+		// TODO Auto-generated method stub
+		return super.buildSimpleRouteWithChoice();
+	}
+	
+	@Override
+	protected RouteBuilder<Exchange> buildSimpleRouteWithHeaderPredicate() {
+		// TODO Auto-generated method stub
+		return super.buildSimpleRouteWithHeaderPredicate();
+	}
+	
+	@Override
+	protected RouteBuilder<Exchange> buildWireTap() {
+		// TODO Auto-generated method stub
+		return super.buildWireTap();
+	}
+}

Added: activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/examples.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/examples.xml?view=auto&rev=521058
==============================================================================
--- activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/examples.xml
(added)
+++ activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/examples.xml
Wed Mar 21 17:49:27 2007
@@ -0,0 +1,126 @@
+<?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.0.xsd
+       http://activemq.apache.org/camel/schema/camel-1.0.xsd http://activemq.apache.org/camel/schema/camel-1.0.xsd
+    ">
+
+    <routeBuilder id="buildSimpleRoute" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+    </routeBuilder>
+    
+    <routeBuilder id="buildSimpleRoute" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+       <route>
+         <from uri="queue:a"/>
+         <to uri="queue:b"/>
+       </route>
+       <route>
+         <from uris="queue:a"/>
+         <to uris="queue:b"/>
+       </route>
+       <route>
+         <from endpoint="queue:a"/>
+         <to endpoint="queue:b"/>
+       </route>
+       <route>
+         <from endpoints="queue:a"/>
+         <to endpoints="queue:b"/>
+       </route>
+
+       <route>
+         <from uri="queue:a"/>
+         <process ref="#myProcessor"/>
+       </route>
+
+       <route>
+         <from uri="queue:a"/>
+         <filter>
+             <predicate>
+                <header name="foo"/>
+                <equalTo value="bar"/>
+             </predicate>
+         </filter>
+         <filter>
+             <predicate>
+                <header name="foo"/>
+                <equalTo value="bar"/>
+             </predicate>
+         </filter>
+         <process ref="#myProcessor"/>
+       </route>
+
+       <route>
+         <from uri="queue:a"/>
+         <intercept>
+         	<interceptor interceptor="#myInterceptor"/>
+         	<interceptor interceptor="#myInterceptor"/>
+         </intercept>
+         <intercept>
+         	<interceptor interceptor="#myInterceptor"/>
+         	<interceptor interceptor="#myInterceptor"/>
+         </intercept>
+         <to uri="queue:b"/>
+       </route>
+
+       <route>
+         <from uri="queue:a"/>
+         <choice>
+             <when>
+                 <predicate>
+                    <header name="foo"/>
+                    <equalTo value="bar"/>
+                 </predicate>
+                 <to uri="queue:b"/>
+             </when>
+             <when>
+                 <predicate>
+                    <header name="foo"/>
+                    <equalTo value="cheese"/>
+                 </predicate>
+                 <to endpoint="queue:c"/>
+             </when>
+             <otherwise>
+                 <to uri="queue:d"/>
+             </otherwise>
+         </choice>
+       </route>
+
+       <route>
+         <from uri="queue:a"/>
+         <filter>
+             <predicate>
+                <header name="foo"/>
+                <equalTo value="bar"/>
+             </predicate>
+         </filter>
+         <to uri="queue:b"/>
+       </route>
+
+       <route>
+         <from uri="queue:a"/>
+         <to>
+            <uri>queue:tap</uri>
+            <uri>queue:a</uri>
+         </to>
+       </route>
+       
+    </routeBuilder>
+
+</beans>
+<!-- END SNIPPET: example -->

Added: activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/spring_route_builder_test.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/spring_route_builder_test.xml?view=auto&rev=521058
==============================================================================
--- activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/spring_route_builder_test.xml
(added)
+++ activemq/camel/trunk/camel-spring/src/test/resources/org/apache/camel/spring/spring_route_builder_test.xml
Wed Mar 21 17:49:27 2007
@@ -0,0 +1,154 @@
+<?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.0.xsd
+       http://activemq.apache.org/camel/schema/camel-1.0.xsd http://activemq.apache.org/camel/schema/camel-1.0.xsd
+    ">
+
+    <!-- 
+        from("queue:a").to("queue:b");
+     -->
+    <routeBuilder id="buildSimpleRoute" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+       <route>
+         <from uri="queue:a"/>
+         <to uri="queue:b"/>
+       </route>
+    </routeBuilder>
+    
+    <!-- 
+        from("queue:a").process(myProcessor);
+     -->
+    <bean id="myProcessor" class="org.apache.camel.builder.MyProcessor"/>
+    <routeBuilder id="buildCustomProcessor" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+       <route>
+         <from uri="queue:a"/>
+         <process ref="#myProcessor"/>
+       </route>
+    </routeBuilder>
+
+    <!-- 
+        from("queue:a").filter(headerEquals("foo", "bar")).process(myProcessor);
+     -->
+    <routeBuilder id="buildCustomProcessorWithFilter" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+    <!-- 
+       <route>
+         <from uri="queue:a"/>
+         <filter>
+             <predicate>
+                <header name="foo"/>
+                <equalTo value="bar"/>
+             </predicate>
+         </filter>
+         <processor>
+           <s:bean class="some.Processor"/>
+         </processor>
+       </route>
+     -->
+    </routeBuilder>
+
+    <!-- 
+        from("queue:a")
+           .intercept()
+              .add(interceptor1)
+              .add(interceptor2)
+           .target().to("queue:d");
+     -->
+    <routeBuilder id="buildRouteWithInterceptor" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+       <!-- 
+       <route>
+         <from uri="queue:a"/>
+         <intercept>
+             <s:bean id="interceptor1" class="some.InterceptorProcessor"/>
+             <s:bean id="interceptor2" class="some.InterceptorProcessor"/>
+         </intercept>
+         <to uri="queue:b"/>
+       </route>
+        -->
+    </routeBuilder>
+
+    <!-- 
+        from("queue:a").choice()
+                .when(header("foo").isEqualTo("bar")).to("queue:b")
+                .when(header("foo").isEqualTo("cheese")).to("queue:c")
+                .otherwise().to("queue:d");
+     -->
+    <routeBuilder id="buildSimpleRouteWithChoice" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+       <!-- 
+       <route>
+         <from uri="queue:a"/>
+         <choice>
+             <when>
+                 <predicate>
+                    <header name="foo"/>
+                    <equalTo value="bar"/>
+                 </predicate>
+                 <to uri="queue:b"/>
+             </when>
+             
+             <when>
+                 <predicate>
+                    <header name="foo"/>
+                    <equalTo value="cheese"/>
+                 </predicate>
+                 <to uri="queue:c"/>
+             </when>
+             <otherwise>
+                 <to uri="queue:d"/>
+             </otherwise>
+         </choice>
+       </route>
+        -->
+    </routeBuilder>
+
+    <!-- 
+        from("queue:a").filter(headerEquals("foo", "bar")).to("queue:b");
+     -->
+    <routeBuilder id="buildSimpleRouteWithHeaderPredicate" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+    <!-- 
+       <route>
+         <from uri="queue:a"/>
+         <filter>
+             <predicate>
+                <header name="foo"/>
+                <equalTo value="bar"/>
+             </predicate>
+         </filter>
+         <to uri="queue:b"/>
+       </route>
+     -->
+    </routeBuilder>
+
+    <!-- 
+        from("queue:a").to("queue:tap", "queue:b");
+     -->
+    <routeBuilder id="buildWireTap" xmlns="http://activemq.apache.org/camel/schema/camel-1.0.xsd">
+    <!-- 
+       <route>
+         <from uri="queue:a"/>
+         <to>
+            <uri>queue:tap</uri>
+            <uri>queue:a</uri>
+         </to>
+       </route>
+     -->
+    </routeBuilder>
+
+</beans>
+<!-- END SNIPPET: example -->



Mime
View raw message