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

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

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

ThreadContext.getSession介绍

暂无

代码示例

代码示例来源:origin: org.apache.wicket/wicket-core

/**
 * Returns session associated to current thread. Always returns a session during a request
 * cycle, even though the session might be temporary
 * 
 * @return session.
 */
public static Session get()
{
  Session session = ThreadContext.getSession();
  if (session != null)
  {
    return session;
  }
  else
  {
    return Application.get().fetchCreateAndSetSession(RequestCycle.get());
  }
}

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

/**
 * Returns session associated to current thread. Always returns a session during a request
 * cycle, even though the session might be temporary
 * 
 * @return session.
 */
public static Session get()
{
  Session session = ThreadContext.getSession();
  if (session != null)
  {
    return session;
  }
  else
  {
    return Application.get().fetchCreateAndSetSession(RequestCycle.get());
  }
}

代码示例来源:origin: org.jabylon/rest.ui

private void internalUmount(String path){
    //workaround so wicket doesn't choke because the thread context isn't filled (wrong thread)
    Application application = ThreadContext.getApplication();
    if (application == null)
      ThreadContext.setApplication(JabylonApplication.this);
    if(ThreadContext.getSession()==null)
      ThreadContext.setSession(new WebSession(createFakeRequest(null)));
//        unmount(path);
    /*
     * umount seems to be greedy, e.g. a prefix match is enough.
     * That's troublesome because umount /settings/log will also umount /settings
     */
    ICompoundRequestMapper rootRequestMapperAsCompound = getRootRequestMapperAsCompound();
    if (rootRequestMapperAsCompound instanceof CompoundRequestMapper) {
      CompoundRequestMapper compound = (CompoundRequestMapper) rootRequestMapperAsCompound;
      Iterator<IRequestMapper> it = compound.iterator();
      while (it.hasNext()) {
        IRequestMapper iRequestMapper = it.next();
        if (iRequestMapper instanceof ResouceAwareMountedMapper) {
          ResouceAwareMountedMapper mapper = (ResouceAwareMountedMapper) iRequestMapper;
          if(path.equals(mapper.getMountPath()))
          {
            logger.info("Unmounting  {}",path);
            getRootRequestMapperAsCompound().remove(mapper);
          }
        }
      }
    }
  }

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

/**
 * Checks existence of a <code>Session</code> associated with the current thread.
 * 
 * @return {@code true} if {@link Session#get()} can return the instance of session,
 *         {@code false} otherwise
 */
public static boolean exists()
{
  Session session = ThreadContext.getSession();
  if (session == null)
  {
    // no session is available via ThreadContext, so lookup in session store
    RequestCycle requestCycle = RequestCycle.get();
    if (requestCycle != null)
    {
      session = Application.get().getSessionStore().lookup(requestCycle.getRequest());
      if (session != null)
      {
        ThreadContext.setSession(session);
      }
    }
  }
  return session != null;
}

代码示例来源:origin: org.apache.wicket/wicket-core

/**
 * Checks existence of a <code>Session</code> associated with the current thread.
 * 
 * @return {@code true} if {@link Session#get()} can return the instance of session,
 *         {@code false} otherwise
 */
public static boolean exists()
{
  Session session = ThreadContext.getSession();
  if (session == null)
  {
    // no session is available via ThreadContext, so lookup in session store
    RequestCycle requestCycle = RequestCycle.get();
    if (requestCycle != null)
    {
      session = Application.get().getSessionStore().lookup(requestCycle.getRequest());
      if (session != null)
      {
        ThreadContext.setSession(session);
      }
    }
  }
  return session != null;
}

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

Session oldSession = ThreadContext.exists() ? ThreadContext.getSession() : null;
ThreadContext oldContext = ThreadContext.detach();
  Session newSession = ThreadContext.getSession();
  ThreadContext.restore(oldContext);
  if (oldSession == null && newSession != null && !newSession.isTemporary()) {

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

Session oldSession = ThreadContext.getSession();
RequestCycle oldRequestCycle = ThreadContext.getRequestCycle();

代码示例来源:origin: org.apache.wicket/wicket-native-websocket-core

Session oldSession = ThreadContext.getSession();
RequestCycle oldRequestCycle = ThreadContext.getRequestCycle();

代码示例来源:origin: theonedev/onedev

Session oldSession = ThreadContext.getSession();
RequestCycle oldRequestCycle = ThreadContext.getRequestCycle();

相关文章