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

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

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

Session.isLive介绍

[英]Returns true if this Session object is usable by the client. Otherwise, returns false. A usable Session is one that is neither logged-out, timed-out nor in any other way disconnected from the repository.
[中]如果客户端可以使用此Session对象,则返回true。否则,返回false。可用的Session是指既没有注销、超时,也没有以任何其他方式与存储库断开连接的存储库。

代码示例

代码示例来源:origin: pentaho/pentaho-platform

@Override protected void finalize() throws Throwable {
  if ( target.isLive() ) {
   //        target.logout();
  }
 }
}

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

@Override
  public void afterTest() throws RepositoryException {
    for (Session session : sessions) {
      if (session.isLive()) {
        session.logout();
      }
    }
  }
}

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

@Override
public void close()
  throws MetadataRepositoryException
{
  if ( jcrSession != null && jcrSession.isLive() )
  {
    jcrSession.logout();
  }
}

代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape

@Override
public Instant updateExpiry(final Duration amountToAdd) {
  if (jcrSession.isLive()) {
    expires = now().plus(amountToAdd);
  }
  return expires;
}

代码示例来源:origin: info.magnolia/magnolia-4-5-migration

private synchronized Session getSession() {
  if (session==null || !session.isLive()) {
    try {
      session = MgnlContext.getJCRSession(DefaultReportingService.WORKSPACE);
    } catch (Exception e) {
      log.error("Cannot obtain JCR session: "+e.getMessage());
      log.debug("Cannot obtain JCR session.", e);
    }
  }
  return session;
}

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

/**
 * Return true if session is live.
 */
public boolean isLive() {
  return getSession().isLive();
}

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

public void tearDown() throws Exception {
  if (file != null) {
    file.delete();
    file = null;
  }
  if (session != null && session.isLive()) {
    session.logout();
    session = null;
  }
  workspace = null;
  super.tearDown();
}

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

/**
 * Checks if this <code>QueryManagerImpl</code> instance is still usable,
 * otherwise throws a {@link javax.jcr.RepositoryException}.
 *
 * @throws RepositoryException if this query manager is not usable anymore,
 *                             e.g. the corresponding session is closed.
 */
private void checkIsAlive() throws RepositoryException {
  if (!session.isLive()) {
    throw new RepositoryException("corresponding session has been closed");
  }
}

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

@Override
public synchronized Node getWrappedNode() {
  try {
    if (node == null || !node.getSession().isLive()) {
      Session session = getSessionForWrappedNode(this.workspace);
      node = session.getNodeByIdentifier(this.nodeIdentifier);
    }
  } catch (RepositoryException e) {
    throw new RuntimeException(e);
  }
  return node;
}

代码示例来源:origin: org.fcrepo/fcrepo-kernel-modeshape

@Override
public void expire() {
  expires = now();
  try {
    if (jcrSession.isLive()) {
      jcrSession.refresh(false);
      jcrSession.logout();
    }
  } catch (final RepositoryException ex) {
    throw new RepositoryRuntimeException(ex);
  }
}

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

public Session getJcrSession()
  throws RepositoryException
{
  if ( this.jcrSession == null || !this.jcrSession.isLive() )
  {
    jcrSession = repository.login( new SimpleCredentials( "admin", "admin".toCharArray() ) );
  }
  return this.jcrSession;
}

代码示例来源:origin: com.thinkbiganalytics.kylo/kylo-metadata-modeshape

default boolean isLive() {
  if (getNode() != null) {
    try {
      if (getNode().getSession() != null) {
        return getNode().getSession().isLive();
      }
    } catch (RepositoryException e) {
    }
  }
  return false;
}

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

@Override
public synchronized Content getWrappedContent() {
  try {
    if (node == null || !node.getJCRNode().getSession().isLive()) {
      node = getHierarchyManager().getContentByUUID(getUuid());
    }
  } catch (RepositoryException e) {
    log.error("can't reinitialize node {}", getUuid(), e);
  }
  return node;
}

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

@Override
protected void tearDown() throws Exception {
  try {
    if (testSession != null && testSession.isLive()) {
      testSession.logout();
    }
  } finally {
    super.tearDown();
  }
}

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

@Override
protected void tearDown() throws Exception {
  try {
    if (testSession != null && testSession.isLive()) {
      testSession.logout();
    }
  } finally {
    super.tearDown();
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms-engine

private void unsubscribe() throws RepositoryException {
  if (fro != null) {
    fro.unsubscribe(this, session);
    fro = null;
  }
  cmsEventDispatcherService.unsubscribe(listenerPath, this);
  if (!isvirtual && session.isLive()) {
    ObservationManager obMgr = session.getWorkspace().getObservationManager();
    obMgr.removeEventListener(this);
  }
  session = null;
}

代码示例来源:origin: pentaho/pentaho-platform

@Before
public void setUp() throws RepositoryException {
 when( nodeMock.getSession() ).thenReturn( sessionMock );
 // Live session
 when( sessionMock.isLive() ).thenReturn( true );
 repoFileProxy = new RepositoryFileProxy( nodeMock, templateMock, pentahoLocale );
 repoFileProxySpy = spy( repoFileProxy );
 // test metadata
 doReturn( metadata ).when( repoFileProxySpy ).getMetadata();
}

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

@Override
protected void tearDown() throws Exception {
  try {
    if (testSession != null && testSession.isLive()) {
      testSession.logout();
    }
    user.remove();
    superuser.save();
  } finally {
    super.tearDown();
  }
}

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

@Override
public NodeData getWrappedNodeData() {
  try {
    // DHM.getNodeData() can still return null and the var itself is transient and won't survive serialization
    if (nodeData == null || (nodeData.isExist() && !nodeData.getJCRProperty().getSession().isLive())) {
      nodeData = getHierarchyManager().getNodeData(getPath());
    }
  } catch (RepositoryException e) {
    log.error("can't reinitialize node {}", getPath(), e);
  }
  return nodeData;
}

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

@Test
public void shouldBeEmpty() throws Exception {
  Session session = session();
  assertThat(session.isLive(), is(true));
  assertThat(session.getRootNode().getNodes().getSize(), is(1L));
  assertThat(session.getRootNode().getNode("jcr:system"), is(notNullValue()));
}

相关文章

微信公众号

最新文章

更多