com.linecorp.armeria.server.VirtualHost.hostnamePattern()方法的使用及代码示例

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

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

VirtualHost.hostnamePattern介绍

[英]Returns the hostname pattern of this virtual host, as defined in the section 3.1 of RFC2818.
[中]返回the section 3.1 of RFC2818中定义的此虚拟主机的主机名模式。

代码示例

代码示例来源:origin: line/armeria

@Override
  public String toString() {
    if (virtualHost != null) {
      return virtualHost.hostnamePattern() + ": " + pathMapping + " -> " + service;
    } else {
      return pathMapping + " -> " + service;
    }
  }
}

代码示例来源:origin: line/armeria

@Override
public ServiceSpecification generateSpecification(Set<ServiceConfig> serviceConfigs) {
  requireNonNull(serviceConfigs, "serviceConfigs");
  final Map<Class<?>, Set<MethodInfo>> methodInfos = new HashMap<>();
  final Map<Class<?>, String> serviceDescription = new HashMap<>();
  serviceConfigs.forEach(sc -> {
    final Optional<AnnotatedHttpService> service = sc.service().as(AnnotatedHttpService.class);
    service.ifPresent(
        httpService -> {
          addMethodInfo(methodInfos, sc.virtualHost().hostnamePattern(), httpService);
          addServiceDescription(serviceDescription, httpService);
        });
  });
  return generate(serviceDescription, methodInfos);
}

代码示例来源:origin: line/armeria

VirtualHost decorate(@Nullable Function<Service<HttpRequest, HttpResponse>,
                    Service<HttpRequest, HttpResponse>> decorator) {
  if (decorator == null) {
    return this;
  }
  final List<ServiceConfig> services =
      this.services.stream().map(cfg -> {
        final PathMapping pathMapping = cfg.pathMapping();
        final Service<HttpRequest, HttpResponse> service = decorator.apply(cfg.service());
        final String loggerName = cfg.loggerName().orElse(null);
        return new ServiceConfig(pathMapping, service, loggerName);
      }).collect(Collectors.toList());
  return new VirtualHost(defaultHostname(), hostnamePattern(), sslContext(),
              services, producibleMediaTypes());
}

代码示例来源:origin: line/armeria

@Override
public String toString() {
  String strVal = this.strVal;
  if (strVal == null) {
    this.strVal = strVal = toString(
        getClass(), defaultHostname(), hostnamePattern(), sslContext(), serviceConfigs());
  }
  return strVal;
}

代码示例来源:origin: line/armeria

mappingBuilder.add(h.hostnamePattern(), h);

代码示例来源:origin: line/armeria

@Override
public ServiceSpecification generateSpecification(Set<ServiceConfig> serviceConfigs) {
  final Map<Class<?>, EntryBuilder> map = new LinkedHashMap<>();
  for (ServiceConfig c : serviceConfigs) {
    final THttpService service = c.service().as(THttpService.class).get();
    service.entries().forEach((serviceName, entry) -> {
      for (Class<?> iface : entry.interfaces()) {
        final Class<?> serviceClass = iface.getEnclosingClass();
        final EntryBuilder builder =
            map.computeIfAbsent(serviceClass, cls -> new EntryBuilder(serviceClass));
        // Add all available endpoints. Accept only the services with exact and prefix path
        // mappings, whose endpoint path can be determined.
        final PathMapping pathMapping = c.pathMapping();
        final String path = pathMapping.exactPath().orElse(pathMapping.prefix().orElse(null));
        if (path != null) {
          builder.endpoint(new EndpointInfoBuilder(c.virtualHost().hostnamePattern(), path)
                       .fragment(serviceName)
                       .defaultFormat(service.defaultSerializationFormat())
                       .availableFormats(service.allowedSerializationFormats())
                       .build());
        }
      }
    });
  }
  final List<Entry> entries = map.values().stream()
                  .map(EntryBuilder::build)
                  .collect(Collectors.toList());
  return generate(entries);
}

