FileDocCategorySizeDatePackage
ParticipantPortTypeImpl.javaAPI DocExample11169Tue May 29 16:57:20 BST 2007com.sun.xml.ws.tx.webservice.member.at

ParticipantPortTypeImpl

public class ParticipantPortTypeImpl extends Object implements ParticipantPortType
WS-Atomic Transaction participant protocol service
author
Joe.Fialli@Sun.COM
version
$Revision: 1.4.2.1 $
since
1.0

Fields Summary
public static final String
serviceName
public static final String
portName
private static final com.sun.xml.ws.tx.common.TxLogger
logger
private WebServiceContext
wsContext
private static com.sun.xml.ws.developer.StatefulWebServiceManager
manager
private String
activityId
private String
participantId
private EndpointReference
fallbackEPR
private com.sun.xml.ws.tx.at.ATParticipant
participant
Constructors Summary
public ParticipantPortTypeImpl()


      
    
public ParticipantPortTypeImpl(String activityId, String participantId)

        this.activityId = activityId;
        this.participantId = participantId;
    
Methods Summary
public voidcommitOperation(Notification parameters)

        final String METHOD_NAME = "commitOperation";

        initPerOperationData();
        if (logger.isLogging(Level.FINER)) {
            logger.entering(METHOD_NAME, getCoordIdPartId());
        }
        if (participant != null) {
            try {
                participant.commit();
            } catch (TXException ex) {
                if (logger.isLogging(Level.WARNING)) {
                    logger.warning("commitOperation", ex.getLocalizedMessage());
                }
            }
        } else {
            // Participant unknown.
            // TODO: send committed to coordinator using wsa:replyTo of this message
            // Specified in 2004 WS-AT, Section 3.3
            // 2004 WS-AT, Section 3.3: Participant unknown, must send abort back to wsa:ReplyTo

            if (fallbackEPR != null) {
                if (logger.isLogging(Level.WARNING)) {
                    logger.warning("commitOperation", "Unknown participant " + getCoordIdPartId() +
                            " reply with committed to " + fallbackEPR);
                }
                ATParticipant.getATCoordinatorWS(fallbackEPR, null, false).committedOperation(null);
            } else {
                if (logger.isLogging(Level.SEVERE)) {
                    logger.severe("commitOperation", "required wsa:ReplyTo property not found");
                }
            }
        }
        if (logger.isLogging(Level.FINER)) {
            logger.exiting(METHOD_NAME, getCoordIdPartId());
        }
    
private java.lang.StringgetCoordIdPartId()

        return "CoorId=" + activityId + " PartId=" + participantId + " ";
    
public static com.sun.xml.ws.developer.StatefulWebServiceManagergetManager()

        return manager;
    
private voidinitPerOperationData()

        participant = null;
        fallbackEPR = null;

        if (wsContext != null) {
            MessageContext mc = wsContext.getMessageContext();
            if (mc != null) {
                HeaderList hdrLst = (HeaderList) mc.get(INBOUND_HEADER_LIST_PROPERTY);
                if (hdrLst != null) {
                    fallbackEPR = hdrLst.getReplyTo(AddressingVersion.MEMBER, SOAPVersion.SOAP_11).
                            toSpec(MemberSubmissionEndpointReference.class);
                } else {
                    if (logger.isLogging(Level.WARNING)) {
                        logger.warning("initOperationData", "INBOUND_HEADER_LIST_PROPERTY unexpectedly null");
                    }
                }
            } else {
                if (logger.isLogging(Level.WARNING)) {
                    logger.warning("initOperationData", "WebServiceContext.getMessageContext() unexpectedly null");
                }
            }
        } else {
            if (logger.isLogging(Level.WARNING)) {
                logger.warning("initContextFromIncomingMessage", "wsContext unexpectedly null");
            }
        }

        ATCoordinator coordinator = null;
        if (activityId == UNKNOWN_ID) {
            if (logger.isLogging(Level.INFO)) {
                logger.info("Two Phase Commit Participant", "handling notification for an unknown transaction");
            }
            return;
        } else {
            coordinator = (ATCoordinator) CoordinationManager.getInstance().getCoordinator(activityId);
            if (coordinator != null) {
                try {
                    participant = (ATParticipant) coordinator.getRegistrant(participantId);
                } catch (ClassCastException ce) {
                    if (logger.isLogging(Level.WARNING)) {
                        logger.warning("getATPartcipant", ce.getLocalizedMessage());
                    }
                }
            }
        }
    
public voidprepareOperation(Notification parameters)

        final String METHOD_NAME = "prepareOperation";

        initPerOperationData();
        if (logger.isLogging(Level.FINER)) {
            logger.entering(METHOD_NAME, getCoordIdPartId());
        }
        if (participant != null) {
            try {
                participant.prepare();
            } catch (TXException ex) {
                // TODO: should this be a fault
                if (logger.isLogging(Level.WARNING)) {
                    logger. warning("prepareOperation", "caught TXException during prepare");
                }
            }
        } else {
            if (fallbackEPR != null) {
                // 2004 WS-AT, Section 3.3: Participant unknown, must send abort back to wsa:ReplyTo
                if (logger.isLogging(Level.WARNING)) {
                    logger.warning("prepareOperation", "Unknown participant " + getCoordIdPartId() +
                            " reply with aborted to " + fallbackEPR);
                }
                ATParticipant.getATCoordinatorWS(fallbackEPR, null, false).abortedOperation(null);
            } else {
                if (logger.isLogging(Level.SEVERE)) {
                    logger.severe("prepareOperation", "required wsa:ReplyTo property not found");
                }
            }
        }
        if (logger.isLogging(Level.FINER)) {
            logger.exiting(METHOD_NAME, getCoordIdPartId());
        }
    
public voidrollbackOperation(Notification parameters)

        final String METHOD_NAME = "rollbackOperation";

        initPerOperationData();
        if (logger.isLogging(Level.FINER)) {
            logger.entering(METHOD_NAME, parameters);
        }
        if (participant != null) {
            participant.abort();
        } else {
            if (fallbackEPR != null) {
                // Particpant unknown. (no need to forget)
                if (logger.isLogging(Level.WARNING)) {
                    logger.warning("rollbackOperation", "Unknown participant " + getCoordIdPartId() +
                            " reply with aborted to" + fallbackEPR);
                }
                ATParticipant.getATCoordinatorWS(fallbackEPR, null, false).abortedOperation(null);
            } else {
                if (logger.isLogging(Level.SEVERE)) {
                    logger.severe("rollbackOperation", "required wsa:ReplyTo property not found");
                }
            }
        }
        if (logger.isLogging(Level.FINER)) {
            logger.exiting(METHOD_NAME, getCoordIdPartId());
        }
    
public static voidsetManager(com.sun.xml.ws.developer.StatefulWebServiceManager aManager)

        manager = aManager;