org.restlet.data.Protocol类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(180)

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

Protocol介绍

[英]Protocol used by client and server connectors. Connectors enable the communication between components by implementing standard protocols.
[中]客户端和服务器连接器使用的协议。连接器通过实现标准协议实现组件之间的通信。

代码示例

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

@Override
protected void handleLocal(Request request, Response response,
    String decodedPath) {
  String scheme = request.getResourceRef().getScheme();
  if (!FILE.getSchemeName().equalsIgnoreCase(scheme)) {
    throw new IllegalArgumentException(format(
        "Protocol \"%s\" not supported by the connector. Only FILE is supported.", scheme));
  }
  handleFile(request, response, decodedPath);
}

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

/**
 * Creates a reference string from its parts.
 * 
 * @param scheme
 *            The scheme ("http", "https" or "ftp").
 * @param hostName
 *            The host name or IP address.
 * @param hostPort
 *            The host port (default ports are correctly ignored).
 * @param path
 *            The path component for hierarchical identifiers.
 * @param query
 *            The optional query component for hierarchical identifiers.
 * @param fragment
 *            The optional fragment identifier.
 * @return The reference as String.
 */
public static String toString(String scheme, String hostName,
    Integer hostPort, String path, String query, String fragment) {
  String host = hostName;
  // Appends the host port number
  if (hostPort != null) {
    final int defaultPort = Protocol.valueOf(scheme).getDefaultPort();
    if (hostPort != defaultPort) {
      host = hostName + ':' + hostPort;
    }
  }
  return toString(scheme, host, path, query, fragment);
}

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

/**
 * Creates the protocol associated to a URI scheme name. If an existing
 * constant exists then it is returned, otherwise a new instance is created.
 * 
 * @param name
 *            The scheme name.
 * @param version
 *            The version number.
 * @return The associated protocol.
 */
public static Protocol valueOf(String name, String version) {
  Protocol result = valueOf(name);
  if (!version.equals(result.getVersion())) {
    result = new Protocol(result.getSchemeName(), result.getName(),
        result.getTechnicalName(), result.getDescription(),
        result.getDefaultPort(), result.isConfidential(), version);
  }
  return result;
}

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

/**
 * Returns the name.
 * 
 * @return The name.
 */
@Override
public String toString() {
  return getName() + ((getVersion() == null) ? "" : "/" + getVersion());
}

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

/**
 * Returns a protocol by its scheme. If the latter is unknown, instantiate a
 * new protocol object.
 * 
 * @param scheme
 *            the scheme of the desired protocol.
 * @return a known protocol or a new instance.
 */
private Protocol getProtocol(String scheme) {
  Protocol protocol = Protocol.valueOf(scheme);
  if (protocol == null) {
    protocol = new Protocol(scheme);
  }
  return protocol;
}

代码示例来源:origin: org.metaeffekt.dcc/dcc-agent-core

