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.
  */
 /*
  * Copyright (C) 2002,
  *
  * Arjuna Technologies Limited,
  * Newcastle upon Tyne,
  * Tyne and Wear,
  * UK.
  *
  * $Id: CoordinatorControl.java,v 1.9 2005/06/09 09:41:27 nmcl Exp $
  */
 
 package com.arjuna.mwlabs.wscf.model.twophase.arjunacore;
 
 
 
 
 
 
 
 
 
 
 
 
 
The ArjunaCore coordination service implementation.

Author(s):
Mark Little (mark.little@arjuna.com)
Version:
$Id: CoordinatorControl.java,v 1.9 2005/06/09 09:41:27 nmcl Exp $
Since:
1.0.
 
 
 public class CoordinatorControl
 {
 
 	public CoordinatorControl ()
 	{
 	}

An activity has begun and is active on the current thread.
 
 
 	public void begin () throws SystemException
 	{		
 		try
 		{
 			ATCoordinator coord = new ATCoordinator();
 			int status = coord.start(parentCoordinator());
 
 			if (status != .)
                        ..get_model_twophase_arjunacore_CoordinatorControl_1()
                                + ActionStatus.stringForm(status));
			else
			{
			}
		}
		catch (SystemException ex)
		{
			throw ex;
		}
		catch (Exception ex)
		{
			throw new UnexpectedException(ex.toString());
		}
	}

The current activity is completing with the specified completion status.

Parameters:
CompletionStatus cs The completion status to use.
Returns:
The result of terminating the relationship of this HLS and the current activity.
	{
		int outcome;
		if ((cs != null) && (cs instanceof Success))
		{
			// commit
			outcome = current.end(true);
		}
		else
		{
			// abort
			outcome = current.cancel();
		}
		int result;
		switch (outcome)
		{
			break;
			break;
			break;
			break;
			break;
			break;
		default:
			break;
		}
		return new CoordinationOutcome(csresult);
	}

The activity has been suspended.
	public void suspend () throws SystemException
	{
	}

The activity has been resumed on the current thread.
	public void resume () throws SystemException
	{
	}

The activity has completed and is no longer active on the current thread.
	public void completed () throws SystemException
	{
	}

If the application requires and if the coordination protocol supports it, then this method can be used to execute a coordination protocol on the currently enlisted participants at any time prior to the termination of the coordination scope. This implementation only supports coordination at the end of the activity.

Parameters:
CompletionStatus cs The completion status to use when determining how to execute the protocol.
Returns:
The result of executing the protocol, or null.
Throws:
com.arjuna.mw.wsas.exceptions.WrongStateException Thrown if the coordinator is in a state the does not allow coordination to occur.
com.arjuna.mw.wsas.exceptions.ProtocolViolationException Thrown if the protocol is violated in some manner during execution.
com.arjuna.mw.wsas.exceptions.SystemException Thrown if any other error occurs.
	{
		return null;
	}

Returns:
the status of the current coordinator. If there is no activity associated with the thread then NoActivity will be returned.
Throws:
com.arjuna.mw.wsas.exceptions.SystemException Thrown if any error occurs.
See also:
com.arjuna.mw.wsas.status.Status
	{
		int currentStatus = currentCoordinator().status();
		switch (currentStatus)
		{
			return Active.instance();
			return Preparing.instance();
			return Cancelling.instance();
			return Cancelled.instance();
			return CancelOnly.instance();
			return Prepared.instance();
			return Confirming.instance();
			return Confirmed.instance();
			return HeuristicCancel.instance();
			return HeuristicConfirm.instance();
			return HeuristicMixed.instance();
			return HeuristicHazard.instance();
			return NoActivity.instance();
		default:
			return Unknown.instance();
		}
	}

Not supported by basic ArjunaCore.

Returns:
the complete list of qualifiers that have been registered with the current coordinator.
Throws:
com.arjuna.mw.wsas.exceptions.SystemException Thrown if any error occurs.
	{
	}

Returns:
The unique identity of the current coordinator.
Throws:
com.arjuna.mw.wsas.exceptions.SystemException Thrown if any error occurs.
	{
	}

Enrol the specified participant with the coordinator associated with the current thread.

