Class ServerCdiExtension

java.lang.Object
io.helidon.microprofile.server.ServerCdiExtension
All Implemented Interfaces:
Extension

public class ServerCdiExtension extends Object implements Extension
Extension to handle web server configuration and lifecycle.
  • Constructor Details

    • ServerCdiExtension

      public ServerCdiExtension()
      Default constructor required by ServiceLoader.
  • Method Details

    • serverRoutingBuilder

      public HttpRouting.Builder serverRoutingBuilder()
      Helidon webserver routing builder that can be used to add routes to the webserver.
      Returns:
      server routing builder
    • serverNamedRoutingBuilder

      public HttpRouting.Builder serverNamedRoutingBuilder(String name)
      Helidon webserver routing builder that can be used to add routes to a named socket of the webserver.
      Parameters:
      name - name of the named routing (should match a named socket configuration)
      Returns:
      builder for routing of the named route
    • addRouting

      public void addRouting(Builder<?,? extends Routing> routing)
      Add a routing to the server. This MUST NOT be HTTP routing. To update HTTP routing, please use serverRoutingBuilder().
      Parameters:
      routing - routing to add, such as WebSocket routing
    • addRouting

      public void addRouting(Builder<?,? extends Routing> routing, String socketName, boolean required, String appName)
      Add a routing to the server. This MUST NOT be HTTP routing. To update HTTP routing, please use serverNamedRoutingBuilder(String).
      Parameters:
      routing - routing to add, such as WebSocket routing
      socketName - name of the configured socket this routing should be assigned to, if not present (and required is false), the routing would be added to default socket
      required - is the socket required to be present, validated against configured sockets
      appName - name of the application, to provide meaningful error messages
    • addObserver

      public void addObserver(Observer observer)
      Add an observer, probably from an observer specific CDI extension. Observers are also discovered using a service loader, so if no customization in CDI is needed, the extension is not needed either.
      Parameters:
      observer - observer to add
    • host

      public String host()
      Current host the server is running on.
      Returns:
      host of this server
    • port

      public int port()
      Current port the server is running on. This information is only available after the server is actually started.
      Returns:
      port the server is running on
    • port

      public int port(String name)
      Named port the server is running on. This information is only available after the server is actually started.
      Parameters:
      name - Socket name
      Returns:
      Named port the server is running on
    • started

      public boolean started()
      State of the server.
      Returns:
      true if the server is already started, false otherwise
    • basePath

      public void basePath(String basePath)
      Base path of this server. This is used to redirect when a request is made for root ("/").
      Parameters:
      basePath - path to redirect to when user requests the root path
    • addFeature

      public void addFeature(ServerFeature feature)
      Add a server feature.
      Parameters:
      feature - feature to add