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

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

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

Context.getClientDispatcher介绍

[英]Returns a request dispatcher to available client connectors. When you ask the dispatcher to handle a request, it will automatically select the appropriate client connector for your request, based on the request.protocol property or on the resource URI's scheme. This call is blocking and will return an updated response object.
[中]将请求分派器返回到可用的客户端连接器。当您要求dispatcher处理请求时,它将根据请求自动为您的请求选择适当的客户端连接器。资源URI的方案上的协议属性或。此调用正在阻止并将返回更新的响应对象。

代码示例

代码示例来源:origin: stackoverflow.com

protected Application initObjLinkage(){

  Context cx = this.getContext();
  Client cli = cx.getClientDispatcher();
  Application app = cli.getApplication() ;
  return app;
}

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

/**
 * Returns a request dispatcher to available client connectors. When you ask
 * the dispatcher to handle a request, it will automatically select the best
 * client connector for your request, based on the request.protocol property
 * or on the resource URI's scheme. This call is blocking and will return an
 * updated response object.
 * 
 * @return A request dispatcher to virtual hosts of the local component.
 * @deprecated Use getClientDispatcher() instead.
 */
@Deprecated
public Uniform getDispatcher() {
  return getClientDispatcher();
}

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

/**
 * Sets the context.
 * 
 * @param context
 *            The context.
 */
public void setContext(Context context) {
  if (context != null) {
    setOutboundNext(context.getClientDispatcher());
  }
}

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

/**
 * Constructor.
 * 
 * @param context
 *            The context from which the client dispatcher will be
 *            retrieved.
 * @param serviceUri
 *            The service URI.
 * @throws IOException
 */
public Service(Context context, String serviceUri) throws IOException {
  this(context.getClientDispatcher(), serviceUri, context
      .getClientDispatcher().get(serviceUri).getEntity());
}

代码示例来源:origin: com.whizzosoftware.hobson.hub/hobson-hub-setup

public Context getContext() {
    // Get the context from the parent
    Context context = super.getContext();

    // Wrapper the context's client dispatcher in an object that will force it to use the OSGi bundle classloader
    // rather than the classloader that created the dispatcher. Also, the same Context object may run through
    // this many times so we have to make sure we don't wrapper multiple times -- otherwise evil hilarity will ensue
    // (i.e stack overflows)
    if (!(context.getClientDispatcher() instanceof CLAPCustomClassLoaderDispatcher)) {
      context.setClientDispatcher(new CLAPCustomClassLoaderDispatcher(context.getClientDispatcher(), bundleClassloader));
    }

    return context;
  }
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.atom

/**
 * Constructor.
 * 
 * @param context
 *            The context from which the client dispatcher will be
 *            retrieved.
 * @param serviceUri
 *            The service URI.
 * @throws IOException
 */
public Service(Context context, String serviceUri) throws IOException {
  this(context.getClientDispatcher(), serviceUri, context
      .getClientDispatcher()
      .handle(new Request(Method.GET, serviceUri)).getEntity());
}

代码示例来源:origin: org.restlet.android/org.restlet.ext.atom

/**
 * Constructor.
 * 
 * @param context
 *            The context from which the client dispatcher will be
 *            retrieved.
 * @param serviceUri
 *            The service URI.
 * @throws IOException
 */
public Service(Context context, String serviceUri) throws IOException {
  this(context.getClientDispatcher(), serviceUri, context
      .getClientDispatcher()
      .handle(new Request(Method.GET, serviceUri)).getEntity());
}

代码示例来源: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.jee/org.restlet.ext.atom

/**
 * Constructor.
 * 
 * @param context
 *            The context from which the client dispatcher will be
 *            retrieved.
 * @param feedUri
 *            The feed URI.
 * @throws IOException
 */
public Feed(Context context, String feedUri) throws IOException {
  this(context.getClientDispatcher()
      .handle(new Request(Method.GET, feedUri)).getEntity());
}

代码示例来源:origin: org.restlet.android/org.restlet.ext.atom

/**
 * Constructor.
 * 
 * @param context
 *            The context from which the client dispatcher will be
 *            retrieved.
 * @param entryUri
 *            The entry URI.
 * @throws IOException
 */
