Author: davsclaus
Date: Fri Jan 16 02:13:51 2009
New Revision: 734957

URL: http://svn.apache.org/viewvc?rev=734957&view=rev
Log:
CAMEL-1255: Polished

Modified:
    activemq/camel/trunk/examples/camel-example-tracer/README.txt
    activemq/camel/trunk/examples/camel-example-tracer/build.xml
    activemq/camel/trunk/examples/camel-example-tracer/pom.xml
    
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/Main.java
    
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteAggregator.java
    
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteService.java

Modified: activemq/camel/trunk/examples/camel-example-tracer/README.txt
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-tracer/README.txt?rev=734957&r1=734956&r2=734957&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-tracer/README.txt (original)
+++ activemq/camel/trunk/examples/camel-example-tracer/README.txt Fri Jan 16 
02:13:51 2009
@@ -7,8 +7,9 @@
 You will need to compile this example first:
   mvn compile
   
-For a background in BAM see
+For a background in tracer and JPA see
   http://activemq.apache.org/camel/tracer.html
+  http://activemq.apache.org/camel/jpa.html
 
 To run the example with Maven, type
   mvn camel:run
@@ -67,7 +68,7 @@
 and log4j.properties is located in src/main/resources 
 
 For the latest & greatest documentation on how to use this example please see
-  http://activemq.apache.org/camel/tracer-example.html
+  http://activemq.apache.org/camel/tracer.html
 
 If you hit any problems please let us know on the Camel Forums
   http://activemq.apache.org/camel/discussion-forums.html

Modified: activemq/camel/trunk/examples/camel-example-tracer/build.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-tracer/build.xml?rev=734957&r1=734956&r2=734957&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-tracer/build.xml (original)
+++ activemq/camel/trunk/examples/camel-example-tracer/build.xml Fri Jan 16 
02:13:51 2009
@@ -30,6 +30,7 @@
   <path id="sample.build.classpath">
     <fileset dir="${camel.lib}">
       <include name="**/camel-jpa-*.jar"/>
+      <include name="**/camel-stream-*.jar"/>
       <include name="**/commons-collections-*.jar"/>
       <exclude name="**/*-tests.jar"/>
     </fileset>

Modified: activemq/camel/trunk/examples/camel-example-tracer/pom.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-tracer/pom.xml?rev=734957&r1=734956&r2=734957&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-tracer/pom.xml (original)
+++ activemq/camel/trunk/examples/camel-example-tracer/pom.xml Fri Jan 16 
02:13:51 2009
@@ -42,12 +42,6 @@
             <artifactId>camel-stream</artifactId>
         </dependency>
 
-        <!-- JpaTraceEventMessage have been enhanced by openjpa so we reuse it 
-->
-        <!--dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa-persistence-jdbc</artifactId>
-        </dependency-->
-
         <!-- lets use log4j -->
         <dependency>
             <groupId>commons-logging</groupId>
@@ -84,7 +78,6 @@
             <artifactId>commons-collections</artifactId>
         </dependency>
 
-
         <!-- testing -->
         <dependency>
             <groupId>junit</groupId>

Modified: 
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/Main.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/Main.java?rev=734957&r1=734956&r2=734957&view=diff
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/Main.java
 (original)
+++ 
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/Main.java
 Fri Jan 16 02:13:51 2009
@@ -19,11 +19,12 @@
 /**
  * To start the application from ANT
  */
-public class Main {
+public final class Main {
 
     private Main() {
         // do nothing here
     }
+    
     public static void main(String[] args) {
         org.apache.camel.spring.Main.main(args);
     }

Modified: 
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteAggregator.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteAggregator.java?rev=734957&r1=734956&r2=734957&view=diff
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteAggregator.java
 (original)
+++ 
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteAggregator.java
 Fri Jan 16 02:13:51 2009
@@ -1,15 +1,33 @@
+/**
+ * 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.tracer;
 
-import java.util.Comparator;
-import java.util.List;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
 
-import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.apache.camel.Exchange;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
 
 /**
- *
+ * Our aggregator where we aggregate all the quotes and find the
+ * the best quotes based on the one that has the most cool words
+ * from our cools words list
  */
 public class QuoteAggregator implements AggregationStrategy {
 
@@ -17,23 +35,34 @@
 
     public void setCoolWords(List<String> coolWords) {
         for (String s : coolWords) {
+            // use lower case to be incase sensitive
             this.coolWords.add(s.toLowerCase());
         }
+        // reverse order so indexOf returning -1 will be the last instead
         Collections.reverse(this.coolWords);
     }
 
     public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+        // here we aggregate
+        // oldExchange is the current "winner"
+        // newExchange is the new candidate
+
+        // we get the quotes of the two exchanges
         String oldQute = oldExchange.getIn().getBody(String.class);
         String newQute = newExchange.getIn().getBody(String.class);
 
+        // now we compare the two and get a result indicate the best one
         int result = new QuoteComparator().compare(oldQute, newQute);
 
+        // we return the winner
         return result > 0 ? newExchange : oldExchange;
     }
 
     private class QuoteComparator implements Comparator<String> {
 
         public int compare(java.lang.String o1, java.lang.String o2) {
+            // here we compare the two quotes and picks the one that
+            // is in the top of the cool words list
             int index1 = coolWords.indexOf(o1.toLowerCase());
             int index2 = coolWords.indexOf(o2.toLowerCase());
 

Modified: 
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteService.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteService.java?rev=734957&r1=734956&r2=734957&view=diff
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteService.java
 (original)
+++ 
activemq/camel/trunk/examples/camel-example-tracer/src/main/java/org/apache/camel/example/tracer/QuoteService.java
 Fri Jan 16 02:13:51 2009
@@ -1,11 +1,27 @@
+/**
+ * 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.tracer;
 
-import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 
 /**
- *
+ * Our quote server that can split words and lookup a quote based on a word
  */
 public class QuoteService {
 
@@ -28,5 +44,4 @@
         return Arrays.asList(payload.split(" "));
     }
 
-
 }


Reply via email to