public synchronized void error () throws SystemException { participant.cancel() ; }
if (current == State.STATE_ACTIVE || current == State.STATE_CANCELING) changeState(State.STATE_COMPLETED) ; executeCompleted() ; sendClose() ; sendCompensate() ;
if (current == State.STATE_ACTIVE) changeState(State.STATE_FAILING_ACTIVE) ; ended(); ended(); executeFail(fail.getExceptionIdentifier()) ; sendFailed() ;
if ((current == State.STATE_ACTIVE) || (current == State.STATE_CANCELING)) changeState(State.STATE_EXITING) ; executeExit() ; sendExited() ;
if ((current == State.STATE_ACTIVE) || (state == State.STATE_CANCELING)) changeState(State.STATE_NOT_COMPLETING) ; executeCannotComplete() ; sendNotCompleted() ;
final ParticipantCompletionCoordinatorEngine engine = new ParticipantCompletionCoordinatorEngine(id, participantProtocolService) ; BusinessAgreementWithParticipantCompletionImple participant = new BusinessAgreementWithParticipantCompletionImple( new BusinessAgreementWithParticipantCompletionStub(engine), id); engine.setCoordinator(participant.participantManager()) ;
if (current == State.STATE_ACTIVE) changeState(State.STATE_CANCELING) ; sendCancel() ; current = waitForState(State.STATE_CANCELING, TransportTimer.getTransportTimeout()) ;
if (current == State.STATE_COMPLETED) changeState(State.STATE_CLOSING) ; sendClose() ; waitForState(State.STATE_CLOSING, TransportTimer.getTransportTimeout()) ;
if (current == State.STATE_COMPLETED) changeState(State.STATE_COMPENSATING) ; sendCompensate() ; waitForState(State.STATE_COMPENSATING, TransportTimer.getTransportTimeout()) ;
/** * Send the cancel message. * */ private void sendCancel() { final MAP map = createContext() ; try { ParticipantCompletionParticipantClient.getClient().sendCancel(participant, map, instanceIdentifier) ; } catch (final Throwable th) { if (WSTLogger.logger.isTraceEnabled()) { WSTLogger.logger.tracev("Unexpected exception while sending Cancel", th) ; } } }
/** * Handle the soap fault event. * @param soapFault The soap fault. * @param map The addressing context. * @param arjunaContext The arjuna context. */ public void soapFault(final SoapFault soapFault, final MAP map, final ArjunaContext arjunaContext) { ended() ; try { // TODO - we cannot do this with JaxWS. need to log something } catch (final Throwable th) {} // ignore }
/** * Execute the exit transition. * */ private void executeExit() { try { coordinator.exit() ; } catch (final Throwable th) { if (WSTLogger.logger.isTraceEnabled()) { WSTLogger.logger.tracev("Unexpected exception from coordinator exit", th) ; } return ; } sendExited() ; ended() ; }
/** * Executing the fail transition. * * @throws com.arjuna.webservices.SoapFault for SOAP errors. * @throws java.io.IOException for transport errors. * */ private void executeFail(QName fail) { try { coordinator.fail(fail) ; } catch (final Throwable th) { if (WSTLogger.logger.isTraceEnabled()) { WSTLogger.logger.tracev("Unexpected exception from coordinator fault", th) ; } return ; } sendFailed() ; ended() ; }
/** * Executing the cannot complete transition. * * @throws SoapFault for SOAP errors. * */ private void executeCannotComplete() { try { coordinator.cannotComplete() ; } catch (final Throwable th) { if (WSTLogger.logger.isTraceEnabled()) { WSTLogger.logger.tracev("Unexpected exception from coordinator error", th) ; } return ; } sendNotCompleted() ; ended() ; } /**
participant = new ParticipantCompletionCoordinatorEngine(id, endpointReference, state, true);
/** * End the current coordinator. */ private void ended() { changeState(State.STATE_ENDED) ; // participants which have not been recovered from the log can be deactivated now. // participants which have been recovered are left for the recovery thread to deactivate. // this is because the recovery thread may have timed out waiting for a response to // a close/cancel message and gone on to complete its scan and suspend. the next scan // will detect this activated participant and note that it has completed. if a crash // happens in between the recovery thread can safely recreate and reactivate the // participant and resend the commit since the commit/committed exchange is idempotent. if (!recovered) { ParticipantCompletionCoordinatorProcessor.getProcessor().deactivateCoordinator(this) ; } }
public synchronized void close () throws WrongStateException, SystemException { /* * Active -> illegal state * Canceling -> illegal state * Completed -> illegal state * Closing -> no response * Compensating -> illegal state * Faulting -> illegal state * Faulting-Active -> illegal state * Faulting-Compensating -> illegal state * Exiting -> illegal state * Ended -> ended */ final State state = participant.close() ; if (state == State.STATE_CLOSING) { throw new SystemException() ; } else if (state != State.STATE_ENDED) { throw new WrongStateException() ; } }
public synchronized void compensate () throws FaultedException, WrongStateException, SystemException { /* * Active -> illegal state * Canceling -> illegal state * Completed -> illegal state * Closing -> illegal state * Compensating -> no answer * Faulting -> illegal state * Faulting-Active -> illegal state * Faulting-Compensating -> fault * Exiting -> illegal state * Ended -> ended */ final State state = participant.compensate() ; if (state == State.STATE_COMPENSATING) { throw new SystemException() ; } else if (state == State.STATE_FAILING_COMPENSATING) { throw new FaultedException() ; } else if (state != State.STATE_ENDED) { throw new WrongStateException() ; } }
final ParticipantCompletionCoordinatorEngine engine = new ParticipantCompletionCoordinatorEngine(id, participantProtocolService) ; BusinessAgreementWithParticipantCompletionImple participant = new BusinessAgreementWithParticipantCompletionImple( new BusinessAgreementWithParticipantCompletionStub(engine), id); engine.setCoordinator(participant.participantManager()) ;
if ((current == State.STATE_ACTIVE) || (current == State.STATE_CANCELING)) changeState(State.STATE_EXITING) ; executeExit() ; sendExited() ;