org.atmosphere.gwt.poll
Class AtmospherePollService

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
              extended by org.atmosphere.gwt.poll.AtmospherePollService
All Implemented Interfaces:
com.google.gwt.user.server.rpc.SerializationPolicyProvider, Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class AtmospherePollService
extends com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
implements com.google.gwt.user.server.rpc.SerializationPolicyProvider

See Also:
Serialized Form

Nested Class Summary
 class AtmospherePollService.SuspendInfo
           
 
Field Summary
static String GWT_REQUEST
           
static String GWT_SUSPENDED
           
 
Fields inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
perThreadRequest, perThreadResponse
 
Constructor Summary
AtmospherePollService()
          The default constructor.
 
Method Summary
protected  com.google.gwt.user.server.rpc.SerializationPolicy doGetSerializationPolicy(javax.servlet.http.HttpServletRequest request, String moduleBaseURL, String strongName)
          Gets the SerializationPolicy for given module base URL and strong name if there is one.
 com.google.gwt.user.server.rpc.SerializationPolicy getSerializationPolicy(String moduleBaseURL, String strongName)
           
protected  boolean isSuspended()
           
protected  void onAfterRequestDeserialized(com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
           
protected  void onAfterResponseSerialized(String serializedResponse)
          Override this method to examine the serialized response that will be returned to the client.
protected  void onBeforeRequestDeserialized(String serializedRequest)
          Override this method to examine the serialized version of the request payload before it is deserialized into objects.
 String processCall(String payload)
          Process a call originating from the given request.
 void processPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Standard HttpServlet method: handle the POST.
protected static boolean shouldCompressResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String responsePayload)
          Determines whether the response to a given servlet request should or should not be GZIP compressed.
protected  AtmospherePollService.SuspendInfo suspend()
           
protected  AtmospherePollService.SuspendInfo suspend(long timeout)
           
protected static void writeResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.ServletContext context, String responsePayload)
           
 
Methods inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
doPost, doUnexpectedFailure, getPermutationStrongName, getThreadLocalRequest, getThreadLocalResponse, readContent
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GWT_SUSPENDED

public static final String GWT_SUSPENDED
See Also:
Constant Field Values

GWT_REQUEST

public static final String GWT_REQUEST
See Also:
Constant Field Values
Constructor Detail

AtmospherePollService

public AtmospherePollService()
The default constructor.

Method Detail

suspend

protected AtmospherePollService.SuspendInfo suspend()

suspend

protected AtmospherePollService.SuspendInfo suspend(long timeout)

isSuspended

protected boolean isSuspended()

onAfterRequestDeserialized

protected void onAfterRequestDeserialized(com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
Overrides:
onAfterRequestDeserialized in class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet

processPost

public final void processPost(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws IOException,
                              javax.servlet.ServletException,
                              com.google.gwt.user.client.rpc.SerializationException
Standard HttpServlet method: handle the POST.

This doPost method swallows ALL exceptions, logs them in the ServletContext, and returns a GENERIC_FAILURE_MSG response with status code 500.

Specified by:
processPost in class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
Throws:
javax.servlet.ServletException
com.google.gwt.user.client.rpc.SerializationException
IOException

shouldCompressResponse

protected static boolean shouldCompressResponse(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response,
                                                String responsePayload)
Determines whether the response to a given servlet request should or should not be GZIP compressed. This method is only called in cases where the requester accepts GZIP encoding.

This implementation currently returns true if the response string's estimated byte length is longer than 256 bytes. Subclasses can override this logic.

Parameters:
request - the request being served
response - the response that will be written into
responsePayload - the payload that is about to be sent to the client
Returns:
true if responsePayload should be GZIP compressed, otherwise false.

writeResponse

protected static void writeResponse(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response,
                                    javax.servlet.ServletContext context,
                                    String responsePayload)
                             throws IOException
Throws:
IOException

getSerializationPolicy

public final com.google.gwt.user.server.rpc.SerializationPolicy getSerializationPolicy(String moduleBaseURL,
                                                                                       String strongName)
Specified by:
getSerializationPolicy in interface com.google.gwt.user.server.rpc.SerializationPolicyProvider

processCall

public String processCall(String payload)
                   throws com.google.gwt.user.client.rpc.SerializationException
Process a call originating from the given request. Uses the RPC.invokeAndEncodeResponse(Object, java.lang.reflect.Method, Object[]) method to do the actual work.

Subclasses may optionally override this method to handle the payload in any way they desire (by routing the request to a framework component, for instance). The HttpServletRequest and HttpServletResponse can be accessed via the AbstractRemoteServiceServlet.getThreadLocalRequest() and AbstractRemoteServiceServlet.getThreadLocalResponse() methods.

This is public so that it can be unit tested easily without HTTP.

Parameters:
payload - the UTF-8 request payload
Returns:
a string which encodes either the method's return, a checked exception thrown by the method, or an IncompatibleRemoteServiceException
Throws:
com.google.gwt.user.client.rpc.SerializationException - if we cannot serialize the response
com.google.gwt.user.server.rpc.UnexpectedException - if the invocation throws a checked exception that is not declared in the service method's signature
RuntimeException - if the service method throws an unchecked exception (the exception will be the one thrown by the service)

doGetSerializationPolicy

protected com.google.gwt.user.server.rpc.SerializationPolicy doGetSerializationPolicy(javax.servlet.http.HttpServletRequest request,
                                                                                      String moduleBaseURL,
                                                                                      String strongName)
Gets the SerializationPolicy for given module base URL and strong name if there is one.

Override this method to provide a SerializationPolicy using an alternative approach.

Parameters:
request - the HTTP request being serviced
moduleBaseURL - as specified in the incoming payload
strongName - a strong name that uniquely identifies a serialization policy file
Returns:
a SerializationPolicy for the given module base URL and strong name, or null if there is none

onAfterResponseSerialized

protected void onAfterResponseSerialized(String serializedResponse)
Override this method to examine the serialized response that will be returned to the client. The default implementation does nothing and need not be called by subclasses.

Parameters:
serializedResponse -

onBeforeRequestDeserialized

protected void onBeforeRequestDeserialized(String serializedRequest)
Override this method to examine the serialized version of the request payload before it is deserialized into objects. The default implementation does nothing and need not be called by subclasses.

Parameters:
serializedRequest -


Copyright © 2013. All Rights Reserved.