use of com.arjuna.wsc.InvalidCreateParametersException in project narayana by jbosstm.
the class UserTransactionStandaloneImple method begin.
public void begin(int timeout) throws WrongStateException, SystemException {
try {
if (_ctxManager.currentTransaction() != null)
throw new WrongStateException();
Context ctx = startTransaction(timeout, null);
_ctxManager.resume(new TxContextImple(ctx));
enlistCompletionParticipants();
} catch (InvalidCreateParametersException ex) {
tidyup();
throw new SystemException(ex.toString());
} catch (UnknownTransactionException ex) {
tidyup();
throw new SystemException(ex.toString());
} catch (SystemException ex) {
tidyup();
throw ex;
}
}
use of com.arjuna.wsc.InvalidCreateParametersException 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 com.arjuna.wsc.InvalidCreateParametersException 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 com.arjuna.wsc.InvalidCreateParametersException in project narayana by jbosstm.
the class UserTransactionStandaloneImple method startTransaction.
protected final Context startTransaction(int timeout, TxContextImple current) throws InvalidCreateParametersException, SystemException {
try {
// TODO: tricks for per app _activationCoordinatorService config, perhaps:
// InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("/foo.properties");
final Long expires = (timeout > 0 ? new Long(timeout) : null);
final String messageId = MessageId.getMessageId();
final CoordinationContext currentContext = (current != null ? getContext(current) : null);
final CoordinationContextType coordinationContext = ActivationCoordinator.createCoordinationContext(_activationCoordinatorService, messageId, AtomicTransactionConstants.WSAT_PROTOCOL, expires, currentContext);
if (coordinationContext == null) {
throw new SystemException(wstxLogger.i18NLogger.get_mwlabs_wst_at_remote_UserTransaction11Imple__2());
}
return new ContextImple(coordinationContext);
} catch (final InvalidCreateParametersException icpe) {
throw icpe;
} catch (final SoapFault sf) {
throw new SystemException(sf.getMessage());
} catch (final Exception ex) {
throw new SystemException(ex.toString());
}
}
use of com.arjuna.wsc.InvalidCreateParametersException in project narayana by jbosstm.
the class ContextFactoryImple method create.
// TODO interposition
/*
* If there is a context passed through to create then this newly created
* coordinator should be interposed.
*/
/**
* Creates a coordination context.
*
* @param coordinationTypeURI the coordination type uri
* @param expires the expire date/time for the returned context, can be null
* @param currentContext the current context, can be null
*
* @return the created coordination context
*
* @throws com.arjuna.wsc.InvalidCreateParametersException if a parameter passed is invalid
* this activity identifier.
*/
public CoordinationContext create(final String coordinationTypeURI, final Long expires, final CoordinationContextType currentContext, final boolean isSecure) throws InvalidCreateParametersException {
if (BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME.equals(coordinationTypeURI)) {
try {
if (currentContext == null) {
_coordManager.suspend();
final int timeout;
if (expires == null) {
timeout = 0;
} else {
final long longTimeout = expires.longValue();
timeout = (longTimeout > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) longTimeout);
}
_coordManager.begin(ArjunaContextImple.serviceType, timeout);
final ArjunaContextImple arjunaContext = ArjunaContextImple.getContext();
final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
final String registrationCoordinatorURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME, isSecure);
final CoordinationContext coordinationContext = new CoordinationContext();
coordinationContext.setCoordinationType(coordinationTypeURI);
CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
identifier.setValue("urn:" + arjunaContext.getTransactionIdentifier());
coordinationContext.setIdentifier(identifier);
final int transactionExpires = arjunaContext.getTransactionExpires();
if (transactionExpires > 0) {
Expires expiresInstance = new Expires();
expiresInstance.setValue(transactionExpires);
coordinationContext.setExpires(expiresInstance);
}
final W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, arjunaContext);
coordinationContext.setRegistrationService(registrationCoordinator);
// why is this created early even though the enlistment for termination
// is done late? well that's a good question. look at the corresponding registrar
// code to see why
// TODO sort this out
String transactionIdentifier = arjunaContext.getTransactionIdentifier();
BusinessActivityTerminator terminator = new BusinessActivityTerminatorImple();
TerminationCoordinatorProcessor.getProcessor().activateParticipant(terminator, transactionIdentifier);
_theRegistrar.associate();
return coordinationContext;
} else {
// we need to create a subordinate transaction -- this transaction will not be associated
// with an activity which identifes the parent transaction this means that we cannot use
// the activity service to do things like enlist participants or deliver participant
// initiated messages.
SubordinateBACoordinator subTx = (SubordinateBACoordinator) createSubordinate();
// now we register a coordinator completion participant on behalf of the subtransaction
// with the registration service defined in the current context
// there is no point registering a participant completion participant because we cannot
// know when it is ok to forward a completed message -- even when all N registered PC
// participants have notified completed another PC participant might enlist.
String ccpid = subTx.getCoordinatorCompletionParticipantid();
SubordinateCoordinatorCompletionParticipantStub ccp = new SubordinateCoordinatorCompletionParticipantStub(subTx);
String messageId = MessageId.getMessageId();
W3CEndpointReference participant = getParticipant(ccpid, isSecure);
W3CEndpointReference coordinator = RegistrationCoordinator.register(currentContext, messageId, participant, BusinessActivityConstants.WSBA_SUB_PROTOCOL_COORDINATOR_COMPLETION);
final CoordinatorCompletionParticipantEngine engine = new CoordinatorCompletionParticipantEngine(ccpid, coordinator, ccp);
CoordinatorCompletionParticipantProcessor.getProcessor().activateParticipant(engine, ccpid);
// we need to pass a manager to the stub in case it has to fail at completion
BAParticipantManager manager = new BACoordinatorCompletionParticipantManagerStub(engine);
ccp.setManager(manager);
// 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(coordinationTypeURI);
CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
String txId = subTx.get_uid().stringForm();
identifier.setValue("urn:" + txId);
coordinationContext.setIdentifier(identifier);
Expires expiresInstance = currentContext.getExpires();
final long transactionExpires = (expiresInstance != null ? expiresInstance.getValue() : 0);
if (transactionExpires > 0) {
expiresInstance = new Expires();
expiresInstance.setValue(transactionExpires);
coordinationContext.setExpires(expiresInstance);
}
W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, txId);
coordinationContext.setRegistrationService(registrationCoordinator);
// now associate the tx id with the sub transaction
_theRegistrar.associate(subTx);
return coordinationContext;
}
} catch (com.arjuna.mw.wsas.exceptions.NoActivityException ex) {
// TODO handle properly
ex.printStackTrace();
} catch (com.arjuna.mw.wsas.exceptions.SystemException ex) {
// TODO handle properly
ex.printStackTrace();
} catch (com.arjuna.mw.wsas.exceptions.WrongStateException ex) {
// TODO handle properly
ex.printStackTrace();
} catch (Exception ex) {
// TODO handle properly
ex.printStackTrace();
}
} else {
wstxLogger.i18NLogger.warn_mwlabs_wst_ba_Context11FactoryImple_1(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, coordinationTypeURI);
throw new InvalidCreateParametersException(wstxLogger.i18NLogger.get_mwlabs_wst_ba_Context11FactoryImple_3() + " < " + BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME + ", " + coordinationTypeURI + " >");
}
return null;
}
Aggregations