|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fourthline.cling.transport.impl.jetty.JettyServletContainer
public class JettyServletContainer
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.
| 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. |
static boolean |
isConnectionOpen(javax.servlet.http.HttpServletRequest request)
Casts the request to a Jetty API and tries to write a space character to the output stream of the socket. |
static boolean |
isConnectionOpen(javax.servlet.http.HttpServletRequest request,
byte[] heartbeat)
|
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 |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final JettyServletContainer INSTANCE
protected org.eclipse.jetty.server.Server server
| Method Detail |
|---|
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
ServletContainerAdapter
addConnector 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)
ServletContainerAdapter
registerServlet in interface ServletContainerAdaptercontextPath - The context path prefix for all UPnP requests.servlet - The servlet handling all UPnP requests.public void startIfNotRunning()
ServletContainerAdapter
startIfNotRunning in interface ServletContainerAdapterpublic void stopIfRunning()
ServletContainerAdapter
stopIfRunning in interface ServletContainerAdapterprotected void resetServer()
public static boolean isConnectionOpen(javax.servlet.http.HttpServletRequest request)
This space character might confuse the HTTP client. The Cling transports for Jetty Client and Apache HttpClient have been tested to work with space characters. Unfortunately, Sun JDK's HttpURLConnection does not gracefully handle any garbage in the HTTP request!
public static boolean isConnectionOpen(javax.servlet.http.HttpServletRequest request,
byte[] heartbeat)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||