VirtualHostBuilder { public VirtualHostBuilder hostnamePattern(String hostnamePattern) { if (defaultVirtualHost) { throw new UnsupportedOperationException( "Cannot set hostnamePattern for the default virtual host builder"); } checkArgument(!hostnamePattern.isEmpty(), "hostnamePattern is empty."); final boolean validHostnamePattern; if (hostnamePattern.charAt(0) == '*') { validHostnamePattern = hostnamePattern.length() >= 3 && hostnamePattern.charAt(1) == '.' && HOSTNAME_PATTERN.matcher(hostnamePattern.substring(2)).matches(); } else { validHostnamePattern = HOSTNAME_PATTERN.matcher(hostnamePattern).matches(); } checkArgument(validHostnamePattern, "hostnamePattern: %s (expected: *.<hostname> or <hostname>)", hostnamePattern); this.hostnamePattern = normalizeHostnamePattern(hostnamePattern); return this; } VirtualHostBuilder(ServerBuilder serverBuilder, boolean defaultVirtualHost); ServerBuilder and(); VirtualHostBuilder defaultHostname(String defaultHostname); VirtualHostBuilder hostnamePattern(String hostnamePattern); VirtualHostBuilder tls(File keyCertChainFile, File keyFile); VirtualHostBuilder tls(File keyCertChainFile, File keyFile, @Nullable String keyPassword); VirtualHostBuilder tls(InputStream keyCertChainInputStream, InputStream keyInputStream); VirtualHostBuilder tls(InputStream keyCertChainInputStream, InputStream keyInputStream,
                                  @Nullable String keyPassword); VirtualHostBuilder tls(PrivateKey key, X509Certificate... keyCertChain); VirtualHostBuilder tls(PrivateKey key, Iterable<? extends X509Certificate> keyCertChain); VirtualHostBuilder tls(PrivateKey key, @Nullable String keyPassword,
                                  X509Certificate... keyCertChain); VirtualHostBuilder tls(PrivateKey key, @Nullable String keyPassword,
                                  Iterable<? extends X509Certificate> keyCertChain); VirtualHostBuilder tls(KeyManagerFactory keyManagerFactory); VirtualHostBuilder tlsSelfSigned(); VirtualHostBuilder tlsSelfSigned(boolean tlsSelfSigned); VirtualHostBuilder tlsCustomizer(Consumer<? super SslContextBuilder> tlsCustomizer); VirtualHostBuilder withRoute(Consumer<? super VirtualHostServiceBindingBuilder> customizer); VirtualHostServiceBindingBuilder route(); VirtualHostDecoratingServiceBindingBuilder routeDecorator(); VirtualHostBuilder serviceUnder(String pathPrefix, HttpService service); VirtualHostBuilder service(String pathPattern, HttpService service); VirtualHostBuilder service(Route route, HttpService service); VirtualHostBuilder service(
            HttpServiceWithRoutes serviceWithRoutes,
            Iterable<? extends Function<? super HttpService, ? extends HttpService>> decorators); @SafeVarargs final VirtualHostBuilder service(
            HttpServiceWithRoutes serviceWithRoutes,
            Function<? super HttpService, ? extends HttpService>... decorators); VirtualHostBuilder annotatedService(Object service); VirtualHostBuilder annotatedService(Object service,
                                               Object... exceptionHandlersAndConverters); VirtualHostBuilder annotatedService(
            Object service, Function<? super HttpService, ? extends HttpService> decorator,
            Object... exceptionHandlersAndConverters); VirtualHostBuilder annotatedService(String pathPrefix, Object service); VirtualHostBuilder annotatedService(String pathPrefix, Object service,
                                               Object... exceptionHandlersAndConverters); VirtualHostBuilder annotatedService(String pathPrefix, Object service,
                                               Iterable<?> exceptionHandlersAndConverters); VirtualHostBuilder annotatedService(
            String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator,
            Object... exceptionHandlersAndConverters); VirtualHostBuilder annotatedService(String pathPrefix, Object service,
                                               Function<? super HttpService, ? extends HttpService> decorator,
                                               Iterable<?> exceptionHandlersAndConverters); VirtualHostBuilder annotatedService(
            String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator,
            Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions,
            Iterable<? extends RequestConverterFunction> requestConverterFunctions,
            Iterable<? extends ResponseConverterFunction> responseConverterFunctions); VirtualHostAnnotatedServiceBindingBuilder annotatedService(); VirtualHostBuilder decorator(Function<? super HttpService, ? extends HttpService> decorator); VirtualHostBuilder decorator(
            DecoratingHttpServiceFunction decoratingHttpServiceFunction); VirtualHostBuilder decorator(
            String pathPattern, DecoratingHttpServiceFunction decoratingHttpServiceFunction); VirtualHostBuilder decorator(
            String pathPattern, Function<? super HttpService, ? extends HttpService> decorator); VirtualHostBuilder decorator(
            Route route, Function<? super HttpService, ? extends HttpService> decorator); VirtualHostBuilder decorator(
            Route route, DecoratingHttpServiceFunction decoratingHttpServiceFunction); VirtualHostBuilder decoratorUnder(
            String prefix, Function<? super HttpService, ? extends HttpService> decorator); VirtualHostBuilder decoratorUnder(
            String prefix, DecoratingHttpServiceFunction decoratingHttpServiceFunction); VirtualHostBuilder accessLogger(Function<? super VirtualHost, ? extends Logger> mapper); VirtualHostBuilder accessLogger(Logger logger); VirtualHostBuilder accessLogger(String loggerName); VirtualHostBuilder rejectedRouteHandler(RejectedRouteHandler handler); VirtualHostBuilder requestTimeout(Duration requestTimeout); VirtualHostBuilder requestTimeoutMillis(long requestTimeoutMillis); VirtualHostBuilder maxRequestLength(long maxRequestLength); VirtualHostBuilder verboseResponses(boolean verboseResponses); VirtualHostBuilder accessLogWriter(AccessLogWriter accessLogWriter, boolean shutdownOnStop); VirtualHostBuilder annotatedServiceExtensions(
            Iterable<? extends RequestConverterFunction> requestConverterFunctions,
            Iterable<? extends ResponseConverterFunction> responseConverterFunctions,
            Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions); @Override String toString();  }
@Test void hostnamePatternCannotBeSetForDefaultBuilder() { final ServerBuilder sb = Server.builder(); assertThatThrownBy(() -> sb.defaultVirtualHost().hostnamePattern("CannotSet")) .isInstanceOf(UnsupportedOperationException.class); }
@Test void hostnamePatternCannotBeSetForDefaultBuilder2() { final ServerBuilder sb = Server.builder(); assertThatThrownBy(() -> sb.withDefaultVirtualHost(builder -> builder.hostnamePattern("CannotSet"))) .isInstanceOf(UnsupportedOperationException.class); }