Parameters:
Participant act The participant.
Throws:
com.arjuna.mw.wsas.exceptions.WrongStateException Thrown if the coordinator is not in a state that allows participants to be enrolled.
com.arjuna.mw.wscf.exceptions.DuplicateParticipantException Thrown if the participant has already been enrolled and the coordination protocol does not support multiple entries.
com.arjuna.mw.wscf.exceptions.InvalidParticipantException Thrown if the participant is invalid.
com.arjuna.mw.wsas.exceptions.SystemException Thrown if any other error occurs.
	public void enlistParticipant (Participant actthrows WrongStateException,
	{
	}

Remove the specified participant from the coordinator's list.

Throws:
com.arjuna.mw.wscf.exceptions.InvalidParticipantException Thrown if the participant is not known of by the coordinator.
com.arjuna.mw.wsas.exceptions.WrongStateException Thrown if the state of the coordinator does not allow the participant to be removed (e.g., in a two-phase protocol the coordinator is committing.)
com.arjuna.mw.wsas.exceptions.SystemException Thrown if any other error occurs.
	public void delistParticipant (Participant act)
	{
	}

Enrol the specified synchronization with the coordinator associated with the current thread.

Parameters:
Synchronization act The synchronization to remove.
Throws:
com.arjuna.mw.wsas.exceptions.WrongStateException Thrown if the coordinator is not in a state that allows participants to be enrolled.
com.arjuna.mw.wscf.model.twophase.exceptions.DuplicateSynchronizationException Thrown if the participant has already been enrolled and the coordination protocol does not support multiple entries.
com.arjuna.mw.wscf.model.twophase.exceptions.InvalidSynchronizationException Thrown if the participant is invalid.
com.arjuna.mw.wsas.exceptions.SystemException Thrown if any other error occurs.
	{
	}

Remove the specified synchronization from the coordinator's list.

Throws:
com.arjuna.mw.wscf.model.twophase.exceptions.InvalidSynchronizationException Thrown if the participant is not known of by the coordinator.
com.arjuna.mw.wsas.exceptions.WrongStateException Thrown if the state of the coordinator does not allow the participant to be removed (e.g., in a two-phase protocol the coordinator is committing.)
com.arjuna.mw.wsas.exceptions.SystemException Thrown if any other error occurs.
	{
	}
	public void participantRolledBack (String participantId)
	{
	}
	public void participantReadOnly (String participantId)
	{
	}

Create a subordinate transaction, i.e., one which can be driven through prepare, commit and rollback. Such a transaction is not interposed with any parent transaction because the parent may be physically remote from the child. Such interposition is the responsibility of the invoker.

Returns:
the subordinate transaction. The transaction is not associated with the thread and is not interposed. It is running.
Throws:
com.arjuna.mw.wsas.exceptions.SystemException throw if any error occurs.
	public final ATCoordinator createSubordinate (String subordinateTypethrows SystemException
	{	
		try
		{
			SubordinateATCoordinator coord = new SubordinateATCoordinator(subordinateType);
			int status = coord.start(null);
			if (status != .)
			{
                        ..get_model_twophase_arjunacore_CoordinatorControl_1()
                                + ActionStatus.stringForm(status));
			}
			else
			{
				/*
				 * TODO does this need to be added to the list?
				 */
				// _coordinators.put(currentActivity(), coord);
				return coord;
			}
		}
		catch (SystemException ex)
		{
			throw ex;
		}
		catch (Exception ex)
		{
			throw new UnexpectedException(ex.toString());
		}
	}
	{
		if (coord == null)
		else
			return coord;
	}
	{
		try
		{
			ActivityHierarchy hier = UserActivityFactory.userActivity().currentActivity();
			if (hier.size() > 0)
				return (ActivityHandleImplehier.activity(hier.size() - 1);
			else
				return null;
		}
		catch (Exception ex)
		{
			throw new SystemException(ex.toString());
		}
	}
	private final ATCoordinator parentCoordinator () throws SystemException
	{
		try
		{
			ActivityHierarchy hier = UserActivityFactory.userActivity().currentActivity();
			ActivityHandleImple parentActivity = null;
			ATCoordinator parentCoordinator = null;
			if (hier.size() > 1)
			{
				parentActivity = (ActivityHandleImplehier.activity(hier.size() - 2);
				parentCoordinator = (ATCoordinator.get(parentActivity);
			}
			return parentCoordinator;
		}
		catch (Exception ex)
		{
			return null;
		}
	}
	private static Hashtable _coordinators = new Hashtable();
New to GrepCode? Check out our FAQ X