org.restlet.data.Request.getCurrent()方法的使用及代码示例

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

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

Request.getCurrent介绍

[英]Returns the request associated to the current thread. This is reusing the Response#getCurrent() method. Warning: this method should only be used under duress. You should by default prefer obtaining the current context using methods such as org.restlet.resource.Resource#getRequest().
[中]返回与当前线程关联的请求。这是在重用Response#getCurrent()方法。警告:此方法只能在胁迫下使用。默认情况下,您应该更喜欢使用org等方法获取当前上下文。restlet。资源资源#getRequest()。

代码示例

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin

@Override
 public ClientInfo getCurrentThreadClientInfo() {
  final Subject subject = SecurityUtils.getSubject();
  if (subject != null && subject.getPrincipal() != null) {
   final String userId = subject.getPrincipal().toString();

   final Request current = Request.getCurrent();
   if (current != null) {
    final String currentIp = RemoteIPFinder.findIP(current);
    final String currentUa = current.getClientInfo().getAgent();
    return new ClientInfo(userId, currentIp, currentUa);
   }
   else {
    // this is not HTTP processing thread at all
    return null;
   }
  }
  // we have no Shiro subject or "anonymous" user (from Shiro perspective, null principals
  return null;
 }
}

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin

else if (Request.getCurrent() != null) {
 baseURL = Request.getCurrent().getRootRef().getParentRef().getParentRef().toString();

代码示例来源:origin: org.sonatype.nexus/nexus-rest-api

@Override
  public ClientInfo getCurrentThreadClientInfo()
  {
    final Subject subject = SecurityUtils.getSubject();
    if ( subject != null && subject.getPrincipal() != null )
    {
      final String userId = subject.getPrincipal().toString();

      final Request current = Request.getCurrent();
      if ( current != null )
      {
        final String currentIp = RemoteIPFinder.findIP( current );
        final String currentUa = current.getClientInfo().getAgent();
        return new ClientInfo( userId, currentIp, currentUa );
      }
      else
      {
        // this is not HTTP processing thread at all
        return null;
      }
    }
    // we have no Shiro subject or "anonymous" user (from Shiro perspective, null principals
    return null;
  }
}

代码示例来源:origin: org.sonatype.nexus/nexus-rest-api

else if ( Request.getCurrent() != null )
  baseURL = Request.getCurrent().getRootRef().toString();

相关文章