You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/03/16 09:51:53 UTC

svn commit: r923631 - in /camel/trunk/examples/camel-example-cafe/src/main: java/org/apache/camel/example/cafe/Customer.java resources/META-INF/spring/camel-context.xml

Author: ningjiang
Date: Tue Mar 16 08:51:53 2010
New Revision: 923631

URL: http://svn.apache.org/viewvc?rev=923631&view=rev
Log:
CAMEL-2553 Added a Customer bean which can keep send order to the camel-example-cafe route

Added:
    camel/trunk/examples/camel-example-cafe/src/main/java/org/apache/camel/example/cafe/Customer.java   (with props)
Modified:
    camel/trunk/examples/camel-example-cafe/src/main/resources/META-INF/spring/camel-context.xml

Added: camel/trunk/examples/camel-example-cafe/src/main/java/org/apache/camel/example/cafe/Customer.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cafe/src/main/java/org/apache/camel/example/cafe/Customer.java?rev=923631&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-cafe/src/main/java/org/apache/camel/example/cafe/Customer.java (added)
+++ camel/trunk/examples/camel-example-cafe/src/main/java/org/apache/camel/example/cafe/Customer.java Tue Mar 16 08:51:53 2010
@@ -0,0 +1,67 @@
+/**
+ * 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.example.cafe;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.beans.factory.InitializingBean;
+
+public class Customer extends RouteBuilder implements InitializingBean, CamelContextAware {
+    private CamelContext camelContext;
+
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+        
+    }
+
+    public void afterPropertiesSet() throws Exception {
+        if (camelContext != null) {
+            // setup a timer to send the cafe order
+            camelContext.addRoutes(this);
+        }
+    }
+
+    @Override
+    public void configure() throws Exception {
+        from("timer://myTimer?fixedRate=true&period=60000")
+            .process(new Processor() {
+                
+                public void process(Exchange exchange) throws Exception {
+                    Order order = new Order(2);
+                    order.addItem(DrinkType.ESPRESSO, 2, true);
+                    order.addItem(DrinkType.CAPPUCCINO, 4, false);
+                    order.addItem(DrinkType.LATTE, 4, false);
+                    order.addItem(DrinkType.MOCHA, 2, false);
+                    exchange.getIn().setBody(order);
+                }
+            })
+            .to("direct:cafe");
+        
+    }
+    
+    
+    
+    
+
+}

Propchange: camel/trunk/examples/camel-example-cafe/src/main/java/org/apache/camel/example/cafe/Customer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/examples/camel-example-cafe/src/main/java/org/apache/camel/example/cafe/Customer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/examples/camel-example-cafe/src/main/resources/META-INF/spring/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cafe/src/main/resources/META-INF/spring/camel-context.xml?rev=923631&r1=923630&r2=923631&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cafe/src/main/resources/META-INF/spring/camel-context.xml (original)
+++ camel/trunk/examples/camel-example-cafe/src/main/resources/META-INF/spring/camel-context.xml Tue Mar 16 08:51:53 2010
@@ -23,6 +23,8 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
  
   <import resource="classpath:META-INF/beans.xml"/>
+  
+  <bean id="customer" class="org.apache.camel.example.cafe.Customer"/>
  
   <camelContext id="camel"
                 xmlns="http://camel.apache.org/schema/spring">