Skip to content

Commit 489a74d

Browse files
committed
Adjust ObjectSleeper.java #495
1 parent a9b3982 commit 489a74d

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectSleeper.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,28 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.metafacture.strings;
17+
package org.metafacture.flowcontrol;
1818

1919
import org.metafacture.framework.FluxCommand;
20+
import org.metafacture.framework.MetafactureException;
2021
import org.metafacture.framework.ObjectReceiver;
2122
import org.metafacture.framework.annotations.Description;
2223
import org.metafacture.framework.annotations.In;
2324
import org.metafacture.framework.annotations.Out;
2425
import 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

metafacture-flowcontrol/src/main/resources/flux-commands.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ reset-object-batch org.metafacture.flowcontrol.ObjectBatchResetter
2121
defer-stream org.metafacture.flowcontrol.StreamDeferrer
2222
catch-stream-exception org.metafacture.flowcontrol.StreamExceptionCatcher
2323
thread-object-tee org.metafacture.flowcontrol.ObjectThreader
24+
sleep org.metafacture.flowcontrol.ObjectSleeper

0 commit comments

Comments
 (0)