Class EmbeddedServers

java.lang.Object
org.jboss.resteasy.plugins.server.embedded.EmbeddedServers

public class EmbeddedServers extends Object
A utility for interacting with and locating embedded servers.
Author:
James R. Perkins
  • Constructor Details

    • EmbeddedServers

      public EmbeddedServers()
  • Method Details

    • validateDeployment

      public static void validateDeployment(ResteasyDeployment deployment)
      Validates a deployment is not null and starts it if required.
      Parameters:
      deployment - the deployment to validate
    • resolveApplication

      public static Optional<Class<? extends jakarta.ws.rs.core.Application>> resolveApplication(ResteasyDeployment deployment) throws ClassNotFoundException
      Resolves the application from the deployment. If the ResteasyDeployment.getApplication() is set, that is the application type returned. If it's not set, the ResteasyDeployment.getApplicationClass() and loaded.
      Parameters:
      deployment - the deployment used to resolve the application from
      Returns:
      the class, if found, or an empty optional
      Throws:
      ClassNotFoundException - if the ResteasyDeployment.getApplicationClass() is used and the class is not found in the class loader
      ClassCastException - if the ResteasyDeployment.getApplicationClass() does not name a subtype of Application
    • resolveContext

      public static String resolveContext(ResteasyDeployment deployment)
      Attempts to resolve the ApplicationPath on the deployments application. If the application is not set or is not annotated, null is returned.
      Parameters:
      deployment - the deployment to check
      Returns:
      the value of the ApplicationPath or null if the type is not annotated
    • resolveContext

      public static String resolveContext(Class<?> type)
      Attempts to resolve the ApplicationPath on the type. If the type is not annotated, null is returned.
      Parameters:
      type - the type to check
      Returns:
      the value of the ApplicationPath or null if the type is not annotated
    • checkContextPath

      public static String checkContextPath(ResteasyDeployment deployment)
      Checks the context path and if required creates a new path with a leading /.

      The deployments application is checked for a ApplicationPath. If application is not set or is not annotated with ApplicationPath, then "/" is returned.

      Parameters:
      deployment - the deployment to check
      Returns:
      the context path with a leading / if required
    • checkContextPath

      public static String checkContextPath(String contextPath)
      Checks the context path and if required creates a new path with a leading /.
      Parameters:
      contextPath - the context path to check
      Returns:
      the context path with a leading / if required
    • findServer

      public static EmbeddedServer findServer()
      Attempts to find the server first via a service loader.
      Returns:
      the embedded server found
    • findServer

      public static EmbeddedServer findServer(jakarta.ws.rs.SeBootstrap.Configuration configuration)
      Attempts to find the server first in the configuration, then via a service loader.

      The service loader will attempt to instantiate EmbeddedServer implementations using the following constructor preference order:

      1. A public constructor accepting SeBootstrap.Configuration - the provided configuration is passed
      2. A public no-argument constructor - used as fallback
      Parameters:
      configuration - the configuration to attempt to locate the server in and pass to the constructor
      Returns:
      the embedded server found
      Throws:
      IllegalStateException - if no EmbeddedServer implementation is found