camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r791478 - in /camel/branches/camel-1.x: ./ camel-core/src/main/java/org/apache/camel/component/timer/ camel-core/src/test/java/org/apache/camel/component/timer/ etc/eclipse/
Date Mon, 06 Jul 2009 13:24:13 GMT
Author: davsclaus
Date: Mon Jul  6 13:24:13 2009
New Revision: 791478

URL: http://svn.apache.org/viewvc?rev=791478&view=rev
Log:
Merged revisions 791476 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r791476 | davsclaus | 2009-07-06 15:18:45 +0200 (Mon, 06 Jul 2009) | 1 line
  
  CAMEL-1805: Timer component, setting time option from uri is now possible.
........

Added:
    camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
      - copied, changed from r791476, camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
Modified:
    camel/branches/camel-1.x/   (props changed)
    camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
    camel/branches/camel-1.x/etc/eclipse/Camel.importorder   (props changed)
    camel/branches/camel-1.x/etc/eclipse/CamelCodeFormatter.xml   (props changed)

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul  6 13:24:13 2009
@@ -1 +1 @@
-/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
 923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379
+/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
 923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379,791476

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java?rev=791478&r1=791477&r2=791478&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/component/timer/TimerComponent.java
Mon Jul  6 13:24:13 2009
@@ -20,6 +20,8 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Timer;
+import java.util.Date;
+import java.text.SimpleDateFormat;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
@@ -51,6 +53,23 @@
     @Override
     protected Endpoint<Exchange> createEndpoint(String uri, String remaining, Map parameters)
throws Exception {
         TimerEndpoint answer = new TimerEndpoint(uri, this, remaining);
+
+        // convert time from String to a java.util.Date using the supported patterns
+        String time = getAndRemoveParameter(parameters, "time", String.class);
+        String pattern = getAndRemoveParameter(parameters, "pattern", String.class);
+        if (time != null) {
+            SimpleDateFormat sdf;
+            if (pattern != null) {
+                sdf = new SimpleDateFormat(pattern);
+            } else if (time.contains("T")) {
+                sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+            } else {
+                sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            }
+            Date date = sdf.parse(time);
+            answer.setTime(date);
+        }
+
         setProperties(answer, parameters);
         return answer;
     }

Copied: camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
(from r791476, camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java)
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java?p2=camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java&r1=791476&r2=791478&rev=791478&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/component/timer/TimerWithTimeOptionTest.java
Mon Jul  6 13:24:13 2009
@@ -44,7 +44,7 @@
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
                 String time = sdf.format(future);
 
-                fromF("timer://foo?time=%s", time).to("mock:result");
+                from(String.format("timer://foo?time=%s", time)).to("mock:result");
             }
         });
         context.start();
@@ -64,7 +64,7 @@
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                 String time = sdf.format(future);
 
-                fromF("timer://foo?time=%s", time).to("mock:result");
+                from(String.format("timer://foo?time=%s", time)).to("mock:result");
             }
         });
         context.start();
@@ -84,7 +84,7 @@
                 SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
                 String time = sdf.format(future);
 
-                fromF("timer://foo?time=%s&pattern=dd-MM-yyyy HH:mm:ss", time).to("mock:result");
+                from(String.format("timer://foo?time=%s&pattern=dd-MM-yyyy HH:mm:ss",
time)).to("mock:result");
             }
         });
         context.start();
@@ -99,7 +99,7 @@
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                fromF("timer://foo?time=%s", "20090101").to("mock:result");
+                from(String.format("timer://foo?time=%s", "20090101")).to("mock:result");
             }
         });
         try {

Propchange: camel/branches/camel-1.x/etc/eclipse/Camel.importorder
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul  6 13:24:13 2009
@@ -1 +1 @@
-/camel/trunk/etc/eclipse/Camel.importorder:790560,790936,791379
+/camel/trunk/etc/eclipse/Camel.importorder:790560,790936,791379,791476

Propchange: camel/branches/camel-1.x/etc/eclipse/CamelCodeFormatter.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul  6 13:24:13 2009
@@ -1 +1 @@
-/camel/trunk/etc/eclipse/CamelCodeFormatter.xml:790560,790936,791379
+/camel/trunk/etc/eclipse/CamelCodeFormatter.xml:790560,790936,791379,791476



Mime
View raw message