- 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
addResourceClass(Class<?> resource)
Add a JAX-RS resource class to use.Server.Builder
applications(Application... applications)
Replace existing applications with the ones provided.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
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
defaultExecutorServiceSupplier(Supplier<? extends ExecutorService> supplier)
Set a supplier of an executor service to use for tasks connected with application processing (JAX-RS).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
retainDiscoveredApplications(boolean retain)
If any application or resource class is added through this builder, applications discovered by CDI are ignored.
-
-
-
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
-
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
-
resourceConfig
public Server.Builder resourceConfig(ResourceConfig config)
JAX-RS resource configuration to use. This will add the provided resource config as an additional application.- 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 classes are ignored):
- All Applications and Application classes
- Resource classes
- Resource config
- Parameters:
application
- application to bootstrap Jersey- Returns:
- modified builder
-
retainDiscoveredApplications
public Server.Builder retainDiscoveredApplications(boolean retain)
If any application or resource class is added through this builder, applications discovered by CDI are ignored. You can change this behavior by setting the retain discovered applications totrue
.If you use
Server.Builder
and explicitly add a JAX-RS application or JAX-RS resource class to it, then classes discovered via CDI mechanisms will be ignored (e.g. all JAX-RS applications with bean defining annotations and all JAX-RS resources in bean archives). If you set the flag to true, we will retain both the "discovered" and "explicitly configured" applications and resource classes.- Parameters:
retain
- whether to keep applications discovered by CDI even if any are explicitly added- Returns:
- updated builder instance
-
applications
public Server.Builder applications(Application... applications)
Replace existing applications with the ones provided.- Parameters:
applications
- new applications to use with this server builder- Returns:
- updated builder instance
-
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 classes are ignored):
- All Applications and Application classes
- Resource 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 classes are ignored):
- Application class
- Application
- Resource 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 classes are ignored):
- Applications and application classes
- Resource 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 classes are ignored):
- Applications and application classes
- Resource classes
- Resource config
- Parameters:
resource
- resource class to add, list of these classes is used to bootstrap Jersey- Returns:
- modified builder
-
-