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) 2004,
  *
  * Arjuna Technologies Limited,
  * Newcastle upon Tyne,
  * Tyne and Wear,
  * UK.
  *
  * $Id: LastResourceRecord.java 2342 2006-03-30 13:06:17Z  $
  */
 
 package com.arjuna.ats.internal.arjuna.abstractrecords;
 
 
AbstractRecord that helps us do the last resource commit optimization. Basically this is something that is used to allow a *single* resource that is only one-phase aware to be enlisted with a transaction that is usually two-phase. The way it works is: (i) the coordinator runs its normal first (prepare) phase on all two-phase aware participants and makes a decision based solely on their responses as to whether to commit or roll back. Note, the one-phase aware resource essentially returns voteCommit during prepare, to ensure that the second phase runs even if all other resources return voteReadOnly. (ii) if the transaction is to commit then the coordinator invokes the second phase on *all* participants, starting with the one that is only one-phase aware. If it rolls back, it rolls all resources back, but the order is not important.

Author(s):
Mark Little (mark@arjuna.com)
Version:
$Id: LastResourceRecord.java 2342 2006-03-30 13:06:17Z $
Since:
ATS 3.2.
 
 
 public class LastResourceRecord extends AbstractRecord
 {
 
     public LastResourceRecord(OnePhaseResource opr)
     {
         super();
 
         if (..isTraceEnabled()) {
             ..trace("LastResourceRecord()");
         }
 
          = opr;
     }
 
     public boolean propagateOnCommit ()
     {
         return false;
     }
 
     public int typeIs ()
     {
         return .;
     }
 
     public int nestedAbort ()
     {
         if (..isTraceEnabled()) {
             ..trace("LastResourceRecord::nestedAbort() for " + order());
         }
 
         return .;
     }
 
     public int nestedCommit ()
     {
         if (..isTraceEnabled()) {
             ..trace("LastResourceRecord::nestedCommit() for " + order());
        }
        return .;
    }

    
Not allowed to participate in nested transactions.
    public int nestedPrepare ()
    {
        if (..isTraceEnabled()) {
            ..trace("LastResourceRecord::nestedPrepare() for " + order());
        }
        return .;
    }
    public int topLevelAbort ()
    {
        if (..isTraceEnabled()) {
            ..trace("LastResourceRecord::topLevelAbort() for " + order());
        }
        if ( != null)
        {
            return .rollback();
        }
        else
        {
            return .;
        }
    }
    public int topLevelCommit ()
    {
        if (..isTraceEnabled()) {
            ..trace("LastResourceRecord::topLevelCommit() for " + order());
        }
        return .;
    }
    public int topLevelPrepare ()
    {
        if (..isTraceEnabled()) {
            ..trace("LastResourceRecord::topLevelPrepare() for " + order());
        }
        if ( == null)
            return .;
        switch (.commit())
        {
        case .:
            return .;
        case .:
            return .;
        default:
            return .;
        }
    }
    @Override
    public String toString()
    {
        return "LastResourceRecord("++")";
    }
    public void print (PrintWriter strm)
    {
        strm.println("LastResource for:");
        super.print(strm);
    }
    public String type ()
    {
        return "/StateManager/AbstractRecord/LastResourceRecord";
    }
    public boolean shouldAdd (AbstractRecord a)
    {
        if (a.typeIs() == typeIs())
        {
            if () {
                if (!
                        || ( && !)) {
                    ..warn_lastResource_multipleWarning(a.toString());
                     = true;
                }
                return true;
            }
            else {
                ..warn_lastResource_disallow(this.toString(), a.toString());
                return false;
            }
        }
        else
        {
            return false;
        }
    }
    public boolean shouldMerge (AbstractRecord a)
    {
        return false;
    }
    public boolean shouldReplace (AbstractRecord a)
    {
        return false;
    }
    public boolean shouldAlter (AbstractRecord a)
    {
        return false;
    }
    public void merge (AbstractRecord a)
    {
    }
    public void alter (AbstractRecord a)
    {
    }

    

Returns:
Object to be used to order.
    public Object value ()
    {
        return ;
    }
    public void setValue (Object o)
    {
    }
    public LastResourceRecord()
    {
        super();
         = null;
    }
    private OnePhaseResource _lro;
    private static final Uid ONE_PHASE_RESOURCE_UID = Uid.lastResourceUid();
    private static final boolean ALLOW_MULTIPLE_LAST_RESOURCES;
    private static boolean _disableMLRWarning = false;
    private static boolean _issuedWarning = false;
    static
    {
         = arjPropertyManager
                .getCoreEnvironmentBean().isAllowMultipleLastResources();
        if () {
        }
         = arjPropertyManager.getCoreEnvironmentBean()
                .isDisableMultipleLastResourcesWarning();
        if (arjPropertyManager.getCoreEnvironmentBean()
                .isDisableMultipleLastResourcesWarning()) {
             = true;
        }
    }
New to GrepCode? Check out our FAQ X