public Entry(Context context, String entryUri) throws IOException {
  this(context.getClientDispatcher().handle(
      new Request(Method.GET, entryUri)).getEntity());
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.atom

/**
 * Constructor.
 * 
 * @param context
 *            The context from which the client dispatcher will be
 *            retrieved.
 * @param categoriesUri
 *            The feed URI.
 * @throws IOException
 */
public Categories(Context context, String categoriesUri) throws IOException {
  this(context.getClientDispatcher()
      .handle(new Request(Method.GET, categoriesUri)).getEntity());
}

代码示例来源:origin: org.restlet.android/org.restlet.ext.atom

/**
 * Constructor.
 * 
 * @param context
 *            The context from which the client dispatcher will be
 *            retrieved.
 * @param categoriesUri
 *            The feed URI.
 * @throws IOException
 */
public Categories(Context context, String categoriesUri) throws IOException {
  this(context.getClientDispatcher().handle(
      new Request(Method.GET, categoriesUri)).getEntity());
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.atom

/**
 * Constructor.
 * 
 * @param context
 *            The context from which the client dispatcher will be
 *            retrieved.
 * @param entryUri
 *            The entry URI.
 * @throws IOException
 */
public Entry(Context context, String entryUri) throws IOException {
  this(context.getClientDispatcher()
      .handle(new Request(Method.GET, entryUri)).getEntity());
}

代码示例来源:origin: org.restlet.android/org.restlet.ext.atom

/**
 * Constructor.
 * 
 * @param context
 *            The context from which the client dispatcher will be
 *            retrieved.
 * @param feedUri
 *            The feed URI.
 * @throws IOException
 */
public Feed(Context context, String feedUri) throws IOException {
  this(context.getClientDispatcher()
      .handle(new Request(Method.GET, feedUri)).getEntity());
}

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

/**
 * Asks to the parent component to handle the call.
 * 
 * @param request
 *            The request to handle.
 * @param response
 *            The response to update.
 */
private void parentHandle(Request request, Response response) {
  if (getChildContext() != null) {
    if (getChildContext().getParentContext() != null) {
      if (getChildContext().getParentContext().getClientDispatcher() != null) {
        getChildContext().getParentContext().getClientDispatcher()
            .handle(request, response);
      } else {
        getLogger()
            .warning(
                "The parent context doesn't have a client dispatcher available. Unable to handle call.");
      }
    } else {
      getLogger()
          .warning(
              "Your Restlet doesn't have a parent context available.");
    }
  } else {
    getLogger().warning(
        "Your Restlet doesn't have a context available.");
  }
}

代码示例来源:origin: org.restlet.gae/org.restlet.ext.freemarker

/**
 * Finds the object that acts as the source of the template with the given
 * name.
 * 
 * @param name
 *            The template name.
 * @return The template source {@link Representation}.
 */
public Object findTemplateSource(String name) throws IOException {
  String fullUri;
  if (getBaseUri().endsWith("/")) {
    fullUri = getBaseUri() + name;
  } else {
    fullUri = getBaseUri() + "/" + name;
  }
  return (getContext() == null) ? null : getContext()
      .getClientDispatcher().handle(new Request(Method.GET, fullUri))
      .getEntity();
}

代码示例来源:origin: org.restlet.android/org.restlet.ext.xml

Response response = this.context.getClientDispatcher().handle(
    new Request(Method.GET, targetUri));

代码示例来源: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 outboundServerRedirect(Reference targetRef, Request request,
    Response response) {
  Restlet next = (getApplication() == null) ? null : getApplication()
      .getOutboundRoot();
  if (next == null) {
    next = getContext().getClientDispatcher();
  }
  serverRedirect(next, targetRef, request, response);
  if (response.getEntity() != null
      && !request.getResourceRef().getScheme()
          .equalsIgnoreCase(targetRef.getScheme())) {
    // Distinct protocol, this data cannot be exposed.
    response.getEntity().setLocationRef((Reference) null);
  }
}

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

/**
 * Creates a next Restlet is no one is set. By default, it creates a new
 * {@link Client} based on the protocol of the resource's URI reference.
 * 
 * @return The created next Restlet or null.
 */
protected Uniform createNext() {
  Uniform result = null;
  // Prefer the outbound root
  result = getApplication().getOutboundRoot();
  if ((result == null) && (getContext() != null)) {
    // Try using directly the client dispatcher
    result = getContext().getClientDispatcher();
  }
  if (result == null) {
    // As a final option, try creating a client connector
    Protocol rProtocol = getProtocol();
    Reference rReference = getReference();
    Protocol protocol = (rProtocol != null) ? rProtocol
        : (rReference != null) ? rReference.getSchemeProtocol()
            : null;
    if (protocol != null) {
      org.restlet.engine.util.TemplateDispatcher dispatcher = new org.restlet.engine.util.TemplateDispatcher();
      dispatcher.setContext(getContext());
      dispatcher.setNext(new Client(protocol));
      result = dispatcher;
    }
  }
  return result;
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.wadl

/**
 * Attaches an application created from a WADL description document
 * available at a given URI reference.
 * 
 * @param wadlRef
 *            The URI reference to the WADL description document.
 * @return The created WADL application.
 */
public WadlApplication attach(Reference wadlRef) {
  WadlApplication result = null;
  // Adds some common client connectors to load the WADL documents
  if (!getClients().contains(wadlRef.getSchemeProtocol())) {
    getClients().add(wadlRef.getSchemeProtocol());
  }
  // Get the WADL document
  final Response response = getContext().getClientDispatcher().handle(
      new Request(Method.GET, wadlRef));
  if (response.getStatus().isSuccess() && response.isEntityAvailable()) {
    result = attach(response.getEntity());
  }
  return result;
}

相关文章