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.5 2005/05/19 12:13:37 nmcl Exp $
  */
 
 package com.arjuna.mwlabs.wscf.model.sagas.arjunacore;
 
 
 
 
 
 
 
 
 
 
 
 
The ArjunaCore coordination service implementation.

Author(s):
Mark Little (mark.little@arjuna.com)
Version:
$Id: CoordinatorControl.java,v 1.5 2005/05/19 12:13:37 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
 	{
 	    BACoordinator coord = new BACoordinator();
 	    int status = coord.start(parentCoordinator());
 	
 	    if (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:
cs The completion status to use.
Returns:
The result of terminating the relationship of this HLS and the current activity.
    public Outcome complete (CompletionStatus csthrows SystemException
    {
	int outcome;
	if ((cs != null) && (cs instanceof Success))
	{
	    // commit
        outcome = current.close();
	}
	else
	{
	    // abort
        outcome = current.cancel();
	}
	int result;
	switch (outcome)
	{
	    result = .;
	    break;
	    result = .;
	    break;
	    result = .;
	    break;
	    break;
	    result = .;
	    break;
	    result = .;
	    break;
	default:
	    result = .;
	    break;
	}
	return new CoordinationOutcome(csresult);
    }	

    
The current activity is completing and informs the participants that all work they need to know about has been received.
    public void complete () throws WrongStateExceptionSystemException
    {
    }	

    
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:
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
    public com.arjuna.mw.wsas.status.Status status () throws SystemException
    {
	int currentStatus = currentCoordinator().status();
	switch (currentStatus)
	{
	    return Active.instance();
	    return Closing.instance();
	    return Closed.instance();
	    return Cancelling.instance();
	    return Cancelled.instance();
	    return CancelOnly.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:
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.
    {
    }

    
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.
    
    {
    }
    {
    }
    {
    }
    {
    }

    
Create a subordinate transaction, i.e., one which can be driven through complete, close and cancel. 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 BACoordinator createSubordinate () throws SystemException
    {
        try
        {
            SubordinateBACoordinator coord = new SubordinateBACoordinator();
            int status = coord.start(null);
            if (status != .)
            {
                throw new BegunFailedException(
                        ..get_model_sagas_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)
	    throw new NoCoordinatorException();
	else
	    return coord;
    }
    private final ActivityHandleImple currentActivity () throws SystemException
    {
	try
	{
	    ActivityHierarchy hier = UserActivityFactory.userActivity().currentActivity();
	    if (hier.size() > 0)
		return (ActivityHandleImplehier.activity(hier.size() -1);
	    else
		return null;
	}
	catch (Exception ex)
	{
	    ex.printStackTrace();
	    throw new SystemException(ex.toString());
	}
    }
    private final BACoordinator parentCoordinator () throws SystemException
    {
	try
	{
	    ActivityHierarchy hier = UserActivityFactory.userActivity().currentActivity();
	    ActivityHandleImple parentActivity = null;
	    BACoordinator parentCoordinator = null;
	    if (hier.size() > 1)
	    {
		parentActivity = (ActivityHandleImplehier.activity(hier.size() -2);
		parentCoordinator = (BACoordinator.get(parentActivity);
	    }
	    return parentCoordinator;
	}
	catch (Exception ex)
	{
	    ex.printStackTrace();
	    
	    return null;
	}
    }
    private static Hashtable _coordinators = new Hashtable();
New to GrepCode? Check out our FAQ X