Search in sources :

Example 1 with CompletionCoordinatorParticipant

use of com.arjuna.wst11.CompletionCoordinatorParticipant in project narayana by jbosstm.

the class CompletionCoordinatorProcessorImpl method commit.

/**
 * Commit.
 * @param commit The commit notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void commit(final Notification commit, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final CompletionCoordinatorParticipant participant = getParticipant(instanceIdentifier);
    try {
        if (participant != null) {
            final String messageId = MessageId.getMessageId();
            try {
                participant.commit();
            } catch (final TransactionRolledBackException trbe) {
                final MAP responseAddressingContext = AddressingHelper.createResponseContext(map, messageId);
                CompletionInitiatorClient.getClient().sendAborted(participant.getParticipant(), responseAddressingContext, instanceIdentifier);
                return;
            } catch (final UnknownTransactionException ute) {
                final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, messageId);
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_1());
                CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
                return;
            } catch (final SystemException se) {
                final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, messageId);
                final String pattern = WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_2();
                final String message = MessageFormat.format(pattern, new Object[] { se });
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME, message);
                CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
                return;
            } catch (final Throwable th) {
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev("Unexpected exception thrown from commit:", th);
                }
                final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
                final SoapFault soapFault = new SoapFault11(th);
                CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
                return;
            }
            final MAP responseAddressingContext = AddressingHelper.createResponseContext(map, messageId);
            CompletionInitiatorClient.getClient().sendCommitted(participant.getParticipant(), responseAddressingContext, instanceIdentifier);
        } else {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Commit called on unknown participant: {0}", new Object[] { instanceIdentifier });
            }
            final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
            final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_5());
            CompletionInitiatorClient.getClient().sendSoapFault(faultAddressingContext, soapFault, instanceIdentifier);
        }
    } catch (Throwable throwable) {
        throwable.printStackTrace(System.err);
    }
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) TransactionRolledBackException(com.arjuna.wst.TransactionRolledBackException) SoapFault11(com.arjuna.webservices11.SoapFault11) CompletionCoordinatorParticipant(com.arjuna.wst11.CompletionCoordinatorParticipant) MAP(org.jboss.ws.api.addressing.MAP)

Example 2 with CompletionCoordinatorParticipant

use of com.arjuna.wst11.CompletionCoordinatorParticipant in project narayana by jbosstm.

the class CompletionCoordinatorRPCProcessorImpl method commit.

/**
 * Commit.
 * @param commit The commit notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public boolean commit(final Notification commit, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final CompletionCoordinatorParticipant participant = getParticipant(instanceIdentifier);
    {
        try {
            if (participant != null) {
                try {
                    participant.commit();
                } catch (final TransactionRolledBackException trbe) {
                    return false;
                } catch (final UnknownTransactionException ute) {
                    SOAPFactory factory = SOAPFactory.newInstance();
                    SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME);
                    soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_1());
                    throw new SOAPFaultException(soapFault);
                } catch (final SystemException se) {
                    SOAPFactory factory = SOAPFactory.newInstance();
                    SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME);
                    soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_2());
                    throw new SOAPFaultException(soapFault);
                } catch (final Throwable th) {
                    if (WSTLogger.logger.isTraceEnabled()) {
                        WSTLogger.logger.tracev("Unexpected exception thrown from commit:", th);
                    }
                    SOAPFactory factory = SOAPFactory.newInstance();
                    SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME);
                    soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_2());
                    throw new SOAPFaultException(soapFault);
                }
                return true;
            } else {
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev("Commit called on unknown participant: {0}", new Object[] { instanceIdentifier });
                }
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_5());
                throw new SOAPFaultException(soapFault);
            }
        } catch (SOAPException se) {
            se.printStackTrace(System.err);
            throw new ProtocolException(se);
        }
    }
}
Also used : ProtocolException(javax.xml.ws.ProtocolException) SOAPException(javax.xml.soap.SOAPException) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SOAPFault(javax.xml.soap.SOAPFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) CompletionCoordinatorParticipant(com.arjuna.wst11.CompletionCoordinatorParticipant) SOAPFactory(javax.xml.soap.SOAPFactory)

Example 3 with CompletionCoordinatorParticipant

use of com.arjuna.wst11.CompletionCoordinatorParticipant in project narayana by jbosstm.

the class CompletionCoordinatorRPCProcessorImpl method rollback.

/**
 * Rollback.
 * @param rollback The rollback notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public boolean rollback(final Notification rollback, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final CompletionCoordinatorParticipant participant = getParticipant(instanceIdentifier);
    try {
        if (participant != null) {
            final String messageId = MessageId.getMessageId();
            try {
                participant.rollback();
                return true;
            } catch (final UnknownTransactionException ute) {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_6());
                throw new SOAPFaultException(soapFault);
            } catch (final SystemException se) {
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_7());
                throw new SOAPFaultException(soapFault);
            } catch (final Throwable th) {
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev("Unexpected exception thrown from commit:", th);
                }
                SOAPFactory factory = SOAPFactory.newInstance();
                SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME);
                soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_7());
                throw new SOAPFaultException(soapFault);
            }
        } else {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Rollback called on unknown participant: {0}", new Object[] { instanceIdentifier });
            }
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME);
            soapFault.addDetail().addDetailEntry(ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME).addTextNode(WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_10());
            throw new SOAPFaultException(soapFault);
        }
    } catch (SOAPException se) {
        se.printStackTrace(System.err);
        throw new ProtocolException(se);
    }
}
Also used : ProtocolException(javax.xml.ws.ProtocolException) SOAPException(javax.xml.soap.SOAPException) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SOAPFault(javax.xml.soap.SOAPFault) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) CompletionCoordinatorParticipant(com.arjuna.wst11.CompletionCoordinatorParticipant) SOAPFactory(javax.xml.soap.SOAPFactory)

Example 4 with CompletionCoordinatorParticipant

use of com.arjuna.wst11.CompletionCoordinatorParticipant in project narayana by jbosstm.

the class CompletionCoordinatorProcessorImpl method rollback.

/**
 * Rollback.
 * @param rollback The rollback notification.
 * @param map The addressing context.
 * @param arjunaContext The arjuna context.
 */
