javax.jcr.Session.addLockToken()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(102)

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

Session.addLockToken介绍

[英]Adds the specified lock token to this Session. Holding a lock token makes this Session the owner of the lock specified by that particular lock token.
[中]将指定的锁令牌添加到此Session。持有锁令牌会使这个Session成为该特定锁令牌指定的锁的所有者。

代码示例

代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector

/**
 * Forwards the method call to the underlying session.
 */
public void addLockToken(String lt) {
  session.addLockToken(lt);
}

代码示例来源:origin: apache/jackrabbit

/** {@inheritDoc} */
public void addLockToken(String token) throws RemoteException {
  session.addLockToken(token);
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public void addLockToken(String lt) {
  getWrappedSession().addLockToken(lt);
}

代码示例来源:origin: apache/jackrabbit

/**
 * Add lock token.
 */
@SuppressWarnings("deprecation")
public void addLockToken(String arg0) {
  getSession().addLockToken(arg0);
}

代码示例来源:origin: ModeShape/modeshape

@SuppressWarnings( "deprecation" )
@Override
public void addLockToken( String string ) {
  session().addLockToken(string);
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jca

/**
 * Add lock token.
 */
@SuppressWarnings("deprecation")
public void addLockToken(String arg0) {
  getSession().addLockToken(arg0);
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

@Override
default void addLockToken(final String lt) {
  unwrapSession().addLockToken(lt);
}

代码示例来源:origin: brix-cms/brix-cms

/**
 * @deprecated
 */
@Deprecated
public void addLockToken(String lt) {
  getDelegate().addLockToken(lt);
}

代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr

public void addLockToken(String s)
{ getSession().addLockToken(s); }

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-ocm

protected void maybeAddLockToken(final String lockToken) {
  if (lockToken != null) {
    // This user (this instance of PM) potentionally placed lock so
    // session already has lock token
    final String[] lockTokens = getSession().getLockTokens();
    if (lockTokens != null) {
      for (int i = 0; i < lockTokens.length; i++) {
        if (lockTokens[i].equals(lockToken)) {
          // we are already holding a lock
          break;
        }
      }
    } else {
      getSession().addLockToken(lockToken);
    }
  }
}

代码示例来源:origin: apache/jackrabbit

/**
 * Test open-scoped locks
 */
public void testOpenScopedLocks() throws Exception {
  // add node
  Node n1 = testRootNode.addNode(nodeName1, testNodeType);
  ensureMixinType(n1, mixLockable);
  testRootNode.getSession().save();
  // create new session
  Session otherSuperuser = getHelper().getSuperuserSession();
  try {
    // get node created above
    Node n2 = (Node) otherSuperuser.getItem(n1.getPath());
    // lock node
    Lock lock = n2.lock(false, false);
    // transfer to standard session
    String lockToken = lock.getLockToken();
    otherSuperuser.removeLockToken(lockToken);
    superuser.addLockToken(lockToken);
  } finally {
    // log out
    otherSuperuser.logout();
  }
  // assert: node still locked
  assertTrue(n1.isLocked());
}

代码示例来源:origin: apache/jackrabbit

public void testRefreshAfterTokenTransfer2() throws Exception {
  String lockToken = lock.getLockToken();
  Node n2 = (Node) otherSession.getItem(lockedNode.getPath());
  try {
    superuser.removeLockToken(lockToken);
    otherSession.addLockToken(lockToken);
    n2.getLock().refresh();
  } finally {
    // move lock token back in order to have lock removed properly
    otherSession.removeLockToken(lockToken);
    superuser.addLockToken(lockToken);
  }
}

代码示例来源:origin: apache/jackrabbit

public void testUnlockAfterTokenTransfer2() throws Exception {
  String lockToken = lock.getLockToken();
  try {
    superuser.removeLockToken(lockToken);
    otherSession.addLockToken(lockToken);
    // otherSession is now lockHolder -> unlock must succeed.
    Node n2 = (Node) otherSession.getItem(lockedNode.getPath());
    n2.unlock();
  } catch (RepositoryException e) {
    // only in case of failure:
    // move lock token back in order to have lock removed properly
    // if test succeeds, moving back tokens is not necessary.
    otherSession.removeLockToken(lockToken);
    superuser.addLockToken(lockToken);
    // and rethrow
    throw e;
  }
}

代码示例来源:origin: apache/jackrabbit

public void testTokenTransfer() throws Exception {
  String lockToken = lock.getLockToken();
  try {
    superuser.removeLockToken(lockToken);
    String nlt = lock.getLockToken();
    assertTrue("freshly obtained lock token must either be null or the same as the one returned earlier",
        nlt == null || nlt.equals(lockToken));
  } finally {
    // move lock token back in order to have lock removed properly
    superuser.addLockToken(lockToken);
  }
}

代码示例来源:origin: apache/jackrabbit

superuser.addLockToken(lockToken);

代码示例来源:origin: apache/jackrabbit

public void testLockHolderAfterTokenTransfer() throws Exception {
  String lockToken = lock.getLockToken();
  Node n2 = (Node) otherSession.getItem(lockedNode.getPath());
  try {
    superuser.removeLockToken(lockToken);
    otherSession.addLockToken(lockToken);
    assertTrue("After lockToken transfer, the new lockHolder must get a non-null token", n2.getLock().getLockToken() != null);
    assertTrue("After lockToken transfer, the new lockHolder must get the same token.", n2.getLock().getLockToken().equals(lockToken));
  } finally {
    // move lock token back in order to have lock removed properly
    otherSession.removeLockToken(lockToken);
    superuser.addLockToken(lockToken);
  }
}

代码示例来源:origin: apache/jackrabbit

public void testRefreshAfterTokenTransfer() throws Exception {
  String lockToken = lock.getLockToken();
  try {
    superuser.removeLockToken(lockToken);
    lock.refresh();
    fail("After transfering lock token the original lock object cannot be refresh by session, that does hold lock any more.");
  } catch (LockException e) {
    // oK
  } finally {
    // move lock token back in order to have lock removed properly
    superuser.addLockToken(lockToken);
  }
}

代码示例来源:origin: apache/jackrabbit

public void testUnlockAfterTokenTransfer() throws Exception {
  String lockToken = lock.getLockToken();
  try {
    superuser.removeLockToken(lockToken);
    lockedNode.unlock();
    fail("After transfering lock token the original lock object cannot be unlocked by session, that does hold lock any more.");
  } catch (LockException e) {
    // oK
  } finally {
    // move lock token back in order to have lock removed properly
    superuser.addLockToken(lockToken);
  }
}

代码示例来源:origin: apache/jackrabbit

public void testLogoutHasNoEffect() throws Exception {
  // create a second session session. since logout of the 'superuser'
  // will cause all inherited tear-down to fail
  Node testRoot2 = (Node) otherSession.getItem(testRootNode.getPath());
  Node lockedNode2 = testRoot2.addNode(nodeName2, testNodeType);
  lockedNode2.addMixin(mixLockable);
  testRoot2.save();
  Lock lock2 = lockedNode2.lock(false, isSessionScoped());
  // force reloading of the testroot in order to be aware of the
  // locked node added by another session
  testRootNode.refresh(false);
  Node n2 = (Node) superuser.getItem(lockedNode2.getPath());
  try {
    String lockToken = lock2.getLockToken();
    otherSession.removeLockToken(lockToken);
    superuser.addLockToken(lockToken);
    otherSession.logout();
    assertTrue("After logout a open-scoped node must still be locked.", lock2.isLive());
    assertTrue("After logout a open-scoped node must still be locked.", n2.isLocked());
  } finally {
    n2.unlock();
  }
}

代码示例来源:origin: apache/jackrabbit

try {
  superuser.removeLockToken(lockToken);
  otherSession.addLockToken(lockToken);
  superuser.addLockToken(lockToken);

相关文章

微信公众号

最新文章

更多