Class Server.Builder

java.lang.Object
io.helidon.microprofile.server.Server.Builder
All Implemented Interfaces:
Builder<Server.Builder,Server>, Supplier<Server>
Enclosing interface:
Server

public static final class Server.Builder extends Object implements Builder<Server.Builder,Server>
Builder to build Server instance.
  • Method Details

    • build

      public Server build()
      Build a server based on this builder.
      Specified by:
      build in interface Builder<Server.Builder,Server>
      Returns:
      Server instance to be started
    • 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
    • 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 different ApplicationPath. 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 to true.

      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 different ApplicationPath. 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 under
      application - 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 under
      applicationClass - 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