for (Map.Entry<String, Object> entry : request.getAttributes()
    .entrySet()) {
  if (!getHeaderFilterStrategy().applyFilterToExternalHeaders(
inMessage.setHeader(Exchange.HTTP_METHOD, request.getMethod());
inMessage.setHeader(Exchange.CONTENT_TYPE, request.getEntity()
    .getMediaType());
String query = request.getResourceRef().getQuery();
  Request httpRequest = (Request) request;
  if (httpRequest.getHostRef() != null) {
    String host = httpRequest.getHostRef().getHostDomain();
    int port = httpRequest.getHostRef().getHostPort();
    String protocol = "http";
    if (httpRequest.getHostRef().getSchemeProtocol() != null) {
      protocol = httpRequest.getHostRef().getSchemeProtocol().getSchemeName();

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

ClientInfo clientInfo = request.getClientInfo();
  addHeader(HEADER_FROM, request.getClientInfo().getFrom(), headers);
Reference hostRef = (request.getResourceRef().getBaseRef() != null) ? request
    .getResourceRef().getBaseRef() : request.getResourceRef();
if (hostRef.getHostDomain() != null) {
  String host = hostRef.getHostDomain();
  int hostRefPortValue = hostRef.getHostPort();
      && (hostRefPortValue != request.getProtocol().getDefaultPort())) {
    host = host + ':' + hostRefPortValue;
  Context.getCurrentLogger()
      .log(WARNING,
          "Unable to format the HTTP If-Range header due to the presence of both entity tag and modification date.");

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

@Override
public void handle(Request request, Response response) {
  try {
    if (Protocol.FTP.equals(request.getProtocol())) {
      if (Method.GET.equals(request.getMethod())) {
        Reference ftpRef = request.getResourceRef();
        String userInfo = null;
          ftpRef.setUserInfo(userInfo);
        URL url = ftpRef.toUrl();
        URLConnection connection = url.openConnection();
        Entity.updateMetadata(request.getResourceRef().getPath(),
            response.getEntity(), true, getMetadataService());
      } else {

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

result = (this.request != null) ? this.request.getAttributes().get(variableName) : null;
if (result != null) {
  return result;
  ChallengeResponse cr = this.request.getChallengeResponse();
  Representation entity = this.request.getEntity();
    return (this.request.getMethod() != null) ? this.request.getMethod().getName() : null;
  case "p":
    return (this.request.getProtocol() != null) ? this.request.getProtocol().getName() : null;
  default:
    if (variableName.startsWith("o")) {

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

Endpoint endpoint = new Endpoint(baseRef.getHostDomain(),
    baseRef.getHostPort(), baseRef.getSchemeProtocol()
        .getSchemeName(), baseRef.getPath(), scheme);
definition.getEndpoints().add(endpoint);
    Protocol.HTTP.getSchemeName(), "/v1", scheme);
definition.getEndpoints().add(endpoint);

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

/**
 * Displays a synthesis of the request like an HTTP request line.
 * 
 * @return A synthesis of the request like an HTTP request line.
 */
public String toString() {
  return ((getMethod() == null) ? "" : getMethod().toString())
      + " "
      + ((getResourceRef() == null) ? "" : getResourceRef()
          .toString())
      + " "
      + ((getProtocol() == null) ? ""
          : (getProtocol().getName() + ((getProtocol()
              .getVersion() == null) ? "" : "/"
              + getProtocol().getVersion())));
}

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

final String path = getPath();
if (path != null) {
  input.append(path);
      && input.substring(0, 4).equals("/../")) {
    input.delete(0, 3);
    removeLastSegment(output);
  } else if ((input.length() == 3)
      && input.substring(0, 3).equals("/..")) {
    input.delete(1, 3);
    removeLastSegment(output);
final int hostPort = getHostPort();
if (hostPort != -1) {
  final int defaultPort = Protocol.valueOf(getScheme())
      .getDefaultPort();
  if (hostPort == defaultPort) {
    setHostPort(null);

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

@Override
protected void handleLocal(Request request, Response response,
    String decodedPath) {
  String scheme = request.getResourceRef().getScheme();
  if (scheme.equalsIgnoreCase(Protocol.CLAP.getSchemeName())) {
    LocalReference cr = new LocalReference(request.getResourceRef());
    ClassLoader classLoader = null;
      Object classLoaderAttribute = request.getAttributes().get(
          "org.restlet.clap.classLoader");

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

sb.append(httpCall.getProtocol().getSchemeName()).append("://");
sb.append(httpCall.getHostDomain());
if ((httpCall.getHostPort() != -1)
    && (httpCall.getHostPort() != httpCall.getProtocol().getDefaultPort())) {
  sb.append(':').append(httpCall.getHostPort());
  setResourceRef(new Reference(getHostRef(), httpCall.getRequestUri()));
  if (getResourceRef().isRelative()) {
      setResourceRef(new Reference(getHostRef().toString() + "/"
          + httpCall.getRequestUri()));
    } else {

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

String hostScheme = "";
if (request.getHostRef() != null) {
  hostDomain = request.getHostRef().getHostDomain();
  int basePortValue = request.getHostRef().getHostPort();
    basePortValue = request.getHostRef().getSchemeProtocol()
        .getDefaultPort();
          .getSchemeProtocol() != null) {
    resourcePortValue = request.getResourceRef()
        .getSchemeProtocol().getDefaultPort();
    serverPortValue = request.getProtocol().getDefaultPort();

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

client = new Client(new Context(),
      protocolsList);
client = new Client(new Context(), getProtocol(item
    .getNodeValue()));
    new Context(),
    protocol,
    getInt(portNode, protocol.getDefaultPort()),
    getServers().getTarget());
    new Reference(item.getNodeValue()));

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

final String scheme = request.getResourceRef().getScheme();
if (Protocol.RIAP.getSchemeName().equalsIgnoreCase(scheme)) {
  LocalReference ref = new LocalReference(request.getResourceRef());
        && RiapServerHelper.instance.getContext() != null
        && RiapServerHelper.instance.getContext()
            .getClientDispatcher() != null) {
      RiapServerHelper.instance.getContext()
          .getClientDispatcher().handle(request, response);
    } else {
      super.handle(request, response);

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

@Override
protected void handleLocal(Request request, Response response,
    String decodedPath) {
  String scheme = request.getResourceRef().getScheme();
  if (scheme.equalsIgnoreCase(Protocol.OBAP.getSchemeName())) {
    Bundle bundle = BUNDLE_CACHE.get(request.getResourceRef()
        .getAuthority());
    getLogger().fine(
        "Look for bundle "
            + request.getResourceRef().getAuthority());
    handleBundle(request, response, bundle);
  } else {
    throw new IllegalArgumentException(
        "Protocol \""
            + scheme
            + "\" not supported by the connector. Only OBAP is supported.");
  }
}

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

@Override
protected int doHandle(Request request, Response response) {
  int result = CONTINUE;
  Protocol protocol = request.getProtocol();
  if (protocol.equals(Protocol.RIAP)) {
    LocalReference cr = new LocalReference(request.getResourceRef());
    Component component = getComponent();
        request.getResourceRef().setBaseRef(
            request.getResourceRef().getHostIdentifier());
          request.getResourceRef().setBaseRef(
              request.getResourceRef().getHostIdentifier());

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

/**
   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    Client sdcClient = new Client(new Context(), Protocol.valueOf("SDC"));
    Series<Parameter> parameters = sdcClient.getContext().getParameters();
    parameters.add("keystorePath", "sdc.keystore");
    parameters.add("keystorePassword", "password");
    parameters.add("enabledCipherSuites", "TLS_RSA_WITH_AES_128_CBC_SHA");
    parameters.add("sslProtocol", "TLSv1");
    sdcClient.start();

    System.out
        .println("Press a key when the SDC agent is started and has established a tunnel...");
    System.in.read();

    Request request = new Request(Method.GET, "http://restlet.org");
    request.setProtocol(Protocol.valueOf("SDC"));
    request.setProxyChallengeResponse(new ChallengeResponse(ChallengeScheme
        .valueOf("SDC"), "myUser@example.com", "myPassword"));
    Response response = sdcClient.handle(request);
    response.getEntity().write(System.out);
  }
}

相关文章