org.restlet.Context.getServerDispatcher()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(99)

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

Context.getServerDispatcher介绍

[英]Returns a request dispatcher to component's virtual hosts. This is useful for application that want to optimize calls to other applications hosted in the same component or to the application itself.

The processing is the same as what would have been done if the request came from one of the component's server connectors. It first must match one of the registered virtual hosts. Then it can be routed to one of the attached Restlets, typically an Application.

Note that the RIAP pseudo protocol isn't supported by this dispatcher, you should instead rely on the #getClientDispatcher() method.
[中]将请求调度程序返回到组件的虚拟主机。这对于希望优化对同一组件中托管的其他应用程序或对应用程序本身的调用的应用程序非常有用。
处理过程与如果请求来自组件的一个服务器连接器时所做的相同。它首先必须匹配一个已注册的虚拟主机。然后可以将它路由到一个附加的restlet,通常是一个应用程序。
请注意,此dispatcher不支持RIAP伪协议,而是应该依赖#getClientDispatcher()方法。

代码示例

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Redirects a given call to a target reference. In the default
 * implementation, the request HTTP headers, stored in the request's
 * attributes, are removed before dispatching. After dispatching, the
 * response HTTP headers are also removed to prevent conflicts with the main
 * call.
 * 
 * @param targetRef
 *            The target reference with URI variables resolved.
 * @param request
 *            The request to handle.
 * @param response
 *            The response to update.
 */
protected void inboundServerRedirect(Reference targetRef, Request request,
    Response response) {
  serverRedirect(getContext().getServerDispatcher(), targetRef, request,
      response);
}

代码示例来源:origin: com.noelios.restlet/com.noelios.restlet.ext.servlet

/**
 * Constructor.
 * 
 * @param servlet
 *            The parent Servlet.
 * @param parentContext
 *            The parent context.
 */
public ServletContextAdapter(Servlet servlet, Context parentContext) {
  super(new ServletLogger(servlet.getServletConfig().getServletContext()));
  this.servletContext = servlet.getServletConfig().getServletContext();
  this.clientDispatcher = (parentContext != null) ? parentContext
      .getClientDispatcher() : null;
  this.serverDispatcher = (parentContext != null) ? parentContext
      .getServerDispatcher() : null;
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

@Get
Representation retrieve() {
  // Create the mail URI inside the API application
  String accountId = getAttribute("accountId");
  String mailId = getAttribute("mailId");
  String mailApiUri = "riap://component/api/accounts/" + accountId
      + "/mails/" + mailId;
  // Optimal internal call using the server dispatcher
  ClientResource cr = new ClientResource(mailApiUri);
  cr.setNext(getContext().getServerDispatcher());
  MailRepresentation mail = cr.get(MailRepresentation.class);
  // Load the FreeMarker template
  Representation mailFtl = new ClientResource(
      LocalReference.createClapReference(getClass().getPackage())
          + "/Mail.ftl").get();
  // Wraps the bean with a FreeMarker representation
  return new TemplateRepresentation(mailFtl, mail, MediaType.TEXT_HTML);
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Constructor.
 * 
 * @param parentContext
 *            The parent context.
 */
public ChildContext(Context parentContext) {
  this.child = null;
  this.parentContext = parentContext;
  setClientDispatcher(new ChildClientDispatcher(this));
  setServerDispatcher((parentContext != null) ? getParentContext()
      .getServerDispatcher() : null);
  setExecutorService((parentContext != null) ? ((parentContext
      .getExecutorService() != null) ? new WrapperScheduledExecutorService(
      parentContext.getExecutorService()) : null)
      : null);
}

相关文章