public boolean cancel(final boolean mayInterruptIfRunning) { final Object lock = EJBClientInvocationContext.this.lock; assert !holdsLock(lock); synchronized (lock) { if (state == State.DONE) { // cannot cancel now; also resultProducer is gone return pendingFailure == CANCELLED_PRODUCER; } else if (! state.isWaiting()) { // cannot cancel now return resultProducer == CANCELLED; } else { if (resultProducer == CANCELLED) { return true; } // at this point the task is running and we are allowed to interrupt it. So set // the cancel request flag and a fall out to send the request cancelRequested = true; } } final EJBReceiver receiver = getReceiver(); final boolean result = receiver != null && receiver.cancelInvocation(receiverInvocationContext, mayInterruptIfRunning); if (! result) { synchronized (lock) { if (resultProducer == CANCELLED || state == State.DONE && pendingFailure == CANCELLED_PRODUCER) { return true; } } } return result; }
public boolean cancel(final boolean mayInterruptIfRunning) { final Object lock = EJBClientInvocationContext.this.lock; assert !holdsLock(lock); synchronized (lock) { if (state == State.DONE) { // cannot cancel now; also resultProducer is gone return pendingFailure == CANCELLED_PRODUCER; } else if (! state.isWaiting()) { // cannot cancel now return resultProducer == CANCELLED; } else { if (resultProducer == CANCELLED) { return true; } // at this point the task is running and we are allowed to interrupt it. So set // the cancel request flag and a fall out to send the request cancelRequested = true; } } final EJBReceiver receiver = getReceiver(); final boolean result = receiver != null && receiver.cancelInvocation(receiverInvocationContext, mayInterruptIfRunning); if (! result) { synchronized (lock) { if (resultProducer == CANCELLED || state == State.DONE && pendingFailure == CANCELLED_PRODUCER) { return true; } } } return result; }
public boolean cancel(final boolean mayInterruptIfRunning) { final Object lock = EJBClientInvocationContext.this.lock; assert !holdsLock(lock); synchronized (lock) { if (state == State.DONE) { // cannot cancel now; also resultProducer is gone return pendingFailure == CANCELLED_PRODUCER; } else if (! state.isWaiting()) { // cannot cancel now return resultProducer == CANCELLED; } else { if (resultProducer == CANCELLED) { return true; } // at this point the task is running and we are allowed to interrupt it. So set // the cancel request flag and a fall out to send the request cancelRequested = true; } } final EJBReceiver receiver = getReceiver(); final boolean result = receiver != null && receiver.cancelInvocation(receiverInvocationContext, mayInterruptIfRunning); if (! result) { synchronized (lock) { if (resultProducer == CANCELLED || state == State.DONE && pendingFailure == CANCELLED_PRODUCER) { return true; } } } return result; }