svn commit: r734742 - in /activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream: StreamConsumer.java StreamEndpoint.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r734742 - in /activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream: StreamConsumer.java StreamEndpoint.java

davsclaus-2
Author: davsclaus
Date: Thu Jan 15 08:22:47 2009
New Revision: 734742

URL: http://svn.apache.org/viewvc?rev=734742&view=rev
Log:
CAMEL-1258: Added delay option for prompt message

Modified:
    activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
    activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamEndpoint.java

Modified: activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java?rev=734742&r1=734741&r2=734742&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java (original)
+++ activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java Thu Jan 15 08:22:47 2009
@@ -48,6 +48,7 @@
     private InputStream inputStream = System.in;
     private StreamEndpoint endpoint;
     private String uri;
+    private boolean initialPromptDone;
 
     public StreamConsumer(StreamEndpoint endpoint, Processor processor, String uri) throws Exception {
         super(endpoint, processor);
@@ -101,9 +102,18 @@
      * Strategy method for prompting the prompt message
      */
     protected void doPromptMessage() {
-        if (endpoint.getPromptDelay() > 0) {
+        long delay = 0;
+
+        if (!initialPromptDone && endpoint.getInitialPromptDelay() > 0) {
+            initialPromptDone = true;
+            delay = endpoint.getInitialPromptDelay();
+        } else if (endpoint.getPromptDelay() > 0) {
+            delay = endpoint.getPromptDelay();
+        }
+
+        if (delay > 0) {
             try {
-                Thread.sleep(endpoint.getPromptDelay());
+                Thread.sleep(delay);
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();
             }

Modified: activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamEndpoint.java?rev=734742&r1=734741&r2=734742&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamEndpoint.java Thu Jan 15 08:22:47 2009
@@ -36,6 +36,7 @@
     private String encoding;
     private String promptMessage;
     private long promptDelay;
+    private long initialPromptDelay = 2000;
 
     public StreamEndpoint(String endpointUri, Component component) throws Exception {
         super(endpointUri, component);
@@ -102,6 +103,14 @@
         this.promptDelay = promptDelay;
     }
 
+    public long getInitialPromptDelay() {
+        return initialPromptDelay;
+    }
+
+    public void setInitialPromptDelay(long initialPromptDelay) {
+        this.initialPromptDelay = initialPromptDelay;
+    }
+
     // Implementations
     //-------------------------------------------------------------------------