public class JettyServletContainer extends Object implements ServletContainerAdapter
org.eclipse.jetty.server.Server.
This org.fourthline.cling.transport.spi.ServletContainerAdapter starts
a Jetty 9.3.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.
| Modifier and Type | Field and Description |
|---|---|
static JettyServletContainer |
INSTANCE |
protected org.eclipse.jetty.server.Server |
server |
| 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.
|
protected void |
resetServer() |
void |
setExecutorService(ExecutorService executorService)
Might be called several times to integrate the servlet container with jUPnP'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.
|
public static final JettyServletContainer INSTANCE
protected org.eclipse.jetty.server.Server server
public void setExecutorService(ExecutorService executorService)
ServletContainerAdapterExecutorService,
make sure the Jetty container won't shut it down when ServletContainerAdapter.stopIfRunning() is called!setExecutorService in interface ServletContainerAdapterexecutorService - The service to use when spawning new servlet execution threads.public int addConnector(String host, int port) throws IOException
ServletContainerAdapteraddConnector in interface ServletContainerAdapterhost - The host address for the socket.port - The port, might be -1 to bind to an ephemeral port.IOException - If the connector couldn't be opened to retrieve the registered local port.public void registerServlet(String contextPath, javax.servlet.Servlet servlet)
ServletContainerAdapterregisterServlet in interface ServletContainerAdaptercontextPath - The context path prefix for all UPnP requests.servlet - The servlet handling all UPnP requests.public void startIfNotRunning()
ServletContainerAdapterstartIfNotRunning in interface ServletContainerAdapterpublic void stopIfRunning()
ServletContainerAdapterstopIfRunning in interface ServletContainerAdapterprotected void resetServer()
Copyright © 2023 jUPnP.org. All rights reserved.