You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/08/17 08:46:43 UTC

svn commit: r566936 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/model/ examples/camel-example-spring/src/data/ examples/camel-example-spring/src/main/java/org/apache/camel/example/spring/

Author: jstrachan
Date: Thu Aug 16 23:46:42 2007
New Revision: 566936

URL: http://svn.apache.org/viewvc?view=rev&rev=566936
Log:
provided a bean() method on the DSL in addition to the beanRef() method so folks can easily bind to a bean in the DSL. Also made the camel-example-spring a little more interesting, sending messages by default

Added:
    activemq/camel/trunk/examples/camel-example-spring/src/data/
    activemq/camel/trunk/examples/camel-example-spring/src/data/message1.xml   (with props)
    activemq/camel/trunk/examples/camel-example-spring/src/data/message2.xml   (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
    activemq/camel/trunk/examples/camel-example-spring/src/main/java/org/apache/camel/example/spring/MyRouteBuilder.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?view=diff&rev=566936&r1=566935&r2=566936
==============================================================================
--- 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 Thu Aug 16 23:46:42 2007
@@ -551,6 +551,29 @@
      * Adds a bean which is invoked which could be a final destination, or could
      * be a transformation in a pipeline
      */
+    public ProcessorType bean(Object bean) {
+        BeanRef answer = new BeanRef();
+        answer.setBean(bean);
+        addOutput(answer);
+        return this;
+    }
+
+    /**
+     * Adds a bean and method which is invoked which could be a final
+     * destination, or could be a transformation in a pipeline
+     */
+    public ProcessorType bean(Object bean, String method) {
+        BeanRef answer = new BeanRef();
+        answer.setBean(bean);
+        answer.setMethod(method);
+        addOutput(answer);
+        return this;
+    }
+
+    /**
+     * Adds a bean which is invoked which could be a final destination, or could
+     * be a transformation in a pipeline
+     */
     public ProcessorType beanRef(String ref) {
         BeanRef answer = new BeanRef(ref);
         addOutput(answer);

Added: activemq/camel/trunk/examples/camel-example-spring/src/data/message1.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring/src/data/message1.xml?view=auto&rev=566936
==============================================================================
--- activemq/camel/trunk/examples/camel-example-spring/src/data/message1.xml (added)
+++ activemq/camel/trunk/examples/camel-example-spring/src/data/message1.xml Thu Aug 16 23:46:42 2007
@@ -0,0 +1,22 @@
+<?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.
+-->
+<person user="james">
+  <firstName>James</firstName>
+  <lastName>Strachan</lastName>
+  <city>London</city>
+</person>
\ No newline at end of file

Propchange: activemq/camel/trunk/examples/camel-example-spring/src/data/message1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/examples/camel-example-spring/src/data/message2.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring/src/data/message2.xml?view=auto&rev=566936
==============================================================================
--- activemq/camel/trunk/examples/camel-example-spring/src/data/message2.xml (added)
+++ activemq/camel/trunk/examples/camel-example-spring/src/data/message2.xml Thu Aug 16 23:46:42 2007
@@ -0,0 +1,22 @@
+<?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.
+-->
+<person user="hiram">
+  <firstName>Hiram</firstName>
+  <lastName>Chirino</lastName>
+  <city>Tampa</city>
+</person>
\ No newline at end of file

Propchange: activemq/camel/trunk/examples/camel-example-spring/src/data/message2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/examples/camel-example-spring/src/main/java/org/apache/camel/example/spring/MyRouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring/src/main/java/org/apache/camel/example/spring/MyRouteBuilder.java?view=diff&rev=566936&r1=566935&r2=566936
==============================================================================
--- activemq/camel/trunk/examples/camel-example-spring/src/main/java/org/apache/camel/example/spring/MyRouteBuilder.java (original)
+++ activemq/camel/trunk/examples/camel-example-spring/src/main/java/org/apache/camel/example/spring/MyRouteBuilder.java Thu Aug 16 23:46:42 2007
@@ -18,6 +18,7 @@
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.Message;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spring.Main;
 
@@ -27,9 +28,9 @@
  * @version $Revision: 1.1 $
  */
 public class MyRouteBuilder extends RouteBuilder {
-
     /**
      * Allow this route to be run as an application
+     *
      * @param args
      */
     public static void main(String[] args) {
@@ -37,13 +38,22 @@
     }
 
     public void configure() {
-        from("activemq:test.MyQueue").to("file://test");
+        // lets populate the message queue with some messages
+        from("file:src/data?noop=true").
+                to("activemq:test.MyQueue");
+
+        from("activemq:test.MyQueue").
+                to("file://target/test?noop=true");
 
         // set up a listener on the file component
-        from("file://test").process(new Processor() {
-            public void process(Exchange e) {
-                System.out.println("Received exchange: " + e.getIn());
-            }
-        });
+        from("file://target/test?noop=true").
+                bean(new SomeBean());
+    }
+
+    public static class SomeBean {
+
+        public void someMethod(String body) {
+            System.out.println("Received: " + body);
+        }
     }
 }