jadex.bpmn.testcases.CreatePlatformTask 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.testcases;
import jadex.base.Starter;
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.IComponentIdentifier;
import jadex.bridge.IExternalAccess;
import jadex.bridge.IInternalAccess;
import jadex.bridge.component.IExecutionFeature;
import jadex.commons.future.ExceptionDelegationResultListener;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
/**
* Create a second platform for testing.
*/
@Task(description="Create a second platform for testing", parameters={
@TaskParameter(name="cid", clazz=IComponentIdentifier.class, direction=TaskParameter.DIRECTION_OUT)
})
public class CreatePlatformTask implements ITask
{
/**
* Execute the task.
* @param context The accessible values.
* @param process The process instance executing the task.
* @return To be notified, when the task has completed.
*/
public IFuture execute(final ITaskContext context, IInternalAccess process)
{
final Future ret = new Future();
String url = process.getModel().getResourceIdentifier().getLocalIdentifier().getUri().toString();
Starter.createPlatform(new String[]{"-platformname", process.getComponentIdentifier().getPlatformPrefix()+"_*",
// "-logging", "true",
"-libpath", "new String[]{\""+url+"\"}",
"-saveonexit", "false", "-welcome", "false", "-autoshutdown", "false", "-awareness", "false",
"-gui", "false"
// "-usepass", "false"//, "-simulation", "false"
})
.addResultListener(process.getComponentFeature(IExecutionFeature.class).createResultListener(new ExceptionDelegationResultListener(ret)
{
public void customResultAvailable(IExternalAccess exta)
{
context.setParameterValue("cid", exta.getComponentIdentifier());
// System.out.println("cid: "+exta.getComponentIdentifier().getAddresses());
ret.setResult(null);
}
}));
return ret;
}
/**
* Compensate in case the task is canceled.
* @return To be notified, when the compensation has completed.
*/
public IFuture cancel(IInternalAccess instance)
{
return IFuture.DONE;
}
}