com.arjuna.ats.txoj.Lock类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中com.arjuna.ats.txoj.Lock类的一些代码示例,展示了Lock类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lock类的具体详情如下:
包路径:com.arjuna.ats.txoj.Lock
类名称:Lock

Lock介绍

[英]Instances of this class (or derived user classes) are used when trying to set a lock. The default implementation provides a single-write/multiple-reader policy. However, by overridding the appropriate methods, other, type-specific concurrency control locks can be implemented.
[中]尝试设置锁定时使用此类(或派生用户类)的实例。默认实现提供单写/多读策略。但是,通过重写适当的方法,可以实现其他特定于类型的并发控制锁。

代码示例

代码示例来源:origin: stackoverflow.com

interface MajorObjectWrapper{
 public Object getMajorObject();
}

enum Utility implements MajorObjectWrapper {
 VAULT("Gold"),
 //...
 LOCK(new Lock());

 @Override public Object getMajorObject(){ return obj; }

 private Object obj;

 Utility(Object obj){ this.obj=obj };

}

{
 MajorObjectWrapper wrapper=Utility.VAULT;
 System.out.println(wrapper.getMajorObject());
 // You will get: "Gold"! :)
}

代码示例来源:origin: org.jboss.jbossts.arjunacore/txoj

protected final int lockConflict (Lock otherLock)
{
  if (txojLogger.logger.isTraceEnabled()) {
    txojLogger.logger.trace("LockManager::lockConflict(" + otherLock.get_uid() + ")");
  }
  boolean matching = false;
  Lock heldLock = null;
  LockListIterator next = new LockListIterator(locksHeld);
  while ((heldLock = next.iterate()) != null)
  {
    if (heldLock.conflictsWith(otherLock))
    {
      if (LockManager.nestedLocking)
      {
        if (!isAncestorOf(heldLock)) /* not quite Moss's rules */
          return ConflictType.CONFLICT;
      }
      else
        return ConflictType.CONFLICT;
    }
    else
    {
      if (heldLock.equals(otherLock))
        matching = true;
    }
  }
  return (matching ? ConflictType.PRESENT : ConflictType.COMPATIBLE);
}

代码示例来源:origin: org.jboss.narayana.jts/narayana-jts-idlj

/**
 * Implementation of Lock conflict check. Returns TRUE if there is conflict
 * FALSE otherwise. Does not take account of relationship in the atomic
 * action hierarchy since this is a function of LockManager.
 * 
 * @return <code>true</code> if this lock conflicts with the parameter,
 *         <code>false</code> otherwise.
 */
public boolean conflictsWith (Lock otherLock)
{
  if (txojLogger.logger.isTraceEnabled()) {
    txojLogger.logger.trace("Lock::conflictsWith(" + otherLock + ")\n" + "\tLock 1:\n"
        + this + "\n" + "\tLock 2:\n" + otherLock);
  }
  if (!(getCurrentOwner().equals(otherLock.getCurrentOwner())))
  {
    switch (lMode)
    {
    case LockMode.WRITE:
      return true; /* WRITE conflicts always */
    case LockMode.READ:
      if (otherLock.getLockMode() != LockMode.READ)
        return true;
      break;
    }
  }
  return false; /* no conflict between these locks */
}

代码示例来源:origin: org.jboss.narayana.jts/narayana-jts-idlj

/**
 * Overrides Object.toString()
 */
public String toString ()
{
  StringWriter strm = new StringWriter();
  strm.write("Lock object : \n");
  strm.write("\ttype : "+type()+ "\n");
  strm.write("\tunique id is : " + get_uid() + "\n");
  strm.write("\tcurrent_status : "
      + LockStatus.printString(currentStatus));
  strm.write("\n\tMode : " + LockMode.stringForm(lMode));
  strm.write("\n\tOwner List : \n");
  owners.print(new PrintWriter(strm));
  return strm.toString();
}

代码示例来源:origin: jbosstm/narayana

current = new Lock(u);
  if (current.restore_state(S,
      ObjectType.ANDPERSISTENT))

代码示例来源:origin: jbosstm/narayana

toSet.changeHierarchy(ah);
else
        modifyRequired = toSet.modifiesObject();

代码示例来源:origin: org.jboss.narayana.jts/narayana-jts-idlj

/**
 * Overrides Object.equals()
 */
public boolean equals (Object otherLock)
{
  if (otherLock instanceof Lock)
    return equals((Lock) otherLock);
  else
    return false;
}

代码示例来源:origin: org.jboss.jbossts.jta/narayana-jta

UidHelper.packInto(current.get_uid(), S);
if (!current.save_state(S, ObjectType.ANDPERSISTENT))
  txojLogger.i18NLogger.warn_LockManager_11(current.toString());
  unloadOk = false;

代码示例来源:origin: org.jboss.jbossts/jbossjta

if (current.getCurrentOwner().equals(from))
  current.propagate();

代码示例来源:origin: org.jboss.narayana.jts/narayana-jts-idlj

protected final boolean isAncestorOf (Lock heldLock)
{
  if (txojLogger.logger.isTraceEnabled()) {
    txojLogger.logger.trace("LockManager::isAncestorOf(" + heldLock.getCurrentOwner()
        + ")");
  }
  BasicAction action = BasicAction.Current();
  if (action == null)
    return false; /* no action no ancestry! */
  return action.isAncestor(heldLock.getCurrentOwner());
}

代码示例来源:origin: org.jboss.narayana.arjunacore/arjunacore

/**
 * Print information about this instance on the specified
 * <code>PrintWriter</code>.
 */
public void print (PrintWriter strm)
{
  LockListIterator next = new LockListIterator(locksHeld);
  Lock current;
  strm.println("LocalLockManager for object " + get_uid());
  if (!stateLoaded)
    strm.println("No loaded state");
  else if (locksHeld != null)
  {
    strm.println("\tCurrently holding : " + locksHeld.entryCount()
        + " locks");
    while ((current = next.iterate()) != null)
      current.print(strm);
  }
  else
    strm.println("Currently holding : 0 locks");
}

代码示例来源:origin: org.jboss.jbossts.jta/narayana-jta

/**
 * Overrides Object.toString()
 */
public String toString ()
{
  StringWriter strm = new StringWriter();
  strm.write("Lock object : \n");
  strm.write("\tunique id is : " + get_uid() + "\n");
  strm.write("\tcurrent_status : "
      + LockStatus.printString(currentStatus));
  strm.write("\n\tMode : " + LockMode.stringForm(lMode));
  strm.write("\n\tOwner List : \n");
  owners.print(new PrintWriter(strm));
  return strm.toString();
}

代码示例来源:origin: jbosstm/narayana

if (current.restore_state(S,
    ObjectType.ANDPERSISTENT))

代码示例来源:origin: org.jboss.narayana.jts/narayana-jts-idlj

current = new Lock(u);
  if (current.restore_state(S,
      ObjectType.ANDPERSISTENT))

代码示例来源:origin: org.jboss.narayana.jts/narayana-jts-idlj

toSet.changeHierarchy(ah);
else
    modifyRequired = toSet.modifiesObject();

代码示例来源:origin: org.jboss.jbossts/jbossjta

/**
 * Overrides Object.equals()
 */
public boolean equals (Object otherLock)
{
  if (otherLock instanceof Lock)
    return equals((Lock) otherLock);
  else
    return false;
}

代码示例来源:origin: org.jboss.jbossts.arjunacore/arjunacore

UidHelper.packInto(current.get_uid(), S);
if (!current.save_state(S, ObjectType.ANDPERSISTENT))
  txojLogger.i18NLogger.warn_LockManager_11(current.toString());
  unloadOk = false;

代码示例来源:origin: org.jboss.narayana.jts/narayana-jts-idlj

if (current.getCurrentOwner().equals(from))
  current.propagate();

代码示例来源:origin: jbosstm/narayana

/**
 * Overrides Object.toString()
 */
public String toString ()
{
  StringWriter strm = new StringWriter();
  strm.write("Lock object : \n");
  strm.write("\ttype : "+type()+ "\n");
  strm.write("\tunique id is : " + get_uid() + "\n");
  strm.write("\tcurrent_status : "
      + LockStatus.printString(currentStatus));
  strm.write("\n\tMode : " + LockMode.stringForm(lMode));
  strm.write("\n\tOwner List : \n");
  owners.print(new PrintWriter(strm));
  return strm.toString();
}

代码示例来源:origin: org.jboss.jbossts.arjunacore/arjunacore

protected final boolean isAncestorOf (Lock heldLock)
{
  if (txojLogger.logger.isTraceEnabled()) {
    txojLogger.logger.trace("LockManager::isAncestorOf(" + heldLock.getCurrentOwner()
        + ")");
  }
  BasicAction action = BasicAction.Current();
  if (action == null)
    return false; /* no action no ancestry! */
  return action.isAncestor(heldLock.getCurrentOwner());
}

相关文章