Klasse JettyServletContainer

java.lang.Object
org.jupnp.transport.impl.jetty.JettyServletContainer
Alle implementierten Schnittstellen:
ServletContainerAdapter

public class JettyServletContainer extends Object implements ServletContainerAdapter
A singleton wrapper of a org.eclipse.jetty.server.Server.

This ServletContainerAdapter starts a Jetty 9.4.x instance on its own and stops it. Only one single context and servlet is registered, to handle UPnP requests.

This implementation might work on Android (not tested within JUPnP), dependencies are jetty-server and jetty-servlet Maven modules.

Autor:
Christian Bauer - initial contribution, Victor Toni - refactoring for JUPnP
  • Felddetails

    • INSTANCE

      public static final JettyServletContainer INSTANCE
    • server

      protected org.eclipse.jetty.server.Server server
  • Methodendetails

    • setExecutorService

      public void setExecutorService(ExecutorService executorService)
      Beschreibung aus Schnittstelle kopiert: ServletContainerAdapter
      Might be called several times to integrate the servlet container with jUPnP's executor configuration. You can ignore this call if you want to configure the container's thread pooling independently from jUPnP. If you use the given jUPnP ExecutorService, make sure the Jetty container won't shut it down when ServletContainerAdapter.stopIfRunning() is called!
      Angegeben von:
      setExecutorService in Schnittstelle ServletContainerAdapter
      Parameter:
      executorService - The service to use when spawning new servlet execution threads.
    • addConnector

      public int addConnector(String host, int port) throws IOException
      Beschreibung aus Schnittstelle kopiert: ServletContainerAdapter
      Might be called several times to set up the connectors. This is the host/address and the port jUPnP expects to receive HTTP requests on. If you set up your HTTP server connectors elsewhere and ignore when jUPnP calls this method, make sure you configure jUPnP with the correct host/port of your servlet container.
      Angegeben von:
      addConnector in Schnittstelle ServletContainerAdapter
      Parameter:
      host - The host address for the socket.
      port - The port, might be -1 to bind to an ephemeral port.
      Gibt zurück:
      The actual registered local port.
      Löst aus:
      IOException - If the connector couldn't be opened to retrieve the registered local port.
    • registerServlet

      public void registerServlet(String contextPath, javax.servlet.Servlet servlet)
      Beschreibung aus Schnittstelle kopiert: ServletContainerAdapter
      Might be called several times to register (the same) handler for UPnP requests, should only register it once.
      Angegeben von:
      registerServlet in Schnittstelle ServletContainerAdapter
      Parameter:
      contextPath - The context path prefix for all UPnP requests.
      servlet - The servlet handling all UPnP requests.
    • startIfNotRunning

      public void startIfNotRunning()
      Beschreibung aus Schnittstelle kopiert: ServletContainerAdapter
      Start your servlet container if it isn't already running, might be called multiple times.
      Angegeben von:
      startIfNotRunning in Schnittstelle ServletContainerAdapter
    • stopIfRunning

      public void stopIfRunning()
      Beschreibung aus Schnittstelle kopiert: ServletContainerAdapter
      Stop your servlet container if it's still running, might be called multiple times.
      Angegeben von:
      stopIfRunning in Schnittstelle ServletContainerAdapter
    • resetServer

      protected void resetServer()