Notification of state changes for GRAM jobs is supported by the user's class adding itself as a listener to a GramJob. See the example below for more details.
public class GramExample implements GramJobListener {
private someMethod() {
...
String gramContact = "pitcairn.mcs.anl.gov:6722:...";
String rsl = "&(executable=...)(...)(...)";
try {
Gram.ping(gramContact);
} catch (GramException e) {
// can't submit
return;
}
job.addListener(this);
// add this class as a listener for state changes
GramJob job = null;
try {
job = new GramJob(rsl);
Gram.request(gramContact,job);
} catch (GramException e) {
// request failed
...
}
...
try {
job.cancel();
} catch (GramException e) {
// cancel failed
...
}
}
// this method must be implemented in order for the class to
// implement the GramJobListener class
public stateChanged(GramJob job) {
System.out.println("Job state change \n" +
" ID : " + job.getID() + "\n" +
" State: " + job.getStateAsString());
}
}