javax.websocket.Extension类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(211)

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

Extension介绍

[英]A simple representation of a websocket extension as a name and map of extension parameters.
[中]websocket扩展的简单表示形式,即扩展参数的名称和映射。

代码示例

代码示例来源:origin: spring-projects/spring-framework

public StandardToWebSocketExtensionAdapter(Extension extension) {
  super(extension.getName(), initParameters(extension));
}

代码示例来源:origin: spring-projects/spring-framework

private static Map<String, String> initParameters(Extension extension) {
  List<Extension.Parameter> parameters = extension.getParameters();
  Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
  for (Extension.Parameter parameter : parameters) {
    result.put(parameter.getName(), parameter.getValue());
  }
  return result;
}

代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket

private static void append(StringBuilder sb, Extension extension) {
  if (extension == null || extension.getName() == null || extension.getName().length() == 0) {
    return;
  }
  sb.append(extension.getName());
  for (Extension.Parameter p : extension.getParameters()) {
    sb.append(';');
    sb.append(p.getName());
    if (p.getValue() != null) {
      sb.append('=');
      sb.append(p.getValue());
    }
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

private static void append(StringBuilder sb, Extension extension) {
  if (extension == null || extension.getName() == null || extension.getName().length() == 0) {
    return;
  }
  sb.append(extension.getName());
  for (Extension.Parameter p : extension.getParameters()) {
    sb.append(';');
    sb.append(p.getName());
    if (p.getValue() != null) {
      sb.append('=');
      sb.append(p.getValue());
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat7-websocket

private static void append(StringBuilder sb, Extension extension) {
  if (extension == null || extension.getName() == null || extension.getName().length() == 0) {
    return;
  }
  sb.append(extension.getName());
  for (Extension.Parameter p : extension.getParameters()) {
    sb.append(';');
    sb.append(p.getName());
    if (p.getValue() != null) {
      sb.append('=');
      sb.append(p.getValue());
    }
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

@Override
public List<Extension> getNegotiatedExtensions(List<Extension> installed,
    List<Extension> requested) {
  Set<String> installedNames = new HashSet<String>();
  for (Extension e : installed) {
    installedNames.add(e.getName());
  }
  List<Extension> result = new ArrayList<Extension>();
  for (Extension request : requested) {
    if (installedNames.contains(request.getName())) {
      result.add(request);
    }
  }
  return result;
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

/**
 * {@inheritDoc}
 * <p/>
 * Please note the TODO. {@link
 * ExtendedExtension#onExtensionNegotiation(ExtensionContext, List)}
 */
@Override
public List<Parameter> onExtensionNegotiation(ExtensionContext context,
                       List<Parameter> requestedParameters) {
  return extendedExtension
      .onExtensionNegotiation(context, requestedExtension.getParameters());
}

代码示例来源:origin: org.apache.tomcat/tomcat-websocket

private static void append(StringBuilder sb, Extension extension) {
  if (extension == null || extension.getName() == null || extension.getName().length() == 0) {
    return;
  }
  sb.append(extension.getName());
  for (Extension.Parameter p : extension.getParameters()) {
    sb.append(';');
    sb.append(p.getName());
    if (p.getValue() != null) {
      sb.append('=');
      sb.append(p.getValue());
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-websocket

@Override
public List<Extension> getNegotiatedExtensions(List<Extension> installed,
    List<Extension> requested) {
  Set<String> installedNames = new HashSet<>();
  for (Extension e : installed) {
    installedNames.add(e.getName());
  }
  List<Extension> result = new ArrayList<>();
  for (Extension request : requested) {
    if (installedNames.contains(request.getName())) {
      result.add(request);
    }
  }
  return result;
}

代码示例来源:origin: eclipse-ee4j/tyrus

/**
 * {@inheritDoc}
 * <p/>
 * Please note the TODO. {@link
 * ExtendedExtension#onExtensionNegotiation(ExtensionContext, List)}
 */
@Override
public List<Parameter> onExtensionNegotiation(ExtensionContext context,
                       List<Parameter> requestedParameters) {
  return extendedExtension
      .onExtensionNegotiation(context, requestedExtension.getParameters());
}

代码示例来源:origin: Red5/red5-plugins

private static void append(StringBuilder sb, Extension extension) {
  if (extension == null || extension.getName() == null || extension.getName().length() == 0) {
    return;
  }
  sb.append(extension.getName());
  for (Extension.Parameter p : extension.getParameters()) {
    sb.append(';');
    sb.append(p.getName());
    if (p.getValue() != null) {
      sb.append('=');
      sb.append(p.getValue());
    }
  }
}

代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket

@Override
public List<Extension> getNegotiatedExtensions(List<Extension> installed,
    List<Extension> requested) {
  Set<String> installedNames = new HashSet<>();
  for (Extension e : installed) {
    installedNames.add(e.getName());
  }
  List<Extension> result = new ArrayList<>();
  for (Extension request : requested) {
    if (installedNames.contains(request.getName())) {
      result.add(request);
    }
  }
  return result;
}

代码示例来源:origin: org.springframework/spring-websocket

private static Map<String, String> initParameters(Extension extension) {
  List<Extension.Parameter> parameters = extension.getParameters();
  Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
  for (Extension.Parameter parameter : parameters) {
    result.put(parameter.getName(), parameter.getValue());
  }
  return result;
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

/**
 * Returns defined representation for HTTP headers.
 *
 * @param extension {@link Extension} instance.
 * @return String containing {@link Extension} representation as defined in RFC 6455.
 */
static String toString(Extension extension) {
  final StringBuilder sb = new StringBuilder();
  sb.append(extension.getName());
  final List<Parameter> extensionParameters = extension.getParameters();
  if (extensionParameters != null && !extensionParameters.isEmpty()) {
    for (Extension.Parameter p : extensionParameters) {
      sb.append("; ");
      sb.append(TyrusParameter.toString(p));
    }
  }
  return sb.toString();
}

代码示例来源:origin: org.apache.tomcat/tomcat7-websocket

@Override
public List<Extension> getNegotiatedExtensions(List<Extension> installed,
    List<Extension> requested) {
  Set<String> installedNames = new HashSet<String>();
  for (Extension e : installed) {
    installedNames.add(e.getName());
  }
  List<Extension> result = new ArrayList<Extension>();
  for (Extension request : requested) {
    if (installedNames.contains(request.getName())) {
      result.add(request);
    }
  }
  return result;
}

代码示例来源:origin: apache/servicemix-bundles

private static Map<String, String> initParameters(Extension extension) {
  List<Extension.Parameter> parameters = extension.getParameters();
  Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
  for (Extension.Parameter parameter : parameters) {
    result.put(parameter.getName(), parameter.getValue());
  }
  return result;
}

代码示例来源:origin: eclipse-ee4j/tyrus

/**
 * Returns defined representation for HTTP headers.
 *
 * @param extension {@link Extension} instance.
 * @return String containing {@link Extension} representation as defined in RFC 6455.
 */
static String toString(Extension extension) {
  final StringBuilder sb = new StringBuilder();
  sb.append(extension.getName());
  final List<Parameter> extensionParameters = extension.getParameters();
  if (extensionParameters != null && !extensionParameters.isEmpty()) {
    for (Extension.Parameter p : extensionParameters) {
      sb.append("; ");
      sb.append(TyrusParameter.toString(p));
    }
  }
  return sb.toString();
}

代码示例来源:origin: Red5/red5-plugins

@Override
public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) {
  log.debug("getNegotiatedExtensions - installed: {} requested: {}", installed, requested);
  Set<String> installedNames = new HashSet<>();
  for (Extension e : installed) {
    installedNames.add(e.getName());
  }
  List<Extension> result = new ArrayList<>();
  for (Extension request : requested) {
    if (installedNames.contains(request.getName())) {
      result.add(request);
    }
  }
  return result;
}

代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket

@Override
public Extension getExtensionResponse() {
  Extension result = new WsExtension(NAME);
  List<Extension.Parameter> params = result.getParameters();
  if (!serverContextTakeover) {
    params.add(new WsExtensionParameter(SERVER_NO_CONTEXT_TAKEOVER, null));
  }
  if (serverMaxWindowBits != -1) {
    params.add(new WsExtensionParameter(SERVER_MAX_WINDOW_BITS,
        Integer.toString(serverMaxWindowBits)));
  }
  if (!clientContextTakeover) {
    params.add(new WsExtensionParameter(CLIENT_NO_CONTEXT_TAKEOVER, null));
  }
  if (clientMaxWindowBits != -1) {
    params.add(new WsExtensionParameter(CLIENT_MAX_WINDOW_BITS,
        Integer.toString(clientMaxWindowBits)));
  }
  return result;
}

代码示例来源:origin: org.apache.tomcat/tomcat7-websocket

private static List<String> generateExtensionHeaders(List<Extension> extensions) {
  List<String> result = new ArrayList<String>(extensions.size());
  for (Extension extension : extensions) {
    StringBuilder header = new StringBuilder();
    header.append(extension.getName());
    for (Extension.Parameter param : extension.getParameters()) {
      header.append(';');
      header.append(param.getName());
      String value = param.getValue();
      if (value != null && value.length() > 0) {
        header.append('=');
        header.append(value);
      }
    }
    result.add(header.toString());
  }
  return result;
}

相关文章