14
14
* limitations under the License.
15
15
*/
16
16
17
- package org .metafacture .strings ;
17
+ package org .metafacture .flowcontrol ;
18
18
19
19
import org .metafacture .framework .FluxCommand ;
20
+ import org .metafacture .framework .MetafactureException ;
20
21
import org .metafacture .framework .ObjectReceiver ;
21
22
import org .metafacture .framework .annotations .Description ;
22
23
import org .metafacture .framework .annotations .In ;
23
24
import org .metafacture .framework .annotations .Out ;
24
25
import org .metafacture .framework .helpers .DefaultObjectPipe ;
25
26
27
+
26
28
/**
27
29
* 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
+ */
31
34
@ Description ("Lets the process between objects sleep for a specific ms." )
32
35
@ In (Object .class )
33
36
@ 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 >> {
36
39
37
40
public static final long DEFAULT_SLEEP_TIME = 1000 ;
38
41
@@ -44,8 +47,7 @@ public final class ObjectSleeper extends DefaultObjectPipe<T, ObjectReceiver<T>>
44
47
public ObjectSleeper () {
45
48
}
46
49
47
-
48
- /**
50
+ /**
49
51
* Sets the time in ms for the sleep phase.
50
52
*
51
53
* @param sleepTime the time to sleep
@@ -54,7 +56,7 @@ public void setSleepTime(final int sleepTime) {
54
56
this .sleepTime = sleepTime ;
55
57
}
56
58
57
- /**
59
+ /**
58
60
* Gets the time in ms for the sleep phase.
59
61
*
60
62
* @return the time to sleep
@@ -65,7 +67,13 @@ public long getSleepTime() {
65
67
66
68
@ Override
67
69
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
+ }
69
77
getReceiver ().process (obj );
70
78
}
71
79
0 commit comments