public void rollback(final Notification rollback, final MAP map, final ArjunaContext arjunaContext) {
    final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
    final CompletionCoordinatorParticipant participant = getParticipant(instanceIdentifier);
    try {
        if (participant != null) {
            final String messageId = MessageId.getMessageId();
            try {
                participant.rollback();
            } catch (final UnknownTransactionException ute) {
                final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, messageId);
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_6());
                CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
                return;
            } catch (SystemException systemException) {
                final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, messageId);
                final String message = WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_7();
                final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNERROR_ERROR_CODE_QNAME, message);
                CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
                return;
            } catch (final Throwable th) {
                if (WSTLogger.logger.isTraceEnabled()) {
                    WSTLogger.logger.tracev("Unexpected exception thrown from rollback:", th);
                }
                final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
                final SoapFault soapFault = new SoapFault11(th);
                CompletionInitiatorClient.getClient().sendSoapFault(participant.getParticipant(), faultAddressingContext, soapFault, instanceIdentifier);
                return;
            }
            final MAP responseAddressingContext = AddressingHelper.createResponseContext(map, messageId);
            CompletionInitiatorClient.getClient().sendAborted(participant.getParticipant(), responseAddressingContext, instanceIdentifier);
        } else {
            if (WSTLogger.logger.isTraceEnabled()) {
                WSTLogger.logger.tracev("Rollback called on unknown participant: {0}", new Object[] { instanceIdentifier });
            }
            final MAP faultAddressingContext = AddressingHelper.createFaultContext(map, MessageId.getMessageId());
            final SoapFault soapFault = new SoapFault11(SoapFaultType.FAULT_SENDER, ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME, WSTLogger.i18NLogger.get_wst11_messaging_CompletionCoordinatorProcessorImpl_10());
            CompletionInitiatorClient.getClient().sendSoapFault(faultAddressingContext, soapFault, instanceIdentifier);
        }
    } catch (Throwable throwable) {
        throwable.printStackTrace(System.err);
    }
}
Also used : SoapFault(com.arjuna.webservices.SoapFault) UnknownTransactionException(com.arjuna.wst.UnknownTransactionException) SystemException(com.arjuna.wst.SystemException) InstanceIdentifier(com.arjuna.webservices11.wsarj.InstanceIdentifier) SoapFault11(com.arjuna.webservices11.SoapFault11) CompletionCoordinatorParticipant(com.arjuna.wst11.CompletionCoordinatorParticipant) MAP(org.jboss.ws.api.addressing.MAP)

