Skip to content

Commit

Permalink
Adjust ObjectSleeper.java #495
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Oct 17, 2024
1 parent a9b3982 commit 489a74d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,28 @@
* limitations under the License.
*/

package org.metafacture.strings;
package org.metafacture.flowcontrol;

import org.metafacture.framework.FluxCommand;
import org.metafacture.framework.MetafactureException;
import org.metafacture.framework.ObjectReceiver;
import org.metafacture.framework.annotations.Description;
import org.metafacture.framework.annotations.In;
import org.metafacture.framework.annotations.Out;
import org.metafacture.framework.helpers.DefaultObjectPipe;


/**
* Lets the process between objects sleep for a specific ms.
*
* @author Tobias Bülte
*/
*
* @param <T> object type
* @author Tobias Bülte
*/
@Description("Lets the process between objects sleep for a specific ms.")
@In(Object.class)
@Out(Object.class)
@FluxCommand("object-sleep")
public final class ObjectSleeper extends DefaultObjectPipe<T, ObjectReceiver<T>> {
@FluxCommand("sleep")
public final class ObjectSleeper<T> extends DefaultObjectPipe<T, ObjectReceiver<T>> {

public static final long DEFAULT_SLEEP_TIME = 1000;

Expand All @@ -44,8 +47,7 @@ public final class ObjectSleeper extends DefaultObjectPipe<T, ObjectReceiver<T>>
public ObjectSleeper() {
}


/**
/**
* Sets the time in ms for the sleep phase.
*
* @param sleepTime the time to sleep
Expand All @@ -54,7 +56,7 @@ public void setSleepTime(final int sleepTime) {
this.sleepTime = sleepTime;
}

/**
/**
* Gets the time in ms for the sleep phase.
*
* @return the time to sleep
Expand All @@ -65,7 +67,13 @@ public long getSleepTime() {

@Override
public void process(final T obj) {
Thread.sleep(sleepTime);
try {
Thread.sleep(sleepTime);
}
catch (final InterruptedException e) {
Thread.currentThread().interrupt();
throw new MetafactureException(e.getMessage(), e);
}
getReceiver().process(obj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ reset-object-batch org.metafacture.flowcontrol.ObjectBatchResetter
defer-stream org.metafacture.flowcontrol.StreamDeferrer
catch-stream-exception org.metafacture.flowcontrol.StreamExceptionCatcher
thread-object-tee org.metafacture.flowcontrol.ObjectThreader
sleep org.metafacture.flowcontrol.ObjectSleeper

0 comments on commit 489a74d

Please sign in to comment.