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

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

本文整理了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

  1. @Override
  2. public ClientInfo getCurrentThreadClientInfo() {
  3. final Subject subject = SecurityUtils.getSubject();
  4. if (subject != null && subject.getPrincipal() != null) {
  5. final String userId = subject.getPrincipal().toString();
  6. final Request current = Request.getCurrent();
  7. if (current != null) {
  8. final String currentIp = RemoteIPFinder.findIP(current);
  9. final String currentUa = current.getClientInfo().getAgent();
  10. return new ClientInfo(userId, currentIp, currentUa);
  11. }
  12. else {
  13. // this is not HTTP processing thread at all
  14. return null;
  15. }
  16. }
  17. // we have no Shiro subject or "anonymous" user (from Shiro perspective, null principals
  18. return null;
  19. }
  20. }

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

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

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

  1. @Override
  2. public ClientInfo getCurrentThreadClientInfo()
  3. {
  4. final Subject subject = SecurityUtils.getSubject();
  5. if ( subject != null && subject.getPrincipal() != null )
  6. {
  7. final String userId = subject.getPrincipal().toString();
  8. final Request current = Request.getCurrent();
  9. if ( current != null )
  10. {
  11. final String currentIp = RemoteIPFinder.findIP( current );
  12. final String currentUa = current.getClientInfo().getAgent();
  13. return new ClientInfo( userId, currentIp, currentUa );
  14. }
  15. else
  16. {
  17. // this is not HTTP processing thread at all
  18. return null;
  19. }
  20. }
  21. // we have no Shiro subject or "anonymous" user (from Shiro perspective, null principals
  22. return null;
  23. }
  24. }

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

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

相关文章