Cancel Method
If a Service is canceled by the user or a Service request (task) is canceled, the managing container receives a message and calls a specified operation on the Service automatically. For a given Service, a method can be assigned to be called by the container under this cancellation event. Here’s a simple example:
public class DBCalculator {
…
public void stop() {
_isStopped = true;
}
public Bar calculate(String arg1, …) {
while (_isStopped != null) {
// iterate over looping variable
}
}
private volatile boolean _isStopped = false;
}
In this example, the stop method must be registered as the “cancelMethod”. If it is not possible to stop the operation in this way, GridServer allows canceled Service operations to cause the entire Engine process to be killed and restarted automatically. The Service option is called KILL_ENGINE_ON_CANCEL and takes the value true or false.