org.fourthline.cling.transport.spi

## Interface ServletContainerAdapter

- All Known Implementing Classes:
    JettyServletContainer

      public interface ServletContainerAdapter

  Implement this to provide your own servlet container (instance),

  It's OK if you don't start or stop your container when this adapter is called. You can treat the `startIfNotRunning()` and `stopIfRunning()` methods as suggestions, they only indicate what the UPnP stack wants to do. If your servlet container handles other services, keep it running all the time.

  An implementation must be thread-safe, all methods might be called concurrently by several threads.

  Author:
    Christian Bauer

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `addConnector(String host, int port)` Might be called several times to set up the connectors.
    `void` | `registerServlet(String contextPath, javax.servlet.Servlet servlet)` Might be called several times to register (the same) handler for UPnP requests, should only register it once.
    `void` | `removeConnector(String host, int port)` Removes a previously added connector.
    `void` | `setExecutorService(ExecutorService executorService)` Might be called several times to integrate the servlet container with Cling's executor configuration.
    `void` | `startIfNotRunning()` Start your servlet container if it isn't already running, might be called multiple times.
    `void` | `stopIfRunning()` Stop your servlet container if it's still running, might be called multiple times.

- - ### Method Detail

    - #### setExecutorService

          void setExecutorService(ExecutorService executorService)

      Might be called several times to integrate the servlet container with Cling's executor configuration. You can ignore this call if you want to configure the container's thread pooling independently from Cling. If you use the given Cling `ExecutorService`, make sure the Jetty container won't shut it down when `stopIfRunning()` is called!
      Parameters:
        `executorService` - The service to use when spawning new servlet execution threads.

    - #### addConnector

          int addConnector(String host,
                           int port)
                    throws IOException

      Might be called several times to set up the connectors. This is the host/address and the port Cling expects to receive HTTP requests on. If you set up your HTTP server connectors elsewhere and ignore when Cling calls this method, make sure you configure Cling with the correct host/port of your servlet container.
      Parameters:
        `host` - The host address for the socket.
        `port` - The port, might be `-1` to bind to an ephemeral port.
      Returns:
        The actual registered local port.
      Throws:
        `IOException` - If the connector couldn't be opened to retrieve the registered local port.

    - #### removeConnector

          void removeConnector(String host,
                               int port)

      Removes a previously added connector. Implementation should close the corresponding listening server socket. It may stop the server when the last connector is removed.
      Parameters:
        `host` - The host address of the socket.
        `port` - The port of the connector

    - #### registerServlet

          void registerServlet(String contextPath,
                               javax.servlet.Servlet servlet)

      Might be called several times to register (the same) handler for UPnP requests, should only register it once.
      Parameters:
        `contextPath` - The context path prefix for all UPnP requests.
        `servlet` - The servlet handling all UPnP requests.

    - #### startIfNotRunning

          void startIfNotRunning()

      Start your servlet container if it isn't already running, might be called multiple times.

    - #### stopIfRunning

          void stopIfRunning()

      Stop your servlet container if it's still running, might be called multiple times.

Copyright © 2016 4th Line GmbH, Switzerland. All rights reserved.