in taverna-server-webapp/src/main/java/org/apache/taverna/server/master/localworker/IdAwareForkRunFactory.java [465:518]
public RemoteRunFactory make(String username) throws Exception {
try {
main.getTheRegistry().list(); // Validate registry connection first
} catch (ConnectException | ConnectIOException e) {
log.warn("connection problems with registry", e);
} catch (RemoteException e) {
if (e.getCause() != null && e.getCause() instanceof Exception) {
throw (Exception) e.getCause();
}
log.warn("connection problems with registry", e);
}
String fpn = state.getFactoryProcessNamePrefix() + randomUUID();
make(username, fpn);
// Wait for the subprocess to register itself in the RMI registry
Calendar deadline = Calendar.getInstance();
deadline.add(SECOND, state.getWaitSeconds());
Exception lastException = null;
lastStartupCheckCount = 0;
while (deadline.after(Calendar.getInstance())) {
try {
sleep(state.getSleepMS());
lastStartupCheckCount++;
log.info("about to look up resource called " + fpn);
RemoteRunFactory f = (RemoteRunFactory) main.getTheRegistry()
.lookup(fpn);
log.info("successfully connected to factory subprocess " + fpn);
main.initInteractionDetails(f);
main.registerFactory(username, fpn, f);
return f;
} catch (InterruptedException ie) {
continue;
} catch (NotBoundException nbe) {
lastException = nbe;
log.info("resource \"" + fpn + "\" not yet registered...");
continue;
} catch (RemoteException re) {
// Unpack a remote exception if we can
lastException = re;
try {
if (re.getCause() != null)
lastException = (Exception) re.getCause();
} catch (Throwable t) {
// Ignore!
}
} catch (Exception e) {
lastException = e;
}
}
if (lastException == null)
lastException = new InterruptedException();
throw lastException;
}