org.fourthline.cling.transport.impl
Class AsyncServletStreamServerImpl

java.lang.Object
  extended by org.fourthline.cling.transport.impl.AsyncServletStreamServerImpl
All Implemented Interfaces:
Runnable, StreamServer<AsyncServletStreamServerConfigurationImpl>

public class AsyncServletStreamServerImpl
extends Object
implements StreamServer<AsyncServletStreamServerConfigurationImpl>

Implementation based on Servlet 3.0 API.

Author:
Christian Bauer

Nested Class Summary
protected  class AsyncServletStreamServerImpl.AsyncServletConnection
           
 
Field Summary
protected  AsyncServletStreamServerConfigurationImpl configuration
           
protected  int localPort
           
 
Constructor Summary
AsyncServletStreamServerImpl(AsyncServletStreamServerConfigurationImpl configuration)
           
 
Method Summary
protected  javax.servlet.Servlet createServlet(Router router)
           
 AsyncServletStreamServerConfigurationImpl getConfiguration()
           
 int getPort()
          This method will be called potentially right after StreamServer.init(java.net.InetAddress, org.fourthline.cling.transport.Router), the actual assigned local port must be available before the server is started.
 void init(InetAddress bindAddress, Router router)
          Configures the service and starts any listening sockets.
protected  boolean isConnectionOpen(javax.servlet.http.HttpServletRequest request)
          Override this method if you can check, at a low level, if the client connection is still open for the given request.
 void run()
           
 void stop()
          Stops the service, closes any listening sockets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configuration

protected final AsyncServletStreamServerConfigurationImpl configuration

localPort

protected int localPort
Constructor Detail

AsyncServletStreamServerImpl

public AsyncServletStreamServerImpl(AsyncServletStreamServerConfigurationImpl configuration)
Method Detail

getConfiguration

public AsyncServletStreamServerConfigurationImpl getConfiguration()
Specified by:
getConfiguration in interface StreamServer<AsyncServletStreamServerConfigurationImpl>
Returns:
This service's configuration.

init

public void init(InetAddress bindAddress,
                 Router router)
          throws InitializationException
Description copied from interface: StreamServer
Configures the service and starts any listening sockets.

Specified by:
init in interface StreamServer<AsyncServletStreamServerConfigurationImpl>
Parameters:
bindAddress - The address to bind any sockets on.
router - The router which handles the incoming UpnpStream.
Throws:
InitializationException - If the service could not be initialized or started.

getPort

public int getPort()
Description copied from interface: StreamServer
This method will be called potentially right after StreamServer.init(java.net.InetAddress, org.fourthline.cling.transport.Router), the actual assigned local port must be available before the server is started.

Specified by:
getPort in interface StreamServer<AsyncServletStreamServerConfigurationImpl>
Returns:
The TCP port this service is listening on, e.g. the actual ephemeral port.

stop

public void stop()
Description copied from interface: StreamServer
Stops the service, closes any listening sockets.

Specified by:
stop in interface StreamServer<AsyncServletStreamServerConfigurationImpl>

run

public void run()
Specified by:
run in interface Runnable

createServlet

protected javax.servlet.Servlet createServlet(Router router)

isConnectionOpen

protected boolean isConnectionOpen(javax.servlet.http.HttpServletRequest request)
Override this method if you can check, at a low level, if the client connection is still open for the given request. This will likely require access to proprietary APIs of your servlet container to obtain the socket/channel for the given request.

Returns:
By default true.


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