org.apache.wicket.ThreadContext.exists()方法的使用及代码示例

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

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

ThreadContext.exists介绍

[英]Checks if ThreadContext exists for the current thread
[中]检查当前线程是否存在ThreadContext

代码示例

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

@Override
  public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
  {
    boolean existed = ThreadContext.exists();
    if (existed == false)
    {
      ThreadContext.setApplication(application);
    }
    try
    {
      return method.invoke(o, args);
    }
    finally
    {
      if (existed == false)
      {
        ThreadContext.detach();
      }
    }
  }
});

代码示例来源:origin: ru.ydn.wicket.wicket-orientdb/wicket-orientdb

protected CookieManager getPersonalCookieManager()
{
  try
  {
    if(!ThreadContext.exists() || RequestCycle.get()==null) return defaultManager;
    
    OrientDbWebSession session = OrientDbWebSession.get();
    session.bind();
    String id = session.getId();
    if(session.isSignedIn()) id=session.getUsername()+'-'+id;
    return cache.get(id, new Callable<CookieManager>() {
      @Override
      public CookieManager call() throws Exception {
        return new CookieManager();
      }
    });
  } catch (ExecutionException e)
  {
    throw new IllegalStateException("Cookie Manager should be always calculated");
  }
}

代码示例来源:origin: OrienteerBAP/wicket-orientdb

protected CookieManager getPersonalCookieManager()
{
  try
  {
    if(!ThreadContext.exists() || RequestCycle.get()==null) return defaultManager;
    
    OrientDbWebSession session = OrientDbWebSession.get();
    session.bind();
    String id = session.getId();
    if(session.isSignedIn()) id=session.getUsername()+'-'+id;
    return cache.get(id, new Callable<CookieManager>() {
      @Override
      public CookieManager call() throws Exception {
        return new CookieManager();
      }
    });
  } catch (ExecutionException e)
  {
    throw new IllegalStateException("Cookie Manager should be always calculated");
  }
}

代码示例来源:origin: at.molindo/molindo-wicket-utils

Session oldSession = ThreadContext.exists() ? ThreadContext.getSession() : null;
ThreadContext oldContext = ThreadContext.detach();

相关文章