Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags. 
   * See the copyright.txt in the distribution for a full listing 
   * of individual contributors.
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
   * of the GNU Lesser General Public License, v. 2.1.
  * This program is distributed in the hope that it will be useful, but WITHOUT A
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public License,
  * v.2.1 along with this distribution; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
  * 
  * (C) 2005-2006,
  * @author JBoss Inc.
  */
 package com.arjuna.wst11.messaging;
 
 import  org.jboss.ws.api.addressing.MAP;
 
The Coordinator Completion Participant processor.

Author(s):
kevin
 
 {
    
The activated object processor.
 
     private final ActivatedObjectProcessor activatedObjectProcessor = new ActivatedObjectProcessor() ;

    
Activate the participant.

Parameters:
participant The participant.
identifier The identifier.
 
     public void activateParticipant(final CoordinatorCompletionParticipantInboundEvents participantfinal String identifier)
     {
         .activateObject(participantidentifier) ;
     }

    
Deactivate the participant.

Parameters:
participant The participant.
 
     public void deactivateParticipant(final CoordinatorCompletionParticipantInboundEvents participant)
     {
         .deactivateObject(participant) ;
     }

    
Check whether a participant with the given id is currently active

Parameters:
identifier The identifier.
 
     public boolean isActive(String identifier) {
         return .getObject(identifier) != null;
     }

    
Get the participant with the specified identifier.

Parameters:
instanceIdentifier The participant identifier.
Returns:
The participant or null if not known.
 
     {
         final String identifier = (instanceIdentifier != null ? instanceIdentifier.getInstanceIdentifier() : null) ;
     }

    
Cancel.

Parameters:
cancel The cancel notification.
map The addressing context.
arjunaContext The arjuna context.
    public void cancel(final NotificationType cancelfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;

        
ensure the BA participant recovery manager is running
        XTSBARecoveryManager recoveryManager = XTSBARecoveryManager.getRecoveryManager();
        if (recoveryManager == null) {
            // log warning and drop this message -- it will be resent
            return;
        }
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;
        if (participant != null)
        {
            try
            {
                participant.cancel(cancelmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from cancel:"th) ;
                }
            }
        }
        else if (!recoveryManager.isParticipantRecoveryStarted())
        {
        }
        else if (recoveryManager.findParticipantRecoveryRecord(instanceIdentifier.getInstanceIdentifier()) != null) {
        }
        else
        {
            if (..isTraceEnabled())
            {
                ..tracev("Cancel called on unknown participant: {0}"new Object[] {instanceIdentifier}) ;
            }
            sendCancelled(maparjunaContext) ;
        }
    }

    
Close.

Parameters:
close The close notification.
map The addressing context.
arjunaContext The arjuna context.
    public void close(final NotificationType closefinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;

        
ensure the BA participant recovery manager is running
        XTSBARecoveryManager recoveryManager = XTSBARecoveryManager.getRecoveryManager();
        if (recoveryManager == null) {
            // log warning and drop this message -- it will be resent
            return;
        }
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;
        if (participant != null)
        {
            try
            {
                participant.close(closemaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from close:"th) ;
                }
            }
        }
        else if (!recoveryManager.isParticipantRecoveryStarted()) {
        }
        else if (recoveryManager.findParticipantRecoveryRecord(instanceIdentifier.getInstanceIdentifier()) != null) {
        }
        else
        {
            if (..isTraceEnabled())
            {
                ..tracev("Close called on unknown participant: {0}"new Object[] {instanceIdentifier}) ;
            }
            sendClosed(maparjunaContext) ;
        }
    }

    
Compensate.

Parameters:
compensate The compensate notification.
map The addressing context.
arjunaContext The arjuna context.
    public void compensate(final NotificationType compensatefinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;

        
ensure the BA participant recovery manager is running
        XTSBARecoveryManager recoveryManager = XTSBARecoveryManager.getRecoveryManager();
        if (recoveryManager == null) {
            // log warning and drop this message -- it will be resent
            return;
        }
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;
        if (participant != null)
        {
            try
            {
                participant.compensate(compensatemaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from compensate:"th) ;
                }
            }
        }
        else if (!recoveryManager.isParticipantRecoveryStarted()) {
        }
        else if (recoveryManager.findParticipantRecoveryRecord(instanceIdentifier.getInstanceIdentifier()) != null) {
        }
        else
        {
            if (..isTraceEnabled())
            {
                ..tracev("Compensate called on unknown participant: {0}"new Object[] {instanceIdentifier}) ;
            }
            sendCompensated(maparjunaContext) ;
        }
    }

    
Complete.

Parameters:
complete The complete notification.
map The addressing context.
arjunaContext The arjuna context.
    public void complete(final NotificationType completefinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;

        
ensure the BA participant recovery manager is running
        XTSBARecoveryManager recoveryManager = XTSBARecoveryManager.getRecoveryManager();
        if (recoveryManager == null) {
            // log warning and drop this message -- it will be resent
            return;
        }
        if (participant != null)
        {
            try
            {
                participant.complete(completemaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from complete:"th) ;
                }
            }
        }
        else if (!recoveryManager.isParticipantRecoveryStarted()) {
        }
        else if (recoveryManager.findParticipantRecoveryRecord(instanceIdentifier.getInstanceIdentifier()) != null) {
        }
        else
        {
            if (..isTraceEnabled())
            {
                ..tracev("Complete called on unknown participant: {0}"new Object[] {instanceIdentifier}) ;
            }
            sendFail(maparjunaContext..getValue()) ;
        }
    }

    
Exited.

Parameters:
exited The exited notification.
map The addressing context.
arjunaContext The arjuna context.
    public void exited(final NotificationType exitedfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;
        if (participant != null)
        {
            try
            {
                participant.exited(exitedmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from exited:"th) ;
                }
            }
        }
        else if (..isTraceEnabled())
        {
            ..tracev("Exited called on unknown participant: {0}"new Object[] {instanceIdentifier}) ;
        }
    }

    
Not Completed.

Parameters:
notCompleted The not completed notification.
map The addressing context.
arjunaContext The arjuna context.
    public void notCompleted(final NotificationType notCompletedfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;
        if (participant != null)
        {
            try
            {
                participant.notCompleted(notCompletedmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from notCompleted:"th) ;
                }
            }
        }
        else if (..isTraceEnabled())
        {
            ..tracev("NotCompleted called on unknown participant: {0}"new Object[] {instanceIdentifier}) ;
        }
    }

    
Failed.

Parameters:
failed The failed notification.
map The addressing context.
arjunaContext The arjuna context.
    public void failed(final NotificationType failedfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;
        if (participant != null)
        {
            try
            {
                participant.failed(failedmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from failed "th);
                }
            }
        }
        else if (..isTraceEnabled())
        {
            ..tracev("Failed called on unknown participant: {0}"instanceIdentifier);
        }
    }

    
Get Status.

Parameters:
getStatus The get status notification.
map The addressing context.
arjunaContext The arjuna context.
    public void getStatus(final NotificationType getStatusfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;
        if (participant != null)
        {
            try
            {
                participant.getStatus(getStatusmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from getStatus:"th) ;
                }
            }
        }
        else
        {
            if (..isTraceEnabled())
            {
                ..tracev("GetStatus called on unknown participant: {0}"new Object[] {instanceIdentifier}) ;
            }
            // send an invalid state fault
            final String messageId = MessageId.getMessageId();
            final MAP faultMAP = AddressingHelper.createFaultContext(mapmessageId) ;
            try
            {
                CoordinatorCompletionCoordinatorClient.getClient().sendSoapFault(soapFaultnullfaultMAPgetFaultAction());
            }
            catch (final Throwable th)
            {
            }
        }
    }
    private static String getFaultAction()
    {
    }

    
Status.

Parameters:
status The status.
map The addressing context.
arjunaContext The arjuna context.
    public void status(final StatusType statusfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;
        if (participant != null)
        {
            try
            {
                participant.status(statusmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from status:"th) ;
                }
            }
        }
        else if (..isTraceEnabled())
        {
            ..tracev("Status called on unknown participant: {0}"new Object[] {instanceIdentifier}) ;
        }
    }

    
SOAP Fault.

Parameters:
fault The SOAP fault notification.
map The addressing context.
arjunaContext The arjuna context.
    public void soapFault(final SoapFault faultfinal MAP map,
        final ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final CoordinatorCompletionParticipantInboundEvents participant = getParticipant(instanceIdentifier) ;
        if (participant != null)
        {
            try
            {
                participant.soapFault(faultmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from soapFault:"th) ;
                }
            }
        }
        else if (..isTraceEnabled())
        {
            ..tracev("SoapFault called on unknown participant: {0}"new Object[] {instanceIdentifier}) ;
        }
    }

    
Send a cancelled message.

Parameters:
map The addressing context.
arjunaContext The arjuna context.
    private void sendCancelled(final MAP mapfinal ArjunaContext arjunaContext)
    {
        // KEV add check for recovery
        final String messageId = MessageId.getMessageId() ;
        final MAP responseMAP = AddressingHelper.createOneWayResponseContext(mapmessageId) ;
        try
        {
            // supply null endpoint to indicate addressing properties should be used to route message
            CoordinatorCompletionCoordinatorClient.getClient().sendCancelled(nullresponseMAParjunaContext.getInstanceIdentifier()) ;
        }
        catch (final Throwable th)
        {
            if (..isTraceEnabled())
            {
                ..tracev("Unexpected exception while sending Cancelled"th) ;
            }
        }
    }

    
Send a closed message.

Parameters:
map The addressing context.
arjunaContext The arjuna context.
    private void sendClosed(final MAP mapfinal ArjunaContext arjunaContext)
    {
        // KEV add check for recovery
        final String messageId = MessageId.getMessageId() ;
        final MAP responseMAP = AddressingHelper.createOneWayResponseContext(mapmessageId) ;
        try
        {
            // supply null endpoint to indicate addressing properties should be used to route message
            CoordinatorCompletionCoordinatorClient.getClient().sendClosed(nullresponseMAParjunaContext.getInstanceIdentifier()) ;
        }
        catch (final Throwable th)
        {
            if (..isTraceEnabled())
            {
                ..tracev("Unexpected exception while sending Closed"th) ;
            }
        }
    }

    
Send a compensated message.

Parameters:
map The addressing context.
arjunaContext The arjuna context.
    private void sendCompensated(final MAP mapfinal ArjunaContext arjunaContext)
    {
        // KEV add check for recovery
        final String messageId = MessageId.getMessageId() ;
        final MAP responseMAP = AddressingHelper.createOneWayResponseContext(mapmessageId) ;
        try
        {
            // supply null endpoint to indicate addressing properties should be used to route message
            CoordinatorCompletionCoordinatorClient.getClient().sendCompensated(nullresponseMAParjunaContext.getInstanceIdentifier()) ;
        }
        catch (final Throwable th)
        {
            if (..isTraceEnabled())
            {
                ..tracev("Unexpected exception while sending Compensated"th) ;
            }
        }
    }

    
Send a fail message.

Parameters:
map The addressing context.
arjunaContext The arjuna context.
exceptionIdentifier The exception identifier.
    private void sendFail(final MAP mapfinal ArjunaContext arjunaContextfinal QName exceptionIdentifier)
    {
        // KEV add check for recovery
        final String messageId = MessageId.getMessageId() ;
        final MAP responseMAP = AddressingHelper.createFaultContext(mapmessageId) ;
        try
        {
            // supply null endpoint to indicate addressing properties should be used to route message
            CoordinatorCompletionCoordinatorClient.getClient().sendFail(nullresponseMAParjunaContext.getInstanceIdentifier(), exceptionIdentifier) ;
        }
        catch (final Throwable th)
        {
            if (..isTraceEnabled())
            {
                ..tracev("Unexpected exception while sending Fail"th) ;
            }
        }
    }
New to GrepCode? Check out our FAQ X