use of com.arjuna.webservices11.ServiceRegistry in project narayana by jbosstm.
the class ContextFactoryImple method createBridgedTransaction.
/**
* create a bridged to subordinate WS-AT 1.1 transaction, associate it with the registrar and create and return
* a coordination context for it. n.b. this is a private, behind-the-scenes method for use by the JTA-AT
* transaction bridge code.
* @param subordinateType a unique string which groups subordinates for the benefit of their parent tx/app and
* allows them to be identified and retrieved as a group during recovery
* @param expires the timeout for the bridged to AT transaction
* @param isSecure true if the registration cooridnator URL should use a secure address, otherwise false.
* @return a coordination context for the bridged to transaction
*/
public BridgeTxData createBridgedTransaction(String subordinateType, final Long expires, final boolean isSecure) {
// we must have a type and it must not be the AT-AT subordinate type
if (subordinateType == null || SubordinateATCoordinator.SUBORDINATE_TX_TYPE_AT_AT.equals(subordinateType)) {
return null;
}
// we need to create a subordinate transaction and register it as both a durable and volatile
// participant with the registration service defined in the current context
SubordinateATCoordinator subTx = null;
try {
subTx = (SubordinateATCoordinator) createSubordinate(subordinateType);
} catch (NoActivityException e) {
// will not happen
return null;
} catch (InvalidProtocolException e) {
// will not happen
return null;
} catch (SystemException e) {
// may happen
return null;
}
// ok now create the context
final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
final String registrationCoordinatorURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME, isSecure);
final CoordinationContext coordinationContext = new CoordinationContext();
coordinationContext.setCoordinationType(AtomicTransactionConstants.WSAT_PROTOCOL);
CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
String txId = subTx.get_uid().stringForm();
identifier.setValue("urn:" + txId);
coordinationContext.setIdentifier(identifier);
if (expires != null && expires.longValue() > 0) {
Expires expiresInstance = new Expires();
expiresInstance.setValue(expires);
coordinationContext.setExpires(expiresInstance);
}
W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, txId);
coordinationContext.setRegistrationService(registrationCoordinator);
try {
_theRegistrar.associate(subTx);
} catch (Exception e) {
// will not happen
}
BridgeTxData bridgeTxData = new BridgeTxData();
bridgeTxData.context = coordinationContext;
bridgeTxData.coordinator = subTx;
bridgeTxData.identifier = txId;
return bridgeTxData;
}
use of com.arjuna.webservices11.ServiceRegistry in project narayana by jbosstm.
the class RegistrarImple method getCompletionCoordinator.
private W3CEndpointReference getCompletionCoordinator(final InstanceIdentifier instanceIdentifier, final boolean isSecure) {
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
String address = serviceRegistry.getServiceURI(AtomicTransactionConstants.COMPLETION_COORDINATOR_SERVICE_NAME, isSecure);
builder.serviceName(AtomicTransactionConstants.COMPLETION_COORDINATOR_SERVICE_QNAME);
builder.endpointName(AtomicTransactionConstants.COMPLETION_COORDINATOR_PORT_QNAME);
builder.address(address);
InstanceIdentifier.setEndpointInstanceIdentifier(builder, instanceIdentifier);
return builder.build();
}
use of com.arjuna.webservices11.ServiceRegistry in project narayana by jbosstm.
the class RegistrarImple method getCoordinator.
private W3CEndpointReference getCoordinator(final String participantId, final boolean isSecure) {
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
String address = serviceRegistry.getServiceURI(AtomicTransactionConstants.COORDINATOR_SERVICE_NAME, isSecure);
builder.serviceName(AtomicTransactionConstants.COORDINATOR_SERVICE_QNAME);
builder.endpointName(AtomicTransactionConstants.COORDINATOR_PORT_QNAME);
builder.address(address);
InstanceIdentifier.setEndpointInstanceIdentifier(builder, participantId);
return builder.build();
}
use of com.arjuna.webservices11.ServiceRegistry in project narayana by jbosstm.
the class UserTransactionImple method getCompletionParticipant.
/**
* Create an endpoint for the local participant service labelled with the current context id which can be passed
* to the registration service and handed on to the registered coordinator to call back to this transaction
* @param id the current transaction context identifier
* @return
*/
private W3CEndpointReference getCompletionParticipant(final String id, final boolean isSecure) {
final QName serviceName = AtomicTransactionConstants.COMPLETION_INITIATOR_SERVICE_QNAME;
final QName endpointName = AtomicTransactionConstants.COMPLETION_INITIATOR_PORT_QNAME;
final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
final String address = serviceRegistry.getServiceURI(AtomicTransactionConstants.COMPLETION_INITIATOR_SERVICE_NAME, isSecure);
W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
builder.serviceName(serviceName);
builder.endpointName(endpointName);
builder.address(address);
InstanceIdentifier.setEndpointInstanceIdentifier(builder, id);
return builder.build();
}
use of com.arjuna.webservices11.ServiceRegistry 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;
}
Aggregations