jadex.bpmn.tutorial.GetTimeTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bpmn Show documentation
Show all versions of jadex-applications-bpmn Show documentation
The Jadex bpmn applications package contains several example applications, benchmarks and testcases using bpmn workflows.
package jadex.bpmn.tutorial;
import jadex.bpmn.model.task.ITask;
import jadex.bpmn.model.task.ITaskContext;
import jadex.bpmn.model.task.annotation.Task;
import jadex.bpmn.model.task.annotation.TaskParameter;
import jadex.bridge.IInternalAccess;
import jadex.bridge.service.RequiredServiceInfo;
import jadex.bridge.service.search.SServiceProvider;
import jadex.bridge.service.types.clock.IClockService;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
/**
* A task that provides the current platform time in the 'time' parameter.
*/
@Task(description="Task that delivers the current time in parameter 'time'.",
parameters=@TaskParameter(name="time", clazz=Long.class, direction=TaskParameter.DIRECTION_OUT))
public class GetTimeTask implements ITask
{
/**
* Execute the task.
*/
public IFuture execute(final ITaskContext context, final IInternalAccess process)
{
final Future ret = new Future();
IClockService clock = SServiceProvider.getLocalService(process, IClockService.class, RequiredServiceInfo.SCOPE_PLATFORM);
context.setParameterValue("time", Long.valueOf(clock.getTime()));
return ret;
}
/**
* Compensate in case the task is canceled.
* @return To be notified, when the compensation has completed.
*/
public IFuture cancel(final IInternalAccess instance)
{
return IFuture.DONE;
}
}