代码示例来源:origin: line/armeria

if (!virtualHosts.isEmpty()) {
  virtualHosts.forEach(c -> {
    buf.append(VirtualHost.toString(null, c.defaultHostname(), c.hostnamePattern(),
                    c.sslContext(), c.serviceConfigs()));
    buf.append(", ");

代码示例来源:origin: line/armeria

vh.hostnamePattern());
vh.accessLogger(logger);
final SslContext sslCtx = h.sslContext();
if (sslCtx != null) {
  mappingBuilder.add(h.hostnamePattern(), sslCtx);

代码示例来源:origin: line/armeria

final String serviceName = service.getServiceDescriptor().getName();
map.get(serviceName).endpoint(
    new EndpointInfoBuilder(serviceConfig.virtualHost().hostnamePattern(),

代码示例来源:origin: line/armeria

private List<Tag> buildTags(RequestLog log) {
    final RequestContext ctx = log.context();
    final Object requestContent = log.requestContent();
    String methodName = null;
    if (requestContent instanceof RpcRequest) {
      methodName = ((RpcRequest) requestContent).method();
    }
    if (methodName == null) {
      final HttpHeaders requestHeaders = log.requestHeaders();
      final HttpMethod httpMethod = requestHeaders.method();
      if (httpMethod != null) {
        methodName = httpMethod.name();
      }
    }
    if (methodName == null) {
      methodName = MoreObjects.firstNonNull(log.method().name(), "__UNKNOWN_METHOD__");
    }
    final List<Tag> tags = new ArrayList<>(4); // method, hostNamePattern, pathMapping, status
    tags.add(Tag.of("method", methodName));
    if (ctx instanceof ServiceRequestContext) {
      final ServiceRequestContext sCtx = (ServiceRequestContext) ctx;
      tags.add(Tag.of("hostnamePattern", sCtx.virtualHost().hostnamePattern()));
      tags.add(Tag.of("pathMapping", sCtx.pathMapping().meterTag()));
    }
    return tags;
  }
};

代码示例来源:origin: line/armeria

@Override
public void serviceAdded(ServiceConfig cfg) throws Exception {
  checkState(server == null, "cannot be added to more than one server");
  server = cfg.server();
  router = Routers.ofCompositeService(services);
  final MeterRegistry registry = server.meterRegistry();
  final MeterIdPrefix meterIdPrefix =
      new MeterIdPrefix("armeria.server.router.compositeServiceCache",
               "hostnamePattern", cfg.virtualHost().hostnamePattern(),
               "pathMapping", cfg.pathMapping().meterTag());
  router.registerMetrics(registry, meterIdPrefix);
  for (CompositeServiceEntry<I, O> e : services()) {
    ServiceCallbackInvoker.invokeServiceAdded(cfg, e.service());
  }
}

代码示例来源:origin: line/armeria

@Override
public void serviceAdded(ServiceConfig cfg) throws Exception {
  final MeterRegistry registry = cfg.server().meterRegistry();
  if (cache != null) {
    CaffeineMetricSupport.setup(
        registry,
        new MeterIdPrefix("armeria.server.file.vfsCache",
                 "hostnamePattern", cfg.virtualHost().hostnamePattern(),
                 "pathMapping", cfg.pathMapping().meterTag(),
                 "vfs", config.vfs().meterTag()),
        cache);
  }
}

代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9-shaded

@Override
public ServiceSpecification generateSpecification(Set<ServiceConfig> serviceConfigs) {
  final Map<Class<?>, EntryBuilder> map = new LinkedHashMap<>();
  for (ServiceConfig c : serviceConfigs) {
    final THttpService service = c.service().as(THttpService.class).get();
    service.entries().forEach((serviceName, entry) -> {
      for (Class<?> iface : entry.interfaces()) {
        final Class<?> serviceClass = iface.getEnclosingClass();
        final EntryBuilder builder =
            map.computeIfAbsent(serviceClass, cls -> new EntryBuilder(serviceClass));
        // Add all available endpoints. Accept only the services with exact and prefix path
        // mappings, whose endpoint path can be determined.
        final PathMapping pathMapping = c.pathMapping();
        final String path = pathMapping.exactPath().orElse(pathMapping.prefix().orElse(null));
        if (path != null) {
          builder.endpoint(new EndpointInfo(
              c.virtualHost().hostnamePattern(),
              path, serviceName,
              service.defaultSerializationFormat(),
              service.allowedSerializationFormats()));
        }
      }
    });
  }
  final List<Entry> entries = map.values().stream()
                  .map(EntryBuilder::build)
                  .collect(Collectors.toList());
  return generate(entries);
}

代码示例来源:origin: com.linecorp.armeria/armeria-thrift

@Override
public ServiceSpecification generateSpecification(Set<ServiceConfig> serviceConfigs) {
  final Map<Class<?>, EntryBuilder> map = new LinkedHashMap<>();
  for (ServiceConfig c : serviceConfigs) {
    final THttpService service = c.service().as(THttpService.class).get();
    service.entries().forEach((serviceName, entry) -> {
      for (Class<?> iface : entry.interfaces()) {
        final Class<?> serviceClass = iface.getEnclosingClass();
        final EntryBuilder builder =
            map.computeIfAbsent(serviceClass, cls -> new EntryBuilder(serviceClass));
        // Add all available endpoints. Accept only the services with exact and prefix path
        // mappings, whose endpoint path can be determined.
        final PathMapping pathMapping = c.pathMapping();
        final String path = pathMapping.exactPath().orElse(pathMapping.prefix().orElse(null));
        if (path != null) {
          builder.endpoint(new EndpointInfoBuilder(c.virtualHost().hostnamePattern(), path)
                       .fragment(serviceName)
                       .defaultFormat(service.defaultSerializationFormat())
                       .availableFormats(service.allowedSerializationFormats())
                       .build());
        }
      }
    });
  }
  final List<Entry> entries = map.values().stream()
                  .map(EntryBuilder::build)
                  .collect(Collectors.toList());
  return generate(entries);
}

代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9

@Override
public ServiceSpecification generateSpecification(Set<ServiceConfig> serviceConfigs) {
  final Map<Class<?>, EntryBuilder> map = new LinkedHashMap<>();
  for (ServiceConfig c : serviceConfigs) {
    final THttpService service = c.service().as(THttpService.class).get();
    service.entries().forEach((serviceName, entry) -> {
      for (Class<?> iface : entry.interfaces()) {
        final Class<?> serviceClass = iface.getEnclosingClass();
        final EntryBuilder builder =
            map.computeIfAbsent(serviceClass, cls -> new EntryBuilder(serviceClass));
        // Add all available endpoints. Accept only the services with exact and prefix path
        // mappings, whose endpoint path can be determined.
        final PathMapping pathMapping = c.pathMapping();
        final String path = pathMapping.exactPath().orElse(pathMapping.prefix().orElse(null));
        if (path != null) {
          builder.endpoint(new EndpointInfoBuilder(c.virtualHost().hostnamePattern(), path)
                       .fragment(serviceName)
                       .defaultFormat(service.defaultSerializationFormat())
                       .availableFormats(service.allowedSerializationFormats())
                       .build());
        }
      }
    });
  }
  final List<Entry> entries = map.values().stream()
                  .map(EntryBuilder::build)
                  .collect(Collectors.toList());
  return generate(entries);
}

代码示例来源:origin: com.linecorp.armeria/armeria-grpc

final String serviceName = service.getServiceDescriptor().getName();
map.get(serviceName).endpoint(
    new EndpointInfoBuilder(serviceConfig.virtualHost().hostnamePattern(),

相关文章