public final class VirtualHostBuilder extends Object
VirtualHost.
This class can only be instantiated through the ServerBuilder.defaultVirtualHost() or
ServerBuilder.virtualHost(String) method of the ServerBuilder.
Call and() method and return to ServerBuilder.
ServerBuilder,
Route| Modifier and Type | Method and Description |
|---|---|
VirtualHostBuilder |
accessLogger(Function<? super VirtualHost,? extends org.slf4j.Logger> mapper)
Sets the access logger mapper of this
VirtualHost. |
VirtualHostBuilder |
accessLogger(org.slf4j.Logger logger)
Sets the
Logger of this VirtualHost, which is used for writing access logs. |
VirtualHostBuilder |
accessLogger(String loggerName)
|
VirtualHostBuilder |
accessLogWriter(AccessLogWriter accessLogWriter,
boolean shutdownOnStop)
Sets the access log writer of this
VirtualHost. |
ServerBuilder |
and()
Returns the parent
ServerBuilder. |
VirtualHostAnnotatedServiceBindingBuilder |
annotatedService()
Returns a new instance of
VirtualHostAnnotatedServiceBindingBuilder to build
an annotated service fluently. |
VirtualHostBuilder |
annotatedService(Object service)
Binds the specified annotated service object under the path prefix
"/". |
VirtualHostBuilder |
annotatedService(Object service,
Function<? super HttpService,? extends HttpService> decorator,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the path prefix
"/". |
VirtualHostBuilder |
annotatedService(Object service,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the path prefix
"/". |
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Function<? super HttpService,? extends HttpService> decorator,
Iterable<?> exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Function<? super HttpService,? extends HttpService> decorator,
Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions,
Iterable<? extends RequestConverterFunction> requestConverterFunctions,
Iterable<? extends ResponseConverterFunction> responseConverterFunctions)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Function<? super HttpService,? extends HttpService> decorator,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Iterable<?> exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedServiceExtensions(Iterable<? extends RequestConverterFunction> requestConverterFunctions,
Iterable<? extends ResponseConverterFunction> responseConverterFunctions,
Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions)
Sets the
RequestConverterFunctions, ResponseConverterFunction
and ExceptionHandlerFunctions for creating an AnnotatedServiceExtensions. |
VirtualHostBuilder |
decorator(DecoratingHttpServiceFunction decoratingHttpServiceFunction)
Decorates all
HttpServices with the specified DecoratingHttpServiceFunction. |
VirtualHostBuilder |
decorator(Function<? super HttpService,? extends HttpService> decorator)
Decorates all
HttpServices with the specified decorator. |
VirtualHostBuilder |
decorator(Route route,
DecoratingHttpServiceFunction decoratingHttpServiceFunction)
|
VirtualHostBuilder |
decorator(Route route,
Function<? super HttpService,? extends HttpService> decorator)
|
VirtualHostBuilder |
decorator(String pathPattern,
DecoratingHttpServiceFunction decoratingHttpServiceFunction)
|
VirtualHostBuilder |
decorator(String pathPattern,
Function<? super HttpService,? extends HttpService> decorator)
|
VirtualHostBuilder |
decoratorUnder(String prefix,
DecoratingHttpServiceFunction decoratingHttpServiceFunction)
Decorates
HttpServices under the specified directory. |
VirtualHostBuilder |
decoratorUnder(String prefix,
Function<? super HttpService,? extends HttpService> decorator)
Decorates
HttpServices under the specified directory. |
VirtualHostBuilder |
defaultHostname(String defaultHostname)
Sets the default hostname of this
VirtualHost. |
VirtualHostBuilder |
hostnamePattern(String hostnamePattern)
Sets the hostname pattern of this
VirtualHost. |
VirtualHostBuilder |
maxRequestLength(long maxRequestLength)
Sets the maximum allowed length of the content decoded at the session layer.
|
VirtualHostBuilder |
rejectedRouteHandler(RejectedRouteHandler handler)
Sets the
RejectedRouteHandler which will be invoked when an attempt to bind
an HttpService at a certain Route is rejected. |
VirtualHostBuilder |
requestTimeout(Duration requestTimeout)
Sets the timeout of a request.
|
VirtualHostBuilder |
requestTimeoutMillis(long requestTimeoutMillis)
Sets the timeout of a request in milliseconds.
|
VirtualHostServiceBindingBuilder |
route()
Returns a
ServiceBindingBuilder which is for binding an HttpService fluently. |
VirtualHostDecoratingServiceBindingBuilder |
routeDecorator()
Returns a
VirtualHostDecoratingServiceBindingBuilder which is for binding
a decorator fluently. |
VirtualHostBuilder |
service(HttpServiceWithRoutes serviceWithRoutes,
Function<? super HttpService,? extends HttpService>... decorators)
Decorates and binds the specified
HttpServiceWithRoutes at multiple Routes
of the default VirtualHost. |
VirtualHostBuilder |
service(HttpServiceWithRoutes serviceWithRoutes,
Iterable<? extends Function<? super HttpService,? extends HttpService>> decorators)
Decorates and binds the specified
HttpServiceWithRoutes at multiple Routes
of the default VirtualHost. |
VirtualHostBuilder |
service(Route route,
HttpService service)
Binds the specified
HttpService at the specified Route. |
VirtualHostBuilder |
service(String pathPattern,
HttpService service)
Binds the specified
HttpService at the specified path pattern. e.g. |
VirtualHostBuilder |
serviceAt(String pathPattern,
HttpService service)
Deprecated.
Use
service(String, HttpService) instead. |
VirtualHostBuilder |
serviceUnder(String pathPrefix,
HttpService service)
Binds the specified
HttpService under the specified directory. |
VirtualHostBuilder |
tls(File keyCertChainFile,
File keyFile)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainFile
and cleartext keyFile. |
VirtualHostBuilder |
tls(File keyCertChainFile,
File keyFile,
Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
Deprecated.
Use
tls(File, File) and tlsCustomizer(Consumer). |
VirtualHostBuilder |
tls(File keyCertChainFile,
File keyFile,
String keyPassword)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainFile,
keyFile and keyPassword. |
VirtualHostBuilder |
tls(File keyCertChainFile,
File keyFile,
String keyPassword,
Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
Deprecated.
|
VirtualHostBuilder |
tls(InputStream keyCertChainInputStream,
InputStream keyInputStream)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainInputStream and
cleartext keyInputStream. |
VirtualHostBuilder |
tls(InputStream keyCertChainInputStream,
InputStream keyInputStream,
String keyPassword)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainInputStream,
keyInputStream and keyPassword. |
VirtualHostBuilder |
tls(KeyManagerFactory keyManagerFactory)
Configures SSL or TLS of this
VirtualHost with the specified KeyManagerFactory. |
VirtualHostBuilder |
tls(KeyManagerFactory keyManagerFactory,
Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
Deprecated.
|
VirtualHostBuilder |
tls(PrivateKey key,
Iterable<? extends X509Certificate> keyCertChain)
Configures SSL or TLS of this
VirtualHost with the specified cleartext PrivateKey and
X509Certificate chain. |
VirtualHostBuilder |
tls(PrivateKey key,
String keyPassword,
Iterable<? extends X509Certificate> keyCertChain)
Configures SSL or TLS of this
VirtualHost with the specified cleartext PrivateKey,
keyPassword and X509Certificate chain. |
VirtualHostBuilder |
tls(PrivateKey key,
String keyPassword,
X509Certificate... keyCertChain)
Configures SSL or TLS of this
VirtualHost with the specified cleartext PrivateKey,
keyPassword and X509Certificate chain. |
VirtualHostBuilder |
tls(PrivateKey key,
X509Certificate... keyCertChain)
Configures SSL or TLS of this
VirtualHost with the specified cleartext PrivateKey and
X509Certificate chain. |
VirtualHostBuilder |
tls(io.netty.handler.ssl.SslContext sslContext)
Deprecated.
This unsafe method has been deprecated because an incorrectly built
SslContext
can cause a Server to malfunction. Use other tls() methods. |
VirtualHostBuilder |
tlsCustomizer(Consumer<? super io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
Adds the
Consumer which can arbitrarily configure the SslContextBuilder that will be
applied to the SSL session. |
VirtualHostBuilder |
tlsSelfSigned()
Configures SSL or TLS of this
VirtualHost with an auto-generated self-signed certificate. |
VirtualHostBuilder |
tlsSelfSigned(boolean tlsSelfSigned)
Configures SSL or TLS of this
VirtualHost with an auto-generated self-signed certificate. |
String |
toString() |
VirtualHostBuilder |
verboseResponses(boolean verboseResponses)
Sets whether the verbose response mode is enabled.
|
VirtualHostBuilder |
withRoute(Consumer<? super VirtualHostServiceBindingBuilder> customizer)
|
public ServerBuilder and()
ServerBuilder.ServerBuilder.public VirtualHostBuilder defaultHostname(String defaultHostname)
VirtualHost.public VirtualHostBuilder hostnamePattern(String hostnamePattern)
VirtualHost.UnsupportedOperationException - if this is the default VirtualHostBuilder@Deprecated public VirtualHostBuilder tls(io.netty.handler.ssl.SslContext sslContext)
SslContext
can cause a Server to malfunction. Use other tls() methods.VirtualHost with the specified SslContext.public VirtualHostBuilder tls(File keyCertChainFile, File keyFile)
VirtualHost with the specified keyCertChainFile
and cleartext keyFile.tlsCustomizer(Consumer)@Deprecated public VirtualHostBuilder tls(File keyCertChainFile, File keyFile, Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
tls(File, File) and tlsCustomizer(Consumer).VirtualHost with the specified keyCertChainFile,
cleartext keyFile and tlsCustomizer.public VirtualHostBuilder tls(File keyCertChainFile, File keyFile, String keyPassword)
VirtualHost with the specified keyCertChainFile,
keyFile and keyPassword.tlsCustomizer(Consumer)@Deprecated public VirtualHostBuilder tls(File keyCertChainFile, File keyFile, String keyPassword, Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
tls(File, File, String) and tlsCustomizer(Consumer).VirtualHost with the specified keyCertChainFile,
keyFile, keyPassword and tlsCustomizer.public VirtualHostBuilder tls(InputStream keyCertChainInputStream, InputStream keyInputStream)
VirtualHost with the specified keyCertChainInputStream and
cleartext keyInputStream.tlsCustomizer(Consumer)public VirtualHostBuilder tls(InputStream keyCertChainInputStream, InputStream keyInputStream, String keyPassword)
VirtualHost with the specified keyCertChainInputStream,
keyInputStream and keyPassword.tlsCustomizer(Consumer)public VirtualHostBuilder tls(PrivateKey key, X509Certificate... keyCertChain)
VirtualHost with the specified cleartext PrivateKey and
X509Certificate chain.tlsCustomizer(Consumer)public VirtualHostBuilder tls(PrivateKey key, Iterable<? extends X509Certificate> keyCertChain)
VirtualHost with the specified cleartext PrivateKey and
X509Certificate chain.tlsCustomizer(Consumer)public VirtualHostBuilder tls(PrivateKey key, String keyPassword, X509Certificate... keyCertChain)
VirtualHost with the specified cleartext PrivateKey,
keyPassword and X509Certificate chain.tlsCustomizer(Consumer)public VirtualHostBuilder tls(PrivateKey key, String keyPassword, Iterable<? extends X509Certificate> keyCertChain)
VirtualHost with the specified cleartext PrivateKey,
keyPassword and X509Certificate chain.tlsCustomizer(Consumer)public VirtualHostBuilder tls(KeyManagerFactory keyManagerFactory)
VirtualHost with the specified KeyManagerFactory.tlsCustomizer(Consumer)@Deprecated public VirtualHostBuilder tls(KeyManagerFactory keyManagerFactory, Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
tls(KeyManagerFactory) and tlsCustomizer(Consumer).public VirtualHostBuilder tlsSelfSigned()
VirtualHost with an auto-generated self-signed certificate.
Note: You should never use this in production but only for a testing purpose.tlsCustomizer(Consumer)public VirtualHostBuilder tlsSelfSigned(boolean tlsSelfSigned)
VirtualHost with an auto-generated self-signed certificate.
Note: You should never use this in production but only for a testing purpose.tlsCustomizer(Consumer)public VirtualHostBuilder tlsCustomizer(Consumer<? super io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
Consumer which can arbitrarily configure the SslContextBuilder that will be
applied to the SSL session.public VirtualHostBuilder withRoute(Consumer<? super VirtualHostServiceBindingBuilder> customizer)
public VirtualHostServiceBindingBuilder route()
ServiceBindingBuilder which is for binding an HttpService fluently.public VirtualHostDecoratingServiceBindingBuilder routeDecorator()
VirtualHostDecoratingServiceBindingBuilder which is for binding
a decorator fluently.@Deprecated public VirtualHostBuilder serviceAt(String pathPattern, HttpService service)
service(String, HttpService) instead.HttpService at the specified path pattern.public VirtualHostBuilder serviceUnder(String pathPrefix, HttpService service)
HttpService under the specified directory.public VirtualHostBuilder service(String pathPattern, HttpService service)
HttpService at the specified path pattern. e.g.
/login (no path parameters)/users/{userId} (curly-brace style)/list/:productType/by/:ordering (colon style)exact:/foo/bar (exact match)prefix:/files (prefix match)glob:/~*/downloads/** (glob pattern)regex:^/files/(?<filePath>.*)$ (regular expression)IllegalArgumentException - if the specified path pattern is invalidpublic VirtualHostBuilder service(Route route, HttpService service)
HttpService at the specified Route.public VirtualHostBuilder service(HttpServiceWithRoutes serviceWithRoutes, Iterable<? extends Function<? super HttpService,? extends HttpService>> decorators)
HttpServiceWithRoutes at multiple Routes
of the default VirtualHost.serviceWithRoutes - the HttpServiceWithRoutes.decorators - the decorator functions, which will be applied in the order specified.@SafeVarargs public final VirtualHostBuilder service(HttpServiceWithRoutes serviceWithRoutes, Function<? super HttpService,? extends HttpService>... decorators)
HttpServiceWithRoutes at multiple Routes
of the default VirtualHost.serviceWithRoutes - the HttpServiceWithRoutes.decorators - the decorator functions, which will be applied in the order specified.public VirtualHostBuilder annotatedService(Object service)
"/".public VirtualHostBuilder annotatedService(Object service, Object... exceptionHandlersAndConverters)
"/".exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(Object service, Function<? super HttpService,? extends HttpService> decorator, Object... exceptionHandlersAndConverters)
"/".exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(String pathPrefix, Object service)
public VirtualHostBuilder annotatedService(String pathPrefix, Object service, Object... exceptionHandlersAndConverters)
exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(String pathPrefix, Object service, Iterable<?> exceptionHandlersAndConverters)
exceptionHandlersAndConverters - the ExceptionHandlerFunction,
RequestConverterFunction and/or
ResponseConverterFunctionpublic VirtualHostBuilder annotatedService(String pathPrefix, Object service, Function<? super HttpService,? extends HttpService> decorator, Object... exceptionHandlersAndConverters)
exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(String pathPrefix, Object service, Function<? super HttpService,? extends HttpService> decorator, Iterable<?> exceptionHandlersAndConverters)
exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(String pathPrefix, Object service, Function<? super HttpService,? extends HttpService> decorator, Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions, Iterable<? extends RequestConverterFunction> requestConverterFunctions, Iterable<? extends ResponseConverterFunction> responseConverterFunctions)
exceptionHandlerFunctions - the ExceptionHandlerFunctionsrequestConverterFunctions - the RequestConverterFunctionsresponseConverterFunctions - the ResponseConverterFunctionspublic VirtualHostAnnotatedServiceBindingBuilder annotatedService()
VirtualHostAnnotatedServiceBindingBuilder to build
an annotated service fluently.public VirtualHostBuilder decorator(Function<? super HttpService,? extends HttpService> decorator)
HttpServices with the specified decorator.decorator - the Function that decorates HttpServicespublic VirtualHostBuilder decorator(DecoratingHttpServiceFunction decoratingHttpServiceFunction)
HttpServices with the specified DecoratingHttpServiceFunction.decoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServicespublic VirtualHostBuilder decorator(String pathPattern, DecoratingHttpServiceFunction decoratingHttpServiceFunction)
decoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServicespublic VirtualHostBuilder decorator(String pathPattern, Function<? super HttpService,? extends HttpService> decorator)
public VirtualHostBuilder decorator(Route route, Function<? super HttpService,? extends HttpService> decorator)
route - the route being decorateddecorator - the Function that decorates HttpServicepublic VirtualHostBuilder decorator(Route route, DecoratingHttpServiceFunction decoratingHttpServiceFunction)
route - the route being decorateddecoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServicespublic VirtualHostBuilder decoratorUnder(String prefix, Function<? super HttpService,? extends HttpService> decorator)
HttpServices under the specified directory.public VirtualHostBuilder decoratorUnder(String prefix, DecoratingHttpServiceFunction decoratingHttpServiceFunction)
HttpServices under the specified directory.decoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServicespublic VirtualHostBuilder accessLogger(Function<? super VirtualHost,? extends org.slf4j.Logger> mapper)
VirtualHost.public VirtualHostBuilder accessLogger(org.slf4j.Logger logger)
Logger of this VirtualHost, which is used for writing access logs.public VirtualHostBuilder accessLogger(String loggerName)
public VirtualHostBuilder rejectedRouteHandler(RejectedRouteHandler handler)
RejectedRouteHandler which will be invoked when an attempt to bind
an HttpService at a certain Route is rejected. If not set,
the RejectedRouteHandler set via
ServerBuilder.rejectedRouteHandler(RejectedRouteHandler) is used.public VirtualHostBuilder requestTimeout(Duration requestTimeout)
ServerBuilder.requestTimeoutMillis(long) is used.requestTimeout - the timeout. 0 disables the timeout.public VirtualHostBuilder requestTimeoutMillis(long requestTimeoutMillis)
ServerBuilder.requestTimeoutMillis(long) is used.requestTimeoutMillis - the timeout in milliseconds. 0 disables the timeout.public VirtualHostBuilder maxRequestLength(long maxRequestLength)
ServerBuilder.maxRequestLength(long) is used.maxRequestLength - the maximum allowed length. 0 disables the length limit.public VirtualHostBuilder verboseResponses(boolean verboseResponses)
ServerBuilder.verboseResponses(boolean) is used.public VirtualHostBuilder accessLogWriter(AccessLogWriter accessLogWriter, boolean shutdownOnStop)
VirtualHost. If not set, the AccessLogWriter set via
ServerBuilder.accessLogWriter(AccessLogWriter, boolean) is used.shutdownOnStop - whether to shut down the AccessLogWriter when the Server stopspublic VirtualHostBuilder annotatedServiceExtensions(Iterable<? extends RequestConverterFunction> requestConverterFunctions, Iterable<? extends ResponseConverterFunction> responseConverterFunctions, Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions)
RequestConverterFunctions, ResponseConverterFunction
and ExceptionHandlerFunctions for creating an AnnotatedServiceExtensions.requestConverterFunctions - the RequestConverterFunctionsresponseConverterFunctions - the ResponseConverterFunctionsexceptionHandlerFunctions - the ExceptionHandlerFunctionsCopyright © 2020 LeanCloud. All rights reserved.