use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.
the class CompletionParticipantTest method testSendCommit.
@Test
public void testSendCommit() throws Exception {
final String messageId = "testSendCommit";
final MAP map = AddressingHelper.createRequestContext(TestUtil.completionCoordinatorServiceURI, messageId);
final InstanceIdentifier instanceIdentifier = new InstanceIdentifier("1");
final W3CEndpointReference endpoint = TestUtil.getCompletionCoordinatorEndpoint(instanceIdentifier.getInstanceIdentifier());
CompletionCoordinatorClient.getClient().sendCommit(endpoint, map, new InstanceIdentifier("sender"));
final CompletionCoordinatorDetails details = testCompletionCoordinatorProcessor.getCompletionCoordinatorDetails(messageId, 10000);
assertTrue(details.hasCommit());
checkDetails(details, true, true, messageId, instanceIdentifier);
}
use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.
the class CompletionParticipantTest method testSendRollback.
@Test
public void testSendRollback() throws Exception {
final String messageId = "testSendRollback";
final MAP map = AddressingHelper.createRequestContext(TestUtil.completionCoordinatorServiceURI, messageId);
final InstanceIdentifier instanceIdentifier = new InstanceIdentifier("2");
final W3CEndpointReference endpoint = TestUtil.getCompletionCoordinatorEndpoint(instanceIdentifier.getInstanceIdentifier());
CompletionCoordinatorClient.getClient().sendRollback(endpoint, map, new InstanceIdentifier("sender"));
final CompletionCoordinatorDetails details = testCompletionCoordinatorProcessor.getCompletionCoordinatorDetails(messageId, 10000);
assertTrue(details.hasRollback());
checkDetails(details, true, true, messageId, instanceIdentifier);
}
use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.
the class TestContextFactory method create.
public CoordinationContext create(final String coordinationTypeURI, final Long expires, final CoordinationContextType currentContext, boolean isSecure) throws InvalidCreateParametersException {
if (coordinationTypeURI.equals(TestUtil.INVALID_CREATE_PARAMETERS_COORDINATION_TYPE)) {
throw new InvalidCreateParametersException();
}
final ServiceRegistry serviceRegistry = ServiceRegistry.getRegistry();
final String registrationURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME);
final W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
builder.serviceName(CoordinationConstants.REGISTRATION_SERVICE_QNAME);
builder.endpointName(CoordinationConstants.REGISTRATION_ENDPOINT_QNAME);
builder.address(registrationURI);
W3CEndpointReference registrationService = builder.build();
CoordinationContext testCoordinationContext = new CoordinationContext();
CoordinationContext.Identifier identifier = new CoordinationContext.Identifier();
identifier.setValue(Integer.toString(nextIdentifier()));
testCoordinationContext.setIdentifier(identifier);
if (expires != null && expires.longValue() > 0) {
Expires expiresInstance = new Expires();
expiresInstance.setValue(expires);
testCoordinationContext.setExpires(expiresInstance);
}
testCoordinationContext.setCoordinationType(_coordinationType);
testCoordinationContext.setRegistrationService(registrationService);
try {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPElement element = factory.createElement(TestUtil.TEST_ELEMENT_EXTENSION_VALUE_QNAME);
element.addTextNode(TestUtil.TEST_EXTENSION_VALUE);
testCoordinationContext.getAny().add(element);
} catch (SOAPException e) {
// TODO log error here
}
return testCoordinationContext;
}
use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.
the class ATInteropUtil method registerParticipant.
/**
* Register the participant in the specified coordination context.
* @param context The coordination context.
* @param participant The participant.
* @param id The participant id.
* @param protocol The sub protocol to register for.
* @return The participant engine.
* @throws Exception for errors.
*/
private static ParticipantEngine registerParticipant(final CoordinationContextType context, final Participant participant, final String id, final String protocol) throws Exception {
final W3CEndpointReference coordinator = RegistrationCoordinator.register(context, MessageId.getMessageId(), getParticipant(id), protocol);
final ParticipantEngine engine = new ParticipantEngine(participant, id, coordinator);
ParticipantProcessor.getProcessor().activateParticipant(engine, id);
return engine;
}
use of javax.xml.ws.wsaddressing.W3CEndpointReference in project narayana by jbosstm.
the class TerminationCoordinatorProcessorImpl method cancel.
/**
* Cancel.
* @param cancel The cancel notification.
* @param map The addressing context.
* @param arjunaContext The arjuna context.
*/
public void cancel(final NotificationType cancel, final MAP map, final ArjunaContext arjunaContext) {
final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
final BusinessActivityTerminator participant = getParticipant(instanceIdentifier);
try {
if (participant != null) {
W3CEndpointReference endpoint = participant.getEndpoint();
final String messageId = MessageId.getMessageId();
try {
participant.cancel();
} catch (final FaultedException fe) {
final MAP responseMAP = AddressingHelper.createNotificationContext(messageId);
TerminationParticipantClient.getClient().sendFaulted(endpoint, responseMAP, instanceIdentifier);
} catch (final UnknownTransactionException ute) {
final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_1());
TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
return;
} catch (final SystemException se) {
final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
final String message = WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_2();
final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME, message);
TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
return;
} catch (final Throwable th) {
if (WSTLogger.logger.isTraceEnabled()) {
WSTLogger.logger.tracev("Unexpected exception thrown from cancel:", th);
}
final MAP faultMAP = AddressingHelper.createFaultContext(map, messageId);
final SoapFault soapFault = new SoapFault11(th);
TerminationParticipantClient.getClient().sendSoapFault(endpoint, faultMAP, soapFault, instanceIdentifier);
return;
}
final MAP responseMAP = AddressingHelper.createNotificationContext(messageId);
TerminationParticipantClient.getClient().sendCancelled(endpoint, responseMAP, instanceIdentifier);
} else {
if (WSTLogger.logger.isTraceEnabled()) {
WSTLogger.logger.tracev("Cancel called on unknown participant: {0}", new Object[] { instanceIdentifier });
}
final MAP faultMAP = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_TerminationCoordinatorProcessorImpl_5());
TerminationParticipantClient.getClient().sendSoapFault(soapFault, faultMAP, instanceIdentifier);
}
} catch (Throwable throwable) {
throwable.printStackTrace(System.err);
}
}
Aggregations