1414* limitations under the License.
1515*/
1616
17- package org .metafacture .strings ;
17+ package org .metafacture .flowcontrol ;
1818
1919import org .metafacture .framework .FluxCommand ;
20+ import org .metafacture .framework .MetafactureException ;
2021import org .metafacture .framework .ObjectReceiver ;
2122import org .metafacture .framework .annotations .Description ;
2223import org .metafacture .framework .annotations .In ;
2324import org .metafacture .framework .annotations .Out ;
2425import org .metafacture .framework .helpers .DefaultObjectPipe ;
2526
27+
2628/**
2729 * Lets the process between objects sleep for a specific ms.
28- *
29- * @author Tobias Bülte
30- */
30+ *
31+ * @param <T> object type
32+ * @author Tobias Bülte
33+ */
3134@ Description ("Lets the process between objects sleep for a specific ms." )
3235@ In (Object .class )
3336@ Out (Object .class )
34- @ FluxCommand ("object- sleep" )
35- public final class ObjectSleeper extends DefaultObjectPipe <T , ObjectReceiver <T >> {
37+ @ FluxCommand ("sleep" )
38+ public final class ObjectSleeper < T > extends DefaultObjectPipe <T , ObjectReceiver <T >> {
3639
3740 public static final long DEFAULT_SLEEP_TIME = 1000 ;
3841
@@ -44,8 +47,7 @@ public final class ObjectSleeper extends DefaultObjectPipe<T, ObjectReceiver<T>>
4447 public ObjectSleeper () {
4548 }
4649
47-
48- /**
50+ /**
4951 * Sets the time in ms for the sleep phase.
5052 *
5153 * @param sleepTime the time to sleep
@@ -54,7 +56,7 @@ public void setSleepTime(final int sleepTime) {
5456 this .sleepTime = sleepTime ;
5557 }
5658
57- /**
59+ /**
5860 * Gets the time in ms for the sleep phase.
5961 *
6062 * @return the time to sleep
@@ -65,7 +67,13 @@ public long getSleepTime() {
6567
6668 @ Override
6769 public void process (final T obj ) {
68- Thread .sleep (sleepTime );
70+ try {
71+ Thread .sleep (sleepTime );
72+ }
73+ catch (final InterruptedException e ) {
74+ Thread .currentThread ().interrupt ();
75+ throw new MetafactureException (e .getMessage (), e );
76+ }
6977 getReceiver ().process (obj );
7078 }
7179
0 commit comments