in taverna-server-worker/src/main/java/org/apache/taverna/server/localworker/impl/LocalWorker.java [212:268]
protected LocalWorker(String executeWorkflowCommand, byte[] workflow,
UsageRecordReceiver urReceiver, UUID id,
Map<String, String> seedEnvironment, List<String> javaParams,
WorkerFactory workerFactory) throws RemoteException,
ImplementationException {
super();
if (id == null)
id = randomUUID();
masterToken = id.toString();
this.workflow = workflow;
this.executeWorkflowCommand = executeWorkflowCommand;
String sharedDir = getProperty(SHARED_DIR_PROP, SLASHTEMP);
base = new File(sharedDir, masterToken);
out.println("about to create " + base);
try {
forceMkdir(base);
for (String subdir : SUBDIR_LIST) {
new File(base, subdir).mkdir();
}
} catch (IOException e) {
throw new ImplementationException(
"problem creating run working directory", e);
}
baseDir = new DirectoryDelegate(base, null);
inputFiles = new HashMap<>();
inputRealFiles = new HashMap<>();
inputValues = new HashMap<>();
inputDelimiters = new HashMap<>();
environment.putAll(seedEnvironment);
runtimeSettings.addAll(javaParams);
try {
core = workerFactory.makeInstance();
} catch (Exception e) {
out.println("problem when creating core worker implementation");
e.printStackTrace(out);
throw new ImplementationException(
"problem when creating core worker implementation", e);
}
core.setURReceiver(urReceiver);
Thread t = new Thread(new Runnable() {
/**
* Kill off the worker launched by the core.
*/
@Override
public void run() {
try {
shutdownHook = null;
destroy();
} catch (ImplementationException e) {
// Absolutely nothing we can do here
}
}
});
getRuntime().addShutdownHook(t);
shutdownHook = t;
status = Initialized;
}