summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/taskmanager/tasks/SleepTask.java
blob: 3556abc7cfa18126c563cbcd640127a5b1a5002c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.openslx.taskmanager.tasks;

import org.apache.log4j.Logger;
import org.openslx.taskmanager.api.AbstractTask;

import com.google.gson.annotations.Expose;

/**
 * Sleep Task that will just do what the name says.
 * Useful only when chaining tasks and you want a pause in between.
 */
public class SleepTask extends AbstractTask
{

	private static final Logger LOG = Logger.getLogger( SleepTask.class );

	@Expose
	private int seconds = 0;

	@Override
	protected boolean initTask()
	{
		return true;
	}

	@Override
	protected boolean execute()
	{
		try {
			Thread.sleep( this.seconds * 1000 );
		} catch ( InterruptedException e ) {
			LOG.error( "Interrupted while sleeping for " + this.seconds + " seconds.", e );
		}
		return true;
	}

}