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: ParticipantRecord.java,v 1.6 2005/05/19 12:13:37 nmcl Exp $
  */
 
 package com.arjuna.mwlabs.wscf.model.sagas.arjunacore;
 
 
 
 
 
 
Arjuna abstract record to handle two-phase participants.

Author(s):
Mark Little (mark.little@arjuna.com)
Version:
$Id: ParticipantRecord.java,v 1.6 2005/05/19 12:13:37 nmcl Exp $
 
 
 public class ParticipantRecord extends
 {

Constructor.

Parameters:
theResource is the proxy that allows us to call out to the object.
 
 
 	public ParticipantRecord (Participant theResourceUid id)
 	{
 		super(idnull.);
 
 		 = theResource;
 		 = 0;
 
         if (theResource == null)
 	}

Override AbstractRecord.propagateOnCommit
 
 
 	public boolean propagateOnCommit ()
 	{
 		return true;
 	}

The type of this abstract record.
 
 
 	public int typeIs ()
 	{
 		// TODO add to record list
	}

The internal value.
	public Object value ()
	{
	}

Set the internal value. Not allowed for this class.
	public void setValue (Object o)
	{
	}

The record is being driven through nested rollback.
	// TODO
	public int nestedAbort ()
	{
		try
		{
			if ( != null)
			{
			}
			else
		}
		catch (Exception ex6) {
            ex6.printStackTrace();
            return .;
        }
	}

The record is being driven through nested commit.
	public int nestedCommit ()
	{
		try
		{
			if ( != null)
			{
			}
			else
		}
		catch (Exception ex6) {
            ex6.printStackTrace();
            return .;
        }
	}

The record is being driven through nested prepare.
	public int nestedPrepare ()
	{
		try
		{
			if ( != null)
			{
			}
			else
		}
		catch (Exception e6) {
            e6.printStackTrace();
            return .;
        }
	}

The record is being driven through top-level rollback.
	public int topLevelAbort ()
	{
		try
		{
			if ( != null)
			{
				try
				{
					if (!)
					{
						else
					}
				}
				{
				}
                catch (WrongStateException ex)
                {
                    // this indicates a fail occured and was detected during cancel (or compensation?) so we return a
                    // HEURISTIC_HAZARD which will place the participant in the heuristic list
                    return .;
                }
                catch (CancelFailedException ex)
                {
                    // this indicates a fail occured and was detected during cancel so we return a HEURISTIC_HAZARD
                    // which will place the participant in the heuristic list
                    return .;
                }
                catch (CompensateFailedException ex)
                {
                    // this indicates a fail occured during compensation so we return a HEURISTIC_HAZARD
                    // which will place the participant in the heuristic list
                    return .;
                }
				catch (SystemException ex)
				{
                    // this indicates a comms failure so we return FINISH_ERROR which will place
                    // the participant in the failed list and cause a retry of the close
                    return .;
				}
                // we are not guaranteed to detect all state transitions so we still have to
                // make sure we did not fail and then end while we were trying to cancel or
                // compensate
                if () {
                    return .;
                }
			}
			else
		}
		catch (Exception ex6) {
            ex6.printStackTrace();
            return .;
        }
	}

The record is being driven through top-level commit.
	public int topLevelCommit ()
	{
		try
		{
			if ( != null)
			{
				try
				{
				}
				{
				}
				{
                    // this indicates a failure to close so we notify a heuristic hazard
				}
                catch (SystemException ex)
				{
                    // this indicates a comms failure so we return FINISH_ERROR which will place
                    // the participant in the failed list and cause a retry of the close
                    return .;
				}
                // if we have failed we notify a heuristic hazard to ensure that the
                // participant is placed in the heuristic list and the transaction is logged
                if () {
                    return .;
                }
                return .;
			}
			else
		}
		catch (Exception ex6) {
            ex6.printStackTrace();
            return .;
        }
	}

The record is being driven through top-level prepare.
	public int topLevelPrepare ()
	{
		try
		{
            boolean result;
            if () {
                // if we have failed we return heuristic hazard so the participant is added to
                // the heuristic list and the transaction is logged
                return .;
            } else if () {
                // otherwise if we have exited then this means the resource is read only
                return .;
            } else {
                // otherwise we only need to have completed for the prepare to be ok -- if we have
                // not completed then the prepare is not ok
                return ( ? ..);
            }
        }
		catch (Exception e6) {
            e6.printStackTrace();
            return .;
        }
	}

The record is being driven through nested commit and is the only resource.
	public int nestedOnePhaseCommit ()
	{
		try
		{
			if ( != null)
			{
			}
			else
		}
		catch (Exception ex6) {
            ex6.printStackTrace();
            return .;
        }
	}

The record is being driven through top-level commit and is the only resource.
	public int topLevelOnePhaseCommit ()
	{
		try
		{
			if ( != null)
			{
                // we cannot proceed if the participant has neither completed not exited
                if (isActive()) return .;
				try
				{
                    if (!.close();
				}
				{
				}
				{
                    // this indicates a failure to close so we notify a heuristic hazard
				}
				catch (SystemException ex)
				{
                    // this indicates a comms failure so we return FINISH_ERROR which will place
                    // the participant in the failed list and cause a retry of the close
                    return .;
				}
                // if we have failed we notify a heuristic hazard to ensure that the
                // participant is placed in the heuristic list and the transaction is logged
                if () {
                    return .;
                }
                // if we closed or we exited then all is ok
                return .;
			}
			else
		}
		catch (Exception ex6) {
            ex6.printStackTrace();
            return .;
        }
	}

The record generated a heuristic and can now forget about it.
	public boolean forgetHeuristic ()
	{
		try
		{
			if ( != null)
			{
				try
				{
				}
				{
					return false;
				}
				{
					return false;
				}
				catch (SystemException ex)
				{
					return false;
				}
				return true;
			}
			else {
            }
		}
		catch (Exception e) {
            e.printStackTrace();
        }
		return false;
	}
	public boolean complete ()
	{
		boolean result = false;
		try
		{
			if ( != null)
			{
				try
				{
					if (isActive())
					{
						{
						}
						result = true;
					}
					else
					{
						// already completed, so this is a null op. just rtn
						// true.
						result = true;
					}
				}
				{
				}
				{
				}
				catch (SystemException ex)
				{
				}
			}
		}
		catch (Exception ex6) {
            ex6.printStackTrace();
        }
		return result;
	}
	public static AbstractRecord create ()
	{
		return new ParticipantRecord();
	}
	public void remove (AbstractRecord toDelete)
	{
		toDelete = null;
	}
	public void print (PrintWriter strm)
	{
		super.print(strm);
		strm.print("ParticipantRecord");
	}
	public boolean restore_state (InputObjectState osint t)
	{
		boolean result = super.restore_state(ost);
		if (result)
		{
			try
			{
                String resourcehandleImplClassName = os.unpackString();
                Class clazz = ClassLoaderHelper.forName(ParticipantRecord.classresourcehandleImplClassName);
                 = (Participant)clazz.newInstance();
                result = .restore_state(os);
				if (result) {
                     = os.unpackBoolean();
                     = os.unpackBoolean();
                    if () {
                         = os.unpackBoolean();
                    }
                }
			}
			catch (Exception ex) {
                result = false;
            }
		}
		return result;
	}
	public boolean save_state (OutputObjectState osint t)
	{
		boolean result = super.save_state(ost);
		if (result)
		{
			try
			{
                os.packString(.getClass().getName()); // TODO: a shorter value whould be more efficient.
                if (result) {
                    os.packBoolean();
                    os.packBoolean();
                    if () {
                        os.packBoolean();
                    }
                }
                /*
				 * TODO: pack qualifiers and coord id.
				 */
			}
			catch (Exception ex) {
                result = false;
            }
		}
		return result;
	}
    public String type ()
	{
		return "/StateManager/AbstractRecord/WSCF/ArjunaCore/ParticipantRecord";
	}
	public boolean doSave ()
	{
		/*
		 * If the participant has exited without failure, then we don't need to save anything
		 * about it in the transaction log. If it has not exited or it has exited with failure
		 * we do need to log it
		 */
		return (! || );
	}
	public void merge (AbstractRecord a)
	{
	}
	public void alter (AbstractRecord a)
	{
	}
	public boolean shouldAdd (AbstractRecord a)
	{
		return false;
	}
	public boolean shouldAlter (AbstractRecord a)
	{
		return false;
	}
	public boolean shouldMerge (AbstractRecord a)
	{
		return false;
	}
	public boolean shouldReplace (AbstractRecord rec)
	{
		return false;
	}

    
record the fact that this participant has exited

Parameters:
failed true if the exit was because of a failure i.e. the participant may be in an unclean state
    public final void delist (boolean failed)
	{
		 = true;
         = failed;
    }

    
record the fact that this participant has completed
    public final synchronized void completed ()
    {
         = true;
    }

    
is the participant is still able to be sent a complete request

Returns:
true if the participant is still able to be sent a complete request otherwise false
Caveat:
it is only appropriate to call this if this is a CoordinatorCompletion participant
    public final synchronized boolean isActive ()
    {
        return ! && !;
    }

    
is this a ParticipantCompletion participant

Returns:
true if this is a ParticipantCompletion participant otherwise false
    public final boolean isParticipantCompletion ()
    {
        // n.b. this is ok if _resourceHandle is null
        return !( instanceof ParticipantWithComplete);
    }
	/*
	 * Protected constructor used by crash recovery.
	 */
	{
		super();
		 = 0;
		 = null;
	}
	private long _timeout;
    private boolean _exited = false;
    private boolean _failed = false;
	private boolean _completed = false;
New to GrepCode? Check out our FAQ X