com.sun.jini.jeri.internal.http
Class HttpServerConnection

java.lang.Object
  extended by com.sun.jini.jeri.internal.http.HttpServerConnection
All Implemented Interfaces:
TimedConnection
Direct Known Subclasses:
HttpServerEndpoint.LH.Connection, HttpsServerEndpoint.HttpsServerEndpointImpl.HttpServer

public abstract class HttpServerConnection
extends Object
implements TimedConnection

Class representing a server-side HTTP connection used to receive and dispatch incoming HTTP requests.

Author:
Sun Microsystems, Inc.

Nested Class Summary
private  class HttpServerConnection.Dispatcher
          Incoming request dispatcher.
private  class HttpServerConnection.InboundRequestImpl
          HTTP-based implementation of InboundRequest abstraction.
 
Field Summary
private static int BUSY
           
private static int CLOSED
           
private  RequestDispatcher dispatcher
           
private static int HTTP_MAJOR
           
private static int HTTP_MINOR
           
private static int IDLE
           
private  InputStream in
           
private  HttpServerManager manager
           
private  OutputStream out
           
private static String serverString
           
private  Socket sock
           
private  int state
           
private  Object stateLock
           
private static int UNSTARTED
           
private static Executor userThreadPool
           
 
Constructor Summary
HttpServerConnection(Socket sock, RequestDispatcher dispatcher, HttpServerManager manager)
          Creates new HttpServerConnection on top of given socket.
 
Method Summary
protected  void busy()
          Upcall indicating that connection is about to become busy.
protected  InvocationConstraints checkConstraints(InvocationConstraints constraints)
          Checks that the specified requirements are either fully or partially satisfied by the constraints actually in force for this connection, and returns any constraints that must be fully or partially implemented by higher layers in order to fully satisfy all of the specified requirements.
protected  void checkPermissions()
          Verifies that calling context has sufficient security permissions to receive a request on this connection.
private static Header createResponseHeader(boolean persist)
          Creates base header to be used in response message.
protected  void idle()
          Upcall indicating that connection has become idle.
protected abstract  void populateContext(Collection context)
          Populates the given context collection with context information representing this connection.
private  void registerAcks(String ackList)
          Notifies listeners for response ack cookies parsed from (possibly null) comma-separated cookie list string.
 boolean shutdown(boolean force)
          Attempts to shut down connection, returning true if connection is closed.
protected  void start()
          Starts request dispatch thread.
private static boolean supportsChunking(StartLine sline, Header header)
          Returns true if the received message start line indicates that the sender understands chunked transfer coding.
private static boolean supportsPersist(StartLine sline, Header header)
          Returns true if the received message start line and header indicate that the connection can be persisted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_MAJOR

private static final int HTTP_MAJOR
See Also:
Constant Field Values

HTTP_MINOR

private static final int HTTP_MINOR
See Also:
Constant Field Values

UNSTARTED

private static final int UNSTARTED
See Also:
Constant Field Values

IDLE

private static final int IDLE
See Also:
Constant Field Values

BUSY

private static final int BUSY
See Also:
Constant Field Values

CLOSED

private static final int CLOSED
See Also:
Constant Field Values

serverString

private static final String serverString

userThreadPool

private static final Executor userThreadPool

sock

private final Socket sock

in

private final InputStream in

out

private final OutputStream out

dispatcher

private final RequestDispatcher dispatcher

manager

private final HttpServerManager manager

stateLock

private final Object stateLock

state

private int state
Constructor Detail

HttpServerConnection

public HttpServerConnection(Socket sock,
                            RequestDispatcher dispatcher,
                            HttpServerManager manager)
                     throws IOException
Creates new HttpServerConnection on top of given socket.

Throws:
IOException
Method Detail

start

protected void start()
Starts request dispatch thread. Throws IllegalStateException if connection has already been started, or is closed.


checkPermissions

protected void checkPermissions()
Verifies that calling context has sufficient security permissions to receive a request on this connection.


checkConstraints

protected InvocationConstraints checkConstraints(InvocationConstraints constraints)
                                          throws UnsupportedConstraintException
Checks that the specified requirements are either fully or partially satisfied by the constraints actually in force for this connection, and returns any constraints that must be fully or partially implemented by higher layers in order to fully satisfy all of the specified requirements.

Throws:
UnsupportedConstraintException

populateContext

protected abstract void populateContext(Collection context)
Populates the given context collection with context information representing this connection.


idle

protected void idle()
Upcall indicating that connection has become idle. Subclasses may override this method to perform an appropriate action, such as scheduling an idle timeout.


busy

protected void busy()
Upcall indicating that connection is about to become busy. Subclasses may override this method to perform an appropriate action, such as cancelling an idle timeout.


shutdown

public boolean shutdown(boolean force)
Attempts to shut down connection, returning true if connection is closed. If force is true, connection is always shut down; if force is false, connection is only shut down if idle.

Specified by:
shutdown in interface TimedConnection

registerAcks

private void registerAcks(String ackList)
Notifies listeners for response ack cookies parsed from (possibly null) comma-separated cookie list string.


supportsPersist

private static boolean supportsPersist(StartLine sline,
                                       Header header)
Returns true if the received message start line and header indicate that the connection can be persisted.


supportsChunking

private static boolean supportsChunking(StartLine sline,
                                        Header header)
Returns true if the received message start line indicates that the sender understands chunked transfer coding.


createResponseHeader

private static Header createResponseHeader(boolean persist)
Creates base header to be used in response message. If persist is true, adds fields indicating a persistent connection.



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.