Example 5 with CompletionCoordinatorParticipant

use of com.arjuna.wst11.CompletionCoordinatorParticipant 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();
    }
}
Also used : DurableTwoPhaseCommitParticipant(com.arjuna.mwlabs.wst.at.participants.DurableTwoPhaseCommitParticipant) Volatile2PCStub(com.arjuna.wst11.stub.Volatile2PCStub) Durable2PCStub(com.arjuna.wst11.stub.Durable2PCStub) ActivityHierarchy(com.arjuna.mw.wsas.activity.ActivityHierarchy) ProtocolNotRegisteredException(com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) SubordinateATCoordinator(com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator) Uid(com.arjuna.ats.arjuna.common.Uid) SystemException(com.arjuna.mw.wsas.exceptions.SystemException) CompletionCoordinatorRPCImple(com.arjuna.mwlabs.wst11.at.participants.CompletionCoordinatorRPCImple) VolatileTwoPhaseCommitParticipant(com.arjuna.mwlabs.wst.at.participants.VolatileTwoPhaseCommitParticipant) CompletionCoordinatorImple(com.arjuna.mwlabs.wst11.at.participants.CompletionCoordinatorImple) CompletionCoordinatorParticipant(com.arjuna.wst11.CompletionCoordinatorParticipant)

Aggregations

CompletionCoordinatorParticipant (com.arjuna.wst11.CompletionCoordinatorParticipant)5 InstanceIdentifier (com.arjuna.webservices11.wsarj.InstanceIdentifier)4 SoapFault (com.arjuna.webservices.SoapFault)2 SoapFault11 (com.arjuna.webservices11.SoapFault11)2 SystemException (com.arjuna.wst.SystemException)2 UnknownTransactionException (com.arjuna.wst.UnknownTransactionException)2 SOAPException (javax.xml.soap.SOAPException)2 SOAPFactory (javax.xml.soap.SOAPFactory)2 SOAPFault (javax.xml.soap.SOAPFault)2 ProtocolException (javax.xml.ws.ProtocolException)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 MAP (org.jboss.ws.api.addressing.MAP)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 ActivityHierarchy (com.arjuna.mw.wsas.activity.ActivityHierarchy)1 SystemException (com.arjuna.mw.wsas.exceptions.SystemException)1 ProtocolNotRegisteredException (com.arjuna.mw.wscf.exceptions.ProtocolNotRegisteredException)1 SubordinateATCoordinator (com.arjuna.mwlabs.wscf.model.twophase.arjunacore.subordinate.SubordinateATCoordinator)1 DurableTwoPhaseCommitParticipant (com.arjuna.mwlabs.wst.at.participants.DurableTwoPhaseCommitParticipant)1 VolatileTwoPhaseCommitParticipant (com.arjuna.mwlabs.wst.at.participants.VolatileTwoPhaseCommitParticipant)1 CompletionCoordinatorImple (com.arjuna.mwlabs.wst11.at.participants.CompletionCoordinatorImple)1