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 Participant Completion Coordinator processor.

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

    
Activate the coordinator.

Parameters:
coordinator The coordinator.
identifier The identifier.
 
     public void activateCoordinator(final ParticipantCompletionCoordinatorInboundEvents coordinatorfinal String identifier)
     {
         .activateObject(coordinatoridentifier) ;
     }

    
Deactivate the coordinator.

Parameters:
coordinator The coordinator.
 
     public void deactivateCoordinator(final ParticipantCompletionCoordinatorInboundEvents coordinator)
     {
         .deactivateObject(coordinator) ;
     }

    
Locate a coordinator by name.

Parameters:
identifier The name of the coordinator.
 
     {
     }

    
Get the coordinator with the specified identifier.

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

    
Cancelled.

Parameters:
cancelled The cancelled notification.
map The addressing context.
arjunaContext The arjuna context.
 
     public void cancelled(final NotificationType cancelledfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final ParticipantCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier) ;
        if (coordinator != null)
        {
            try
            {
                coordinator.cancelled(cancelledmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from cancelled:"th) ;
                }
            }
        }
        else if (..isTraceEnabled())
        {
            ..tracev("Cancelled called on unknown coordinator: {0}"new Object[] {instanceIdentifier}) ;
        }
    }

    
Closed.

Parameters:
closed The closed notification.
map The addressing context.
arjunaContext The arjuna context.
    public void closed(final NotificationType closedfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final ParticipantCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier) ;
        if (coordinator != null)
        {
            try
            {
                coordinator.closed(closedmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from closed:"th) ;
                }
            }
        }
        else if (..isTraceEnabled())
        {
            ..tracev("Closed called on unknown coordinator: {0}"new Object[] {instanceIdentifier}) ;
        }
    }

    
Compensated.

Parameters:
compensated The compensated notification.
map The addressing context.
arjunaContext The arjuna context.
    public void compensated(final NotificationType compensatedfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final ParticipantCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier) ;
        if (coordinator != null)
        {
            try
            {
                coordinator.compensated(compensatedmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from compensated:"th) ;
                }
            }
        }
        else if (..isTraceEnabled())
        {
            ..tracev("Compensated called on unknown coordinator: {0}"new Object[] {instanceIdentifier}) ;
        }
    }

    
Completed.

Parameters:
completed The completed notification.
map The addressing context.
arjunaContext The arjuna context.
    public void completed(final NotificationType completedfinal MAP map,
        final ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final ParticipantCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier) ;
        if (coordinator != null)
        {
            try
            {
                coordinator.completed(completedmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from completed:"th) ;
                }
            }
        }
        else if (..isTraceEnabled())
        {
            if (areRecoveryLogEntriesAccountedFor()) {
                // this is a resend for a lost participant
                ..tracev("Completed called on unknown coordinator: {0}"new Object[] {instanceIdentifier}) ;
            } else {
                // this may be a resend for a participant still pending recovery
                ..tracev("Ignoring completed called on unidentified coordinator until recovery pass is complete: {0}"new Object[] {instanceIdentifier}) ;
            }
        }
    }

    
Completed.

Parameters:
cannotComplete The cannot complete notification.
map The addressing context.
arjunaContext The arjuna context.
    public void cannotComplete(final NotificationType cannotCompletefinal MAP map,
        final ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final ParticipantCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier) ;
        if (coordinator != null)
        {
            try
            {
                coordinator.cannotComplete(cannotCompletemaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from completed:"th) ;
                }
            }
        } else {
            if (..isTraceEnabled())
            {
                ..tracev("Completed called on unknown coordinator: {0}"new Object[] {instanceIdentifier}) ;
            }
            sendNotCompleted(maparjunaContext) ;
        }
    }

    
Exit.

Parameters:
exit The exit notification.
map The addressing context.
arjunaContext The arjuna context.
    public void exit(final NotificationType exitfinal MAP mapfinal ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final ParticipantCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier) ;
        if (coordinator != null)
        {
            try
            {
                coordinator.exit(exitmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from exit:"th) ;
                }
            }
        } else {
            if (..isTraceEnabled())
            {
                ..tracev("Exit called on unknown coordinator: {0}"new Object[] {instanceIdentifier}) ;
            }
            sendExited(maparjunaContext) ;
        }
    }

    
Fail.

Parameters:
fail The fail notification.
map The addressing context.
arjunaContext The arjuna context.
    public void fail(final ExceptionType failfinal MAP map,
        final ArjunaContext arjunaContext)
    {
        final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier() ;
        final ParticipantCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier) ;
        if (coordinator != null)
        {
            try
            {
                coordinator.fail(failmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from fail:"th) ;
                }
            }
        } else if (areRecoveryLogEntriesAccountedFor()) {
            // we can respond with a failed as the participant is not pending recovery
            if (..isTraceEnabled())
            {
                ..tracev("Fail called on unknown coordinator: {0}"new Object[] {instanceIdentifier}) ;
            }
            sendFailed(maparjunaContext) ;
        } else {
            // we must delay responding until we can be sure there is no participant pending recovery
            if (..isTraceEnabled())
            {
                ..tracev("Ignoring fail called on unidentified coordinator until recovery pass is complete: {0}"new Object[] {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 ParticipantCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier) ;
        if (coordinator != null)
        {
            try
            {
                coordinator.getStatus(getStatusmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from getStatus:"th) ;
                }
            }
        }
        else if (!areRecoveryLogEntriesAccountedFor())
        {
            // drop the request until we have ensured that there is no recovered coordinator for this id
            if (..isTraceEnabled())
            {
                ..tracev("GetStatus dropped for unknown coordinator completion participant {0} while waiting on recovery scan"new Object[] {instanceIdentifier}) ;
            }
        }
        else
        {
            if (..isTraceEnabled())
            {
                ..tracev("GetStatus called on unknown coordinator: {0}"new Object[] {instanceIdentifier}) ;
            }
            
            // send an invalid state fault
            final String messageId = MessageId.getMessageId();
            final MAP faultMAP = AddressingHelper.createFaultContext(mapmessageId) ;
            try
            {
                AddressingHelper.installNoneReplyTo(faultMAP);
                ParticipantCompletionParticipantClient.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 ParticipantCompletionCoordinatorInboundEvents coordinator = getCoordinator(instanceIdentifier) ;
        if (coordinator != null)
        {
            try
            {
                coordinator.status(statusmaparjunaContext) ;
            }
            catch (final Throwable th)
            {
                if (..isTraceEnabled())
                {
                    ..tracev("Unexpected exception thrown from status:"th) ;
                }
            }
        }
        else if (..isTraceEnabled())
        {
            ..tracev("Status called on unknown coordinator: {0}"new Object[] {instanceIdentifier}) ;
        }
    }

    
SOAP fault.

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

    
Send an exited message.

Parameters:
map The addressing context.
arjunaContext The arjuna context.
    private void sendExited(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 so that addressing properties are used to deliver message
            ParticipantCompletionParticipantClient.getClient().sendExited(nullresponseMAParjunaContext.getInstanceIdentifier()) ;
        }
        catch (final Throwable th)
        {
            if (..isTraceEnabled())
            {
                ..tracev("Unexpected exception while sending Exited"th) ;
            }
        }
    }

    
Send a failed message.

Parameters:
map The addressing context.
arjunaContext The arjuna context.
    private void sendFailed(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 so that addressing properties are used to deliver message
            ParticipantCompletionParticipantClient.getClient().sendFailed(nullresponseMAParjunaContext.getInstanceIdentifier()) ;
        }
        catch (final Throwable th)
        {
            if (..isTraceEnabled())
            {
                ..tracev("Unexpected exception while sending Failed"th) ;
            }
        }
    }

    
Send a not completed message.

Parameters:
map The addressing context.
arjunaContext The arjuna context.
    private void sendNotCompleted(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 so that addressing properties are used to deliver message
            ParticipantCompletionParticipantClient.getClient().sendNotCompleted(nullresponseMAParjunaContext.getInstanceIdentifier()); ;
        }
        catch (final Throwable th)
        {
            if (..isTraceEnabled())
            {
                ..tracev("Unexpected exception while sending NotCompleted"th) ;
            }
        }
    }

    
Tests if there may be unknown coordinator entries in the recovery log.

Returns:
false if there may be unknown coordinator entries in the recovery log.
    private static boolean areRecoveryLogEntriesAccountedFor()
    {
        return (XTSBARecoveryManager.getRecoveryManager().isCoordinatorRecoveryStarted() &&
                XTSBARecoveryManager.getRecoveryManager().isSubordinateCoordinatorRecoveryStarted());
    }
New to GrepCode? Check out our FAQ X