com.appenginefan.toolkit.common
Interface WebConnectionServer.ServerGuts

Enclosing class:
WebConnectionServer

public static interface WebConnectionServer.ServerGuts

Represents the inner works of a server. An instance of this interface is contained within a WebConnectionServer, which uses its different methods during dispatch.


Method Summary
 void commit(javax.servlet.http.HttpServletRequest request)
          Commits any changes made to the store in this thread that have not been written yet.
 ServerEndpoint fromHandle(javax.servlet.http.HttpServletRequest request, String handle)
          Loads a ServerEndpoint object from a given handle.
 ServerEndpoint loadServerEndpoint(javax.servlet.http.HttpServletRequest request, String meta)
          Assumed a given request belongs to an existing ServerEndpoint, loads that object.
 ServerEndpoint newServerEndpoint(javax.servlet.http.HttpServletRequest request)
          For the given HttpServletRequest, create a new server endpoint.
 void rollback(javax.servlet.http.HttpServletRequest request)
          Commits any changes made to the store in this thread that have not been written yet.
 String toHandle(ServerEndpoint bus)
          Converts a ServerEndpoint to a unique handle that can be used to persist inner state in a data store
 void writeState(javax.servlet.http.HttpServletRequest request, ServerEndpoint bus, javax.servlet.http.HttpServletResponse response)
          Populate the cookies in a servlet response with whatever data is needed to support the loadServerEndpoint() method in future requests.
 

Method Detail

loadServerEndpoint

ServerEndpoint loadServerEndpoint(javax.servlet.http.HttpServletRequest request,
                                  String meta)
Assumed a given request belongs to an existing ServerEndpoint, loads that object. It is assumed that the ServerEndpoint is in its connected state. Unlike newServerEndpoint(), an existing ServerEndpoint object may have additional state in a database. This method is expected to load that data, as well.

Parameters:
request - the request that triggers the lookup
meta - the meta-tag from the http request
Returns:
a ServerEndpoint object if existent, or null if nothing is found

newServerEndpoint

ServerEndpoint newServerEndpoint(javax.servlet.http.HttpServletRequest request)
For the given HttpServletRequest, create a new server endpoint. This is the equivalent of a newly opened socket connection.

Parameters:
request - the request that triggers the creation
Returns:
a non-null ServerEndpoint object that is not "open" yet

writeState

void writeState(javax.servlet.http.HttpServletRequest request,
                ServerEndpoint bus,
                javax.servlet.http.HttpServletResponse response)
                throws IOException
Populate the cookies in a servlet response with whatever data is needed to support the loadServerEndpoint() method in future requests. Also, write the body of the response.

Parameters:
bus - the ServerEndpoint to transmit
response - the response to populate
Throws:
IOException

toHandle

String toHandle(ServerEndpoint bus)
Converts a ServerEndpoint to a unique handle that can be used to persist inner state in a data store

Parameters:
bus - a non-null ServerEndpoint
Returns:
the unique id of the bus

fromHandle

ServerEndpoint fromHandle(javax.servlet.http.HttpServletRequest request,
                          String handle)
Loads a ServerEndpoint object from a given handle. The ServerEndpoint object is usually less "complete" than an object constructed from a request, since it does not contain the state stored in the http client, but it is sufficient to perform certain manipulattions, like enqueuing outgoing messages.

Parameters:
handle - the handle that should be used for constructing the object
Returns:
a ServerEndpoint object, or null if the handle is invalid

commit

void commit(javax.servlet.http.HttpServletRequest request)
Commits any changes made to the store in this thread that have not been written yet.


rollback

void rollback(javax.servlet.http.HttpServletRequest request)
Commits any changes made to the store in this thread that have not been written yet.