Class SimpleContainerFactory

java.lang.Object
org.glassfish.jersey.simple.SimpleContainerFactory

public final class SimpleContainerFactory extends Object
Factory for creating and starting Simple server containers. This returns a handle to the started server as Closeable instances, which allows the server to be stopped by invoking the Closeable.close() method.

To start the server in HTTPS mode an SSLContext can be provided. This will be used to decrypt and encrypt information sent over the connected TCP socket channel.

Author:
Arul Dhesiaseelan (aruld at acm.org), Marek Potociar, Paul Sandoz
  • Method Details

    • create

      public static SimpleServer create(URI address, ResourceConfig config)
      Create a Closeable that registers an Container that in turn manages all root resource and provider classes declared by the resource configuration.
      Parameters:
      address - the URI to create the http server. The URI scheme must be equal to "http". The URI user information and host are ignored If the URI port is not present then port 80 will be used. The URI path, query and fragment components are ignored.
      config - the resource configuration.
      Returns:
      the closeable connection, with the endpoint started.
      Throws:
      ProcessingException - thrown when problems during server creation.
      IllegalArgumentException - if address is null.
    • create

      public static SimpleServer create(URI address, ResourceConfig config, int count, int select)
      Create a Closeable that registers an Container that in turn manages all root resource and provider classes declared by the resource configuration.
      Parameters:
      address - the URI to create the http server. The URI scheme must be equal to "http". The URI user information and host are ignored If the URI port is not present then port 80 will be used. The URI path, query and fragment components are ignored.
      config - the resource configuration.
      count - this is the number of threads to be used.
      select - this is the number of selector threads to use.
      Returns:
      the closeable connection, with the endpoint started.
      Throws:
      ProcessingException - thrown when problems during server creation.
      IllegalArgumentException - if address is null.
    • create

      public static SimpleServer create(URI address, SSLContext context, ResourceConfig config)
      Create a Closeable that registers an Container that in turn manages all root resource and provider classes declared by the resource configuration.
      Parameters:
      address - the URI to create the http server. The URI scheme must be equal to https . The URI user information and host are ignored. If the URI port is not present then port 443 will be used. The URI path, query and fragment components are ignored.
      context - this is the SSL context used for SSL connections.
      config - the resource configuration.
      Returns:
      the closeable connection, with the endpoint started.
      Throws:
      ProcessingException - thrown when problems during server creation.
      IllegalArgumentException - if address is null.
    • create

      public static SimpleServer create(URI address, SSLContext context, ResourceConfig config, int count, int select)
      Create a Closeable that registers an Container that in turn manages all root resource and provider classes declared by the resource configuration.
      Parameters:
      address - the URI to create the http server. The URI scheme must be equal to https . The URI user information and host are ignored. If the URI port is not present then port 443 will be used. The URI path, query and fragment components are ignored.
      context - this is the SSL context used for SSL connections.
      config - the resource configuration.
      count - this is the number of threads to be used.
      select - this is the number of selector threads to use.
      Returns:
      the closeable connection, with the endpoint started.
      Throws:
      ProcessingException - thrown when problems during server creation.
      IllegalArgumentException - if address is null.
    • create

      public static SimpleServer create(URI address, SSLContext context, SimpleContainer container)
      Create a Closeable that registers an Container that in turn manages all root resource and provider classes found by searching the classes referenced in the java classpath.
      Parameters:
      address - the URI to create the http server. The URI scheme must be equal to https . The URI user information and host are ignored. If the URI port is not present then port 443 will be used. The URI path, query and fragment components are ignored.
      context - this is the SSL context used for SSL connections.
      container - the container that handles all HTTP requests.
      Returns:
      the closeable connection, with the endpoint started.
      Throws:
      ProcessingException - thrown when problems during server creation.
      IllegalArgumentException - if address is null.
    • create

      public static SimpleServer create(URI address, SSLContext context, SeBootstrap.Configuration.SSLClientAuthentication sslClientAuthentication, SimpleContainer container, boolean start)
      Create a Closeable that registers an Container that in turn manages all root resource and provider classes found by searching the classes referenced in the java classpath.
      Parameters:
      address - the URI to create the http server. The URI scheme must be equal to https . The URI user information and host are ignored. If the URI port is not present then port 443 will be used. The URI path, query and fragment components are ignored.
      context - this is the SSL context used for SSL connections.
      container - the Simple container with ResourceConfig.
      sslClientAuthentication - Secure socket client authentication policy.
      start - whether the server shall listen to connections immediately
      Returns:
      the closeable connection, with the endpoint started.
      Throws:
      ProcessingException - thrown when problems during server creation.
      IllegalArgumentException - if address is null.
    • create

      public static SimpleServer create(URI address, SSLContext context, ResourceConfig config, Object parentContext, int count, int select)
      Create a Closeable that registers an Container that in turn manages all root resource and provider classes declared by the resource configuration.
      Parameters:
      address - the URI to create the http server. The URI scheme must be equal to https . The URI user information and host are ignored. If the URI port is not present then port 443 will be used. The URI path, query and fragment components are ignored.
      context - this is the SSL context used for SSL connections.
      config - the resource configuration.
      parentContext - DI provider specific context with application's registered bindings.
      count - this is the number of threads to be used.
      select - this is the number of selector threads to use.
      Returns:
      the closeable connection, with the endpoint started.
      Throws:
      ProcessingException - thrown when problems during server creation.
      IllegalArgumentException - if address is null.
      Since:
      2.12
    • create

      public static SimpleServer create(URI address, SSLContext context, SimpleContainer container, int count, int select) throws ProcessingException
      Create a Closeable that registers an Container that in turn manages all root resource and provider classes found by searching the classes referenced in the java classpath.
      Parameters:
      address - the URI to create the http server. The URI scheme must be equal to https . The URI user information and host are ignored. If the URI port is not present then port 443 will be used. The URI path, query and fragment components are ignored.
      context - this is the SSL context used for SSL connections.
      container - the container that handles all HTTP requests.
      count - this is the number of threads to be used.
      select - this is the number of selector threads to use.
      Returns:
      the closeable connection, with the endpoint started.
      Throws:
      ProcessingException - thrown when problems during server creation.
      IllegalArgumentException - if address is null.