camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r674416 - in /activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version: Bank.java Translator.java
Date Mon, 07 Jul 2008 08:11:20 GMT
Author: ningjiang
Date: Mon Jul  7 01:11:20 2008
New Revision: 674416

URL: http://svn.apache.org/viewvc?rev=674416&view=rev
Log:
Polished the loan-broker example

Modified:
    activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Bank.java
    activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Translator.java

Modified: activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Bank.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Bank.java?rev=674416&r1=674415&r2=674416&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Bank.java
(original)
+++ activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Bank.java
Mon Jul  7 01:11:20 2008
@@ -26,15 +26,17 @@
 public class Bank implements Processor {
     private static final transient Log LOG = LogFactory.getLog(Bank.class);
     private String bankName;
+    private double primeRate;
 
     public Bank(String name) {
         bankName = name;
+        primeRate = 3.5;
     }
 
     public void process(Exchange exchange) throws Exception {
-        LOG.debug("Receiving bank request");
         String ssn = (String)exchange.getIn().getHeader(Constants.PROPERTY_SSN);
-        double rate = Math.random() * 10;
+        Integer historyLength = (Integer) exchange.getIn().getHeader(Constants.PROPERTY_HISTORYLENGTH);
+        double rate = primeRate + (double)(historyLength / 12) / 10 + (double)(Math.random()
* 10) / 10;
         LOG.info("The bank: " + bankName + " for client: " + ssn + " 's rate " + rate);
         exchange.getOut().setHeader(Constants.PROPERTY_RATE, new Double(rate));
         exchange.getOut().setHeader(Constants.PROPERTY_BANK, bankName);

Modified: activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Translator.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Translator.java?rev=674416&r1=674415&r2=674416&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Translator.java
(original)
+++ activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/Translator.java
Mon Jul  7 01:11:20 2008
@@ -27,7 +27,7 @@
         Double rate = (Double)exchange.getIn().getHeader(Constants.PROPERTY_RATE);
         String ssn = (String)exchange.getIn().getHeader(Constants.PROPERTY_SSN);
         exchange.getOut().setBody("Loan quotion for Client " + ssn + "."
-                                  + " The lowest rate of bank is " + bank + ", the rate is
" + rate);
+                                  + " The lowest rate bank is " + bank + ", the rate is "
+ rate);
     }
 
 }



Mime
View raw message