Package io.helidon.microprofile.server
Class Server.Builder
- java.lang.Object
-
- io.helidon.microprofile.server.Server.Builder
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Server.Builder
addApplication(JaxRsApplication application)
Add a JAX-RS application with all possible options to this server.Server.Builder
addApplication(Class<? extends Application> applicationClass)
JAX-RS application class to use.Server.Builder
addApplication(String contextRoot, Class<? extends Application> applicationClass)
JAX-RS application class to use.Server.Builder
addApplication(String contextRoot, Application application)
JAX-RS application to use.Server.Builder
addApplication(Application application)
JAX-RS application to use.Server.Builder
addExtension(MpService service)
Add an extension to the list of extensions.Server.Builder
addProviderClass(Class<?> provider)
Add a JAX-RS provider class to use.Server.Builder
addResourceClass(Class<?> resource)
Add a JAX-RS resource class to use.Server.Builder
basePath(String basePath)
Configure a path to which the server would redirect when a root path is requested.Server
build()
Build a server based on this builder.Server.Builder
cdiContainer(SeContainer cdiContainer)
Configure CDI container to use.Server.Builder
config(Config config)
Configuration instance to use to configure this server (Helidon config).Server.Builder
config(Config config)
Configuration instance to use to configure this server (Microprofile config).Server.Builder
context(Context parentContext)
Configure the parent context to be used by this server.Server.Builder
defaultExecutorServiceSupplier(Supplier<? extends ExecutorService> supplier)
Set a supplier of an executor service to use for tasks connected with application processing (JAX-RS).Server.Builder
extensionsService(HelidonServiceLoader.Builder<MpService> loaderBuilder)
Configure the extension builder.Server.Builder
host(String host)
Configure listen host.Server.Builder
port(int port)
Configure listen port.Server.Builder
resourceConfig(ResourceConfig config)
JAX-RS resource configuration to use.Server.Builder
supportParallel(boolean supportParallelRun)
Enabled (or disable) support for more than one MP Server running in parallel.
-
-
-
Method Detail
-
build
public Server build()
Build a server based on this builder.- Returns:
- Server instance to be started
- Throws:
MpException
- in case the server fails to be created
-
host
public Server.Builder host(String host)
Configure listen host.- Parameters:
host
- hostname- Returns:
- modified builder
-
basePath
public Server.Builder basePath(String basePath)
Configure a path to which the server would redirect when a root path is requested. E.g. when static content is available at "/static" and you want to start there on index.html, you may want to configure this to "/static/index.html". When user requests "http://host:port" or "http://host:port/", the user would be redirected to "http://host:port/static/index.html"- Parameters:
basePath
- path to redirect user from root path- Returns:
- updated builder instance
-
extensionsService
public Server.Builder extensionsService(HelidonServiceLoader.Builder<MpService> loaderBuilder)
Configure the extension builder. This allows a fully customized handling ofMpService
instances to be used by the createdServer
.- Parameters:
loaderBuilder
- builder of server extensions- Returns:
- updated builder instance
- See Also:
HelidonServiceLoader.Builder.useSystemServiceLoader(boolean)
-
addExtension
public Server.Builder addExtension(MpService service)
Add an extension to the list of extensions. AllMpService
configured for Java Service loader are loaded automatically. This serves as a possibility to add a service that is not loaded through a service loader.To have a fully customized list of extensions, use
extensionsService(io.helidon.common.serviceloader.HelidonServiceLoader.Builder)
.- Parameters:
service
- service implementation- Returns:
- updated builder instance
-
defaultExecutorServiceSupplier
public Server.Builder defaultExecutorServiceSupplier(Supplier<? extends ExecutorService> supplier)
Set a supplier of an executor service to use for tasks connected with application processing (JAX-RS).- Parameters:
supplier
- executor service supplier, only called when an application is configured without its own executor service- Returns:
- updated builder instance
-
port
public Server.Builder port(int port)
Configure listen port.- Parameters:
port
- port- Returns:
- modified builder
-
config
public Server.Builder config(Config config)
Configuration instance to use to configure this server (Helidon config).- Parameters:
config
- configuration to use- Returns:
- modified builder
-
config
public Server.Builder config(Config config)
Configuration instance to use to configure this server (Microprofile config).- Parameters:
config
- configuration to use- Returns:
- modified builder
-
cdiContainer
public Server.Builder cdiContainer(SeContainer cdiContainer)
Configure CDI container to use. Use this method if you need to manually configure the CDI container. Also understand, that whatever happens during container initialization is already done and cannot be undone, such as when microprofile configuration is used. If you use this method and then set explicit config usingconfig(Config)
, you may end up with some classes configured from default MP config.- Parameters:
cdiContainer
- container to use, currently this requires Weld, as Jersey CDI integration depends on it; not other CDI provider is tested- Returns:
- modified builder
-
resourceConfig
public Server.Builder resourceConfig(ResourceConfig config)
JAX-RS resource configuration to use.Order is (e.g. if application is defined, resource classes are ignored):
- All Applications and Application classes
- Resource classes
- Resource config
- Parameters:
config
- configuration to bootstrap Jersey- Returns:
- modified builder
-
addApplication
public Server.Builder addApplication(JaxRsApplication application)
Add a JAX-RS application with all possible options to this server.- Parameters:
application
- application to add- Returns:
- updated builder instance
-
addApplication
public Server.Builder addApplication(Application application)
JAX-RS application to use. If more than one application is added, they must be registered on differentApplicationPath
. Also you must make sure that paths do not overlap, as that may cause unexpected results (e.g. registering one application under root ("/") and another under "/app1" would not work as expected).Order is (e.g. if application is defined, resource and provider classes are ignored):
- Applications and application classes
- Resource and provider classes
- Resource config
- Parameters:
application
- application to bootstrap Jersey- Returns:
- modified builder
-
addApplication
public Server.Builder addApplication(String contextRoot, Application application)
JAX-RS application to use. If more than one application is added, they must be registered on differentApplicationPath
. Also you must make sure that paths do not overlap, as that may cause unexpected results (e.g. registering one application under root ("/") and another under "/app1" would not work as expected).Order is (e.g. if application is defined, resource and provider classes are ignored):
- Applications and application classes
- Resource and provider classes
- Resource config
- Parameters:
contextRoot
- context root this application will be available underapplication
- application to bootstrap Jersey- Returns:
- modified builder
-
addApplication
public Server.Builder addApplication(Class<? extends Application> applicationClass)
JAX-RS application class to use.Order is (e.g. if application is defined, resource and provider classes are ignored):
- Applications and application classes
- Resource and provider classes
- Resource config
- Parameters:
applicationClass
- application class to bootstrap Jersey- Returns:
- modified builder
-
addApplication
public Server.Builder addApplication(String contextRoot, Class<? extends Application> applicationClass)
JAX-RS application class to use.Order is (e.g. if application is defined, resource and provider classes are ignored):
- Applications and application classes
- Resource and provider classes
- Resource config
- Parameters:
contextRoot
- context root to serve this application underapplicationClass
- application class to bootstrap Jersey- Returns:
- modified builder
-
addResourceClass
public Server.Builder addResourceClass(Class<?> resource)
Add a JAX-RS resource class to use.Order is (e.g. if application is defined, resource and provider classes are ignored):
- Applications and application classes
- Resource and provider classes
- Resource config
- Parameters:
resource
- resource class to add, list of these classes is used to bootstrap Jersey- Returns:
- modified builder
-
addProviderClass
public Server.Builder addProviderClass(Class<?> provider)
Add a JAX-RS provider class to use.Order is (e.g. if application is defined, resource and provider classes are ignored):
- Applications and application classes
- Resource and provider classes
- Resource config
- Parameters:
provider
- provider class to add, list of these classes is used to bootstrap Jersey- Returns:
- modified builder
-
context
public Server.Builder context(Context parentContext)
Configure the parent context to be used by this server.- Parameters:
parentContext
- context to serve as a parent- Returns:
- updated builder instance
-
supportParallel
public Server.Builder supportParallel(boolean supportParallelRun)
Enabled (or disable) support for more than one MP Server running in parallel. By default this is not supported, as a single JVM shares class loader and CDI, so running more than one server in a single JVM can lead to unexpected behavior.- Parameters:
supportParallelRun
- set totrue
to start more than oneServer
in the same JVM- Returns:
- updated builder instance
-
-