use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class SubordinateImporter method importContext.
public static TxContext importContext(CoordinationContextType cc) {
// get the subordinate transaction manager to install any existing
// subordinate tx for this one or create and install a new one.
final String identifier = cc.getIdentifier().getValue();
TxContext subordinateTxContext = subordinateContextMap.get(identifier);
if (subordinateTxContext == null) {
// create a context for a local coordinator
CoordinationContext context = null;
try {
context = atContextFactory.create(AtomicTransactionConstants.WSAT_PROTOCOL, 0L, cc, false);
} catch (InvalidCreateParametersException e) {
// should not happen
}
subordinateTxContext = new TxContextImple(context);
subordinateContextMap.put(identifier, subordinateTxContext);
// register a cleanup callback with the subordinate transactionso that the entry gets removed
// when the transcation commits or rolls back
// remove "urn:" prefix
String subordinateId = context.getIdentifier().getValue().substring(4);
SubordinateATCoordinator.SubordinateCallback callback = new SubordinateATCoordinator.SubordinateCallback() {
public String parentId = identifier;
public void run() {
subordinateContextMap.remove(parentId);
}
};
SubordinateATCoordinator.addCallback(subordinateId, callback);
}
return subordinateTxContext;
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class UserBusinessActivityImple method getTerminationCoordinator.
private W3CEndpointReference getTerminationCoordinator(final TxContextImple ctx) throws SystemException {
final CoordinationContextType coordinationContext = ctx.context().getCoordinationContext();
final String messageId = MessageId.getMessageId();
try {
return RegistrationCoordinator.register(coordinationContext, messageId, getParticipantProtocolService(ctx.identifier(), ctx.isSecure()), com.arjuna.webservices.wsarjtx.ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION);
} catch (final Throwable th) {
throw new SystemException(wstxLogger.i18NLogger.get_mwlabs_wst11_ba_remote_UserBusinessActivityImple_3());
}
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class UserBusinessActivityImple method getContext.
/**
* fetch the coordination context type stashed in the current BA context implememtation
* and use it to construct an instance of the coordination context extension type we need to
* send down the wire to the activation coordinator
* @param current the current AT context implememtation
* @return an instance of the coordination context extension type
*/
private CoordinationContext getContext(TxContextImple current) {
CoordinationContextType contextType = getContextType(current);
CoordinationContext context = new CoordinationContext();
context.setCoordinationType(contextType.getCoordinationType());
context.setExpires(contextType.getExpires());
context.setIdentifier(contextType.getIdentifier());
context.setRegistrationService(contextType.getRegistrationService());
return context;
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class ActivationTest method executeRequestTest.
private void executeRequestTest(final String messageId, final String coordinationType, final Long expires, final CoordinationContext coordinationContext) throws Exception {
final MAP map = AddressingHelper.createRequestContext(TestUtil11.activationCoordinatorService, messageId);
Expires expiresInstance;
if (expires == null) {
expiresInstance = null;
} else {
expiresInstance = new Expires();
expiresInstance.setValue(expires.longValue());
}
CreateCoordinationContextResponseType createCoordinationContextResponseType;
createCoordinationContextResponseType = ActivationCoordinatorClient.getClient().sendCreateCoordination(map, coordinationType, expiresInstance, coordinationContext);
final CreateCoordinationContextDetails details = testActivationCoordinatorProcessor.getCreateCoordinationContextDetails(messageId, 10000);
final CreateCoordinationContextType requestCreateCoordinationContext = details.getCreateCoordinationContext();
final MAP requestMAP = details.getMAP();
assertNotNull(requestMAP.getTo());
assertEquals(requestMAP.getTo(), TestUtil11.activationCoordinatorService);
// we don't care about the reply to field -- this is an RPC style message
// assertNotNull(requestMAP.getReplyTo());
// assertTrue(AddressingHelper.isNoneReplyTo(requestMAP));
assertNotNull(requestMAP.getMessageID());
assertEquals(requestMAP.getMessageID(), messageId);
if (expires == null) {
assertNull(requestCreateCoordinationContext.getExpires());
} else {
assertNotNull(requestCreateCoordinationContext.getExpires());
assertEquals(expires.longValue(), requestCreateCoordinationContext.getExpires().getValue());
}
if (coordinationContext == null) {
assertNull(requestCreateCoordinationContext.getCurrentContext());
} else {
assertNotNull(requestCreateCoordinationContext.getCurrentContext());
assertEquals(requestCreateCoordinationContext.getCurrentContext().getIdentifier().getValue(), coordinationContext.getIdentifier().getValue());
if (coordinationContext.getExpires() == null) {
assertNull(requestCreateCoordinationContext.getCurrentContext().getExpires());
} else {
assertNotNull(requestCreateCoordinationContext.getCurrentContext().getExpires());
assertEquals(requestCreateCoordinationContext.getCurrentContext().getExpires().getValue(), coordinationContext.getExpires().getValue());
}
assertNotNull(requestCreateCoordinationContext.getCurrentContext().getIdentifier());
assertEquals(requestCreateCoordinationContext.getCurrentContext().getIdentifier().getValue(), coordinationContext.getIdentifier().getValue());
}
assertNotNull(requestCreateCoordinationContext.getCoordinationType());
assertEquals(requestCreateCoordinationContext.getCoordinationType(), coordinationType);
// make sure we got a sensible response
checkResponse(coordinationType, expiresInstance, createCoordinationContextResponseType);
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext in project narayana by jbosstm.
the class ActivationTest method testRequestWithoutExpiresWithCurrentContextWithoutExpires.
@Test
public void testRequestWithoutExpiresWithCurrentContextWithoutExpires() throws Exception {
final String messageId = "testRequestWithoutExpiresWithCurrentContextWithoutExpires";
final String coordinationType = TestUtil.COORDINATION_TYPE;
final Long expires = null;
final CoordinationContext coordinationContext = new CoordinationContext();
coordinationContext.setCoordinationType(coordinationType);
CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
identifier.setValue(TestUtil.PROTOCOL_IDENTIFIER);
coordinationContext.setIdentifier(identifier);
W3CEndpointReference registrationService = TestUtil11.getRegistrationEndpoint(identifier.getValue());
coordinationContext.setRegistrationService(registrationService);
executeRequestTest(messageId, coordinationType, expires, coordinationContext);
}
Aggregations