// if ip:port forwarding needs to be done to work around firewall problems
// on the GATEWAY use the following method
// mGateway.setForwardAddress(new InetSocketAddress("193.122.18.162", 8310));
GatewayProcess mGatewayProcess = mGateway.submit(dispelFile);
// if ip:port forwarding needs to be done to work around firewall problems
// on the OGSADAI-USMT use the following method
// mGatewayProcess.setForwardAddress(new InetSocketAddress("193.122.18.162", 8300));
// now can either wait for results (blocking) or sign up for
// notifications (non-blocking)
// 0 - blocking wait; 1 - wait with timeout; 2 - non-blocking
int example = 0;
try
{
switch (example) {
// *****************************************************
// waiting for results
// *****************************************************
case 0:
mGatewayProcess.waitForResults();
Errors errors = mGatewayProcess.getErrors();
if (hasErrors(errors))
{
return;
}
for (Result r : mGatewayProcess.getResults().values())
{
System.out.println("Result name = " + r.getName());
System.out.println("Value = " + Util.getAsString(r));
r.close();
}
break;
// *****************************************************
// waiting for results with timeout
// *****************************************************
case 1:
long timeout = 100 * 1000;
mGatewayProcess.waitForResults(timeout);
if (hasErrors(mGatewayProcess.getErrors()))
{
return;
}
for (Result r : mGatewayProcess.getResults().values())
{
System.out.println("Result name = " + r.getName());
System.out.println("Value = " + Util.getAsString(r));
r.close();
}
break;
// *****************************************************
// subscribing for results
// *****************************************************
// when subscribing also need to implement ResultObserver interface
// resultsReady method, example below
case 2:
mGatewayProcess.subscribeForResults(this);
break;
}
}
finally
{
// then destroy the process itself
mGatewayProcess.destroyProcess();
}
}