Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.fourthline.cling.transport.impl.jetty
Class JettyServletContainer

    java.lang.Object
      org.fourthline.cling.transport.impl.jetty.JettyServletContainer

All Implemented Interfaces:
  ServletContainerAdapter

    public class JettyServletContainer

extends Object
implements ServletContainerAdapter

A singleton wrapper of a `org.eclipse.jetty.server.Server`.

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

This implementation works on Android, dependencies are `jetty-server` and `jetty-servlet` Maven modules.

Author:
  Christian Bauer

Field Summary
`static JettyServletContainer` | `INSTANCE`
`protected org.eclipse.jetty.server.Server` | `server`

Method Summary
`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 register (the same) handler for UPnP requests, should only register it once.
`protected void` | `resetServer()`
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INSTANCE

    public static final JettyServletContainer INSTANCE

### server

    protected org.eclipse.jetty.server.Server server

Method Detail

### addConnector

    public int addConnector(String host,
                            int port)
                     throws IOException

  Description copied from interface: `ServletContainerAdapter`
  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.

  Specified by:
    `addConnector` in interface `ServletContainerAdapter`
  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.

### registerServlet

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

  Description copied from interface: `ServletContainerAdapter`
  Might be called several times register (the same) handler for UPnP requests, should only register it once.

  Specified by:
    `registerServlet` in interface `ServletContainerAdapter`
  Parameters:
    `contextPath` - The context path prefix for all UPnP requests.
    `servlet` - The servlet handling all UPnP requests.

### startIfNotRunning

    public void startIfNotRunning()

  Description copied from interface: `ServletContainerAdapter`
  Start your servlet container if it isn't already running, might be called multiple times.

  Specified by:
    `startIfNotRunning` in interface `ServletContainerAdapter`

### stopIfRunning

    public void stopIfRunning()

  Description copied from interface: `ServletContainerAdapter`
  Stop your servlet container if it's still running, might be called multiple times.

  Specified by:
    `stopIfRunning` in interface `ServletContainerAdapter`

### resetServer

    protected void resetServer()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2013 4th Line GmbH, Switzerland. All Rights Reserved.