use of com.arjuna.wst11.stub.Volatile2PCStub in project narayana by jbosstm.
the class RegistrarImple method register.
/**
* Registers the interest of participant in a particular protocol.
*
* @param participantProtocolService
* the address of the participant protocol service
* @param protocolIdentifier
* the protocol identifier
*
* @return the PortReference of the coordinator protocol service
*
* @throws com.arjuna.wsc.AlreadyRegisteredException
* if the participant is already registered for this
* coordination protocol under this activity identifier
* @throws com.arjuna.wsc.InvalidProtocolException
* if the coordination protocol is not supported
* @throws com.arjuna.wsc.InvalidStateException
* if the state of the coordinator no longer allows registration
* for this coordination protocol
* @throws com.arjuna.wsc.NoActivityException
* if the activity does not exist.
*/
/*
* TODO
*
* See comment at head of class definition. We shouldn't have to rely on
* thread-to-activity association to register a participant. We currently do
* because the code is based on old WS-CAF models that are no longer
* applicable. This needs updating!
*/
public W3CEndpointReference register(final W3CEndpointReference participantProtocolService, final String protocolIdentifier, final InstanceIdentifier instanceIdentifier, final boolean isSecure) throws AlreadyRegisteredException, InvalidProtocolException, InvalidStateException, NoActivityException {
Object tx = _hierarchies.get(instanceIdentifier.getInstanceIdentifier());
if (tx instanceof SubordinateATCoordinator)
return registerWithSubordinate((SubordinateATCoordinator) tx, participantProtocolService, protocolIdentifier, isSecure);
ActivityHierarchy hier = (ActivityHierarchy) tx;
if (hier == null)
throw new NoActivityException();
try {
_coordManager.resume(hier);
} catch (com.arjuna.mw.wsas.exceptions.InvalidActivityException ex) {
throw new NoActivityException();
} catch (SystemException ex) {
throw new InvalidProtocolException();
}
if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_DURABLE_2PC.equals(protocolIdentifier)) {
// enlist participant that wraps the requester URI.
final String participantId = "D" + new Uid().stringForm();
try {
final Durable2PCStub participantStub = new Durable2PCStub(participantId, participantProtocolService);
_coordManager.enlistParticipant(new DurableTwoPhaseCommitParticipant(participantStub, participantId));
_coordManager.suspend();
return getCoordinator(participantId, isSecure);
} catch (Exception ex) {
throw new InvalidStateException();
}
} else if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_VOLATILE_2PC.equals(protocolIdentifier)) {
// enlist participant that wraps the requester URI.
final String participantId = "V" + new Uid().stringForm();
try {
final Volatile2PCStub participantStub = new Volatile2PCStub(participantId, participantProtocolService);
_coordManager.enlistSynchronization(new VolatileTwoPhaseCommitParticipant(participantStub));
_coordManager.suspend();
return getCoordinator(participantId, isSecure);
} catch (Exception ex) {
throw new InvalidStateException();
}
} else if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_COMPLETION.equals(protocolIdentifier)) {
try {
final CompletionCoordinatorParticipant participant = new CompletionCoordinatorImple(_coordManager, hier, true, participantProtocolService);
CompletionCoordinatorProcessor.getProcessor().activateParticipant(participant, instanceIdentifier.getInstanceIdentifier());
_coordManager.suspend();
return getCompletionCoordinator(instanceIdentifier, isSecure);
} catch (Exception ex) {
ex.printStackTrace();
throw new InvalidStateException(ex.toString());
}
} else if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_COMPLETION_RPC.equals(protocolIdentifier)) {
try {
final CompletionCoordinatorParticipant participant = new CompletionCoordinatorRPCImple(_coordManager, hier, true, participantProtocolService);
CompletionCoordinatorRPCProcessor.getProcessor().activateParticipant(participant, instanceIdentifier.getInstanceIdentifier());
_coordManager.suspend();
return getCompletionCoordinatorRPC(instanceIdentifier, isSecure);
} catch (Exception ex) {
ex.printStackTrace();
throw new InvalidStateException(ex.toString());
}
} else {
wstxLogger.i18NLogger.warn_mwlabs_wst_at_Registrar11Imple_1(AtomicTransactionConstants.WSAT_PROTOCOL, protocolIdentifier);
throw new InvalidProtocolException();
}
}
use of com.arjuna.wst11.stub.Volatile2PCStub in project narayana by jbosstm.
the class RegistrarImple method registerWithSubordinate.
private final W3CEndpointReference registerWithSubordinate(final SubordinateATCoordinator theTx, final W3CEndpointReference participantProtocolService, final String protocolIdentifier, final boolean isSecure) throws AlreadyRegisteredException, InvalidProtocolException, InvalidStateException, NoActivityException {
if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_DURABLE_2PC.equals(protocolIdentifier)) {
// enlist participant that wraps the requester URI.
final String participantId = "D" + new Uid().stringForm();
try {
final Durable2PCStub participantStub = new Durable2PCStub(participantId, participantProtocolService);
theTx.enlistParticipant(new DurableTwoPhaseCommitParticipant(participantStub, participantId));
return getCoordinator(participantId, isSecure);
} catch (Exception ex) {
throw new InvalidStateException();
}
} else if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_VOLATILE_2PC.equals(protocolIdentifier)) {
// enlist participant that wraps the requester URI.
final String participantId = "V" + new Uid().stringForm();
try {
final Volatile2PCStub participantStub = new Volatile2PCStub(participantId, participantProtocolService);
theTx.enlistSynchronization(new VolatileTwoPhaseCommitParticipant(participantStub));
return getCoordinator(participantId, isSecure);
} catch (Exception ex) {
throw new InvalidStateException();
}
} else if (AtomicTransactionConstants.WSAT_SUB_PROTOCOL_COMPLETION.equals(protocolIdentifier)) {
throw new InvalidStateException();
} else {
wstxLogger.i18NLogger.warn_mwlabs_wst_at_Registrar11Imple_1(AtomicTransactionConstants.WSAT_PROTOCOL, protocolIdentifier);
throw new InvalidProtocolException();
}
}
Aggregations