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

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

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

Session.getLockTokens介绍

[英]Returns an array containing all lock tokens currently held by this Session. Note that any such tokens will represent open-scoped locks, since session-scoped locks do not have tokens.
[中]返回一个数组,其中包含此[$0$]当前持有的所有锁令牌。请注意,任何这样的令牌都将代表开放范围的锁,因为会话范围的锁没有令牌。

代码示例

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

/**
 * Forwards the method call to the underlying session.
 */
public String[] getLockTokens() {
  return session.getLockTokens();
}

代码示例来源:origin: net.adamcin.oakpal/oakpal-core

@Override
public String[] getLockTokens() {
  return delegate.getLockTokens();
}

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

/** {@inheritDoc} */
public String[] getLockTokens() throws RemoteException {
  return session.getLockTokens();
}

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

/**
 * Return a flag indicating whether the indicated session contains
 * a specific lock token
 */
private boolean containsLockToken(Session session, String lockToken) {
  String[] lt = session.getLockTokens();
  for (int i = 0; i < lt.length; i++) {
    if (lt[i].equals(lockToken)) {
      return true;
    }
  }
  return false;
}

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

/**
 * Return the lock tokens.
 */
@SuppressWarnings("deprecation")
public String[] getLockTokens() {
  return getSession().getLockTokens();
}

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

/**
 * Return the lock tokens.
 */
@SuppressWarnings("deprecation")
public String[] getLockTokens() {
  return getSession().getLockTokens();
}

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

/**
 * @deprecated
 */
@Deprecated
public String[] getLockTokens() {
  return getDelegate().getLockTokens();
}

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

@SuppressWarnings( "deprecation" )
@Override
public String[] getLockTokens() {
  return session().getLockTokens();
}

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

@Override
public String[] getLockTokens() {
  return getWrappedSession().getLockTokens();
}

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

public String[] getLockTokens()
{ return getSession().getLockTokens(); }

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

@Override
default String[] getLockTokens() {
  return unwrapSession().getLockTokens();
}

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

/**
   * Return a flag indicating whether the indicated session contains
   * a specific lock token
   */
  private boolean containsLockToken(Session session, String lockToken) {
    String[] lt = session.getLockTokens();
    for (int i = 0; i < lt.length; i++) {
      if (lt[i].equals(lockToken)) {
        return true;
      }
    }
    return false;
  }
}

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

public void testGetLockTokensSessionScoped() throws RepositoryException,
    NotExecutableException {
  assertLockable(testNode);
  List<String> tokensBefore = Arrays.asList(lockMgr.getLockTokens());
  boolean sessionScoped = true;
  Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
  assertEquals("Creating a session scoped lock must not change the lock tokens.",
      tokensBefore, Arrays.asList(lockMgr.getLockTokens()));
  assertEquals("Creating a session scoped lock must not change the lock tokens.",
      tokensBefore, Arrays.asList(superuser.getLockTokens()));
}

代码示例来源: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 if the lock token has been automatically added to the set of lock
 * tokens present with the Session that created the new Lock.
 *
 * @throws RepositoryException
 */
public void testLockTokenPresentWithSession() throws RepositoryException {
  String token = lock.getLockToken();
  String[] allTokens = lockedNode.getSession().getLockTokens();
  for (int i = 0; i < allTokens.length; i++) {
    if (allTokens[i].equals(token)) {
      // lock token is present with the session that applied the lock
      // OK
      return;
    }
  }
  // lock token not present within tokens returned by Session.getLockTokens.
  fail("Upon successful call to Node.lock, the lock token must automatically be added to the set of tokens held by the Session.");
}

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

/**
   * Only removes the <code>DavSession</code> object from the given request object.
   * and remove all the lock tokens from the underlying repository session
   * in order make sure they can be reset when attaching a session to the
   * next request. Finally the session provider is informed, that the
   * session is no longer used.
   *
   * @param request
   * @see DavSessionProvider#releaseSession(org.apache.jackrabbit.webdav.WebdavRequest)
   */
  public void releaseSession(WebdavRequest request) {
    DavSession ds = request.getDavSession();
    if (ds != null && ds instanceof DavSessionImpl) {
      Session repSession = ((DavSessionImpl)ds).getRepositorySession();
      for (String lockToken : repSession.getLockTokens()) {
        repSession.removeLockToken(lockToken);
      }
      sesProvider.releaseSession(repSession);
      log.debug("Releasing session '"+ ds + "' from request '" + request + "'");
    } // else : session is null. nothing to be done.
    request.setDavSession(null);
  }
}

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

public void testGetLockTokens() throws RepositoryException,
    NotExecutableException {
  assertLockable(testNode);
  boolean sessionScoped = false;
  Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
  String ltoken = l.getLockToken();
  assertTrue("Creating open scoped lock must add token to the lock manager.",
      containsLockToken(lockMgr, ltoken));
  assertTrue("Creating open scoped lock must add token to the lock manager.",
      containsLockToken(superuser.getLockTokens(), ltoken));
}

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

public void testGetLockTokensAfterUnlock() throws RepositoryException,
    NotExecutableException {
  assertLockable(testNode);
  boolean sessionScoped = false;
  Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
  String ltoken = l.getLockToken();
  lockMgr.unlock(testPath);
  assertFalse("Removing an open scoped lock must remove the token from the lock manager.",
      containsLockToken(lockMgr, ltoken));
  assertFalse("Removing an open scoped lock must remove the token from the lock manager.",
      containsLockToken(superuser.getLockTokens(), ltoken));
}

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

public void testRemoveLockToken() throws Exception {
  assertLockable(testNode);
  boolean sessionScoped = false;
  Lock l = lockMgr.lock(testPath, true, sessionScoped, Long.MAX_VALUE, null);
  String ltoken = l.getLockToken();
  try {
    // remove lock token
    lockMgr.removeLockToken(ltoken);
    assertFalse(containsLockToken(lockMgr, ltoken));
    assertFalse(containsLockToken(superuser.getLockTokens(), ltoken));
  } finally {
    // make sure lock token is added even if test fail
    lockMgr.addLockToken(ltoken);
    assertTrue(containsLockToken(lockMgr, ltoken));
    assertNotNull("Token must be exposed again", l.getLockToken());
    assertEquals("The lock must get the same token again.", ltoken, l.getLockToken());
  }
}

相关文章

微信公众号

最新文章

更多