org.atmosphere.gwt.server.impl
Class GwtResponseWriterImpl

java.lang.Object
  extended by org.atmosphere.gwt.server.impl.GwtResponseWriterImpl
All Implemented Interfaces:
GwtResponseWriter
Direct Known Subclasses:
ManagedStreamResponseWriter, OperaEventSourceResponseWriter, WebsocketResponseWriter

public abstract class GwtResponseWriterImpl
extends Object
implements GwtResponseWriter

Author:
p.havelaar

Field Summary
protected  int connectionID
           
protected  org.slf4j.Logger logger
           
protected  GwtAtmosphereResourceImpl resource
           
protected  boolean shouldEscapeText
           
protected  Writer writer
           
 
Constructor Summary
protected GwtResponseWriterImpl(GwtAtmosphereResourceImpl resource)
           
 
Method Summary
protected abstract  void doHeartbeat()
           
protected abstract  void doSendError(int statusCode, String message)
           
protected abstract  void doSuspend()
           
protected abstract  void doTerminate()
           
protected abstract  void doWrite(List<? extends Serializable> messages)
           
protected  void escapeText(boolean escape)
           
protected  JSONSerializer getJsonSerializer()
           
 long getLastWriteTime()
          Returns the last time a write has been performed
protected  OutputStream getOutputStream(OutputStream outputStream)
           
 javax.servlet.http.HttpServletRequest getRequest()
           
 javax.servlet.http.HttpServletResponse getResponse()
           
protected  SerialMode getSerializationMode()
           
protected  boolean hasSession()
           
 void heartbeat()
          Write a heartbeat message to the associated HTTP response.
 void initiate()
           
 boolean isTerminated()
          Test if this Comet response has been terminated by calling the GwtResponseWriter.terminate() method or terminated from the HTTP client disconnecting.
 void sendError(int statusCode)
          Send an error before the response is sent.
 void sendError(int statusCode, String message)
          Send an error before the response is sent.
protected  String serialize(Object message)
           
protected  boolean shouldEscapeText()
           
protected  boolean supportsDeflate()
           
 void suspend()
           
 void terminate()
          Write a terminate message to the associated HTTP response and close the HTTP output stream/
 void write(List<? extends Serializable> messages)
          Write a list of message to the associated HTTP response.
 void write(List<? extends Serializable> messages, boolean flush)
          Write a list of message to the associated HTTP response.
 void write(Serializable message)
          Write a single message to the associated HTTP response.
 void write(Serializable message, boolean flush)
          Write a single message to the associated HTTP response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

protected Writer writer

resource

protected final GwtAtmosphereResourceImpl resource

connectionID

protected final int connectionID

logger

protected final org.slf4j.Logger logger

shouldEscapeText

protected boolean shouldEscapeText
Constructor Detail

GwtResponseWriterImpl

protected GwtResponseWriterImpl(GwtAtmosphereResourceImpl resource)
Method Detail

isTerminated

public boolean isTerminated()
Description copied from interface: GwtResponseWriter
Test if this Comet response has been terminated by calling the GwtResponseWriter.terminate() method or terminated from the HTTP client disconnecting.

Specified by:
isTerminated in interface GwtResponseWriter
Returns:
if this Comet response has been terminated

getSerializationMode

protected SerialMode getSerializationMode()

getRequest

public javax.servlet.http.HttpServletRequest getRequest()

getResponse

public javax.servlet.http.HttpServletResponse getResponse()

sendError

public void sendError(int statusCode)
               throws IOException
Description copied from interface: GwtResponseWriter
Send an error before the response is sent.

Specified by:
sendError in interface GwtResponseWriter
Throws:
IOException

sendError

public void sendError(int statusCode,
                      String message)
               throws IOException
Description copied from interface: GwtResponseWriter
Send an error before the response is sent.

Specified by:
sendError in interface GwtResponseWriter
Throws:
IOException

getOutputStream

protected OutputStream getOutputStream(OutputStream outputStream)

initiate

public void initiate()
              throws IOException
Throws:
IOException

suspend

public void suspend()
             throws IOException
Throws:
IOException

terminate

public void terminate()
               throws IOException
Description copied from interface: GwtResponseWriter
Write a terminate message to the associated HTTP response and close the HTTP output stream/

Specified by:
terminate in interface GwtResponseWriter
Throws:
IOException

write

public void write(Serializable message)
           throws IOException,
                  SerializationException
Description copied from interface: GwtResponseWriter
Write a single message to the associated HTTP response.

Specified by:
write in interface GwtResponseWriter
Throws:
IOException
SerializationException

write

public void write(Serializable message,
                  boolean flush)
           throws IOException,
                  SerializationException
Description copied from interface: GwtResponseWriter
Write a single message to the associated HTTP response. Flush the HTTP output stream if flush is true.

Specified by:
write in interface GwtResponseWriter
Throws:
IOException
SerializationException

write

public void write(List<? extends Serializable> messages)
           throws IOException,
                  SerializationException
Description copied from interface: GwtResponseWriter
Write a list of message to the associated HTTP response. This method may be more optimal to the single message version.

Specified by:
write in interface GwtResponseWriter
Throws:
IOException
SerializationException

write

public void write(List<? extends Serializable> messages,
                  boolean flush)
           throws IOException,
                  SerializationException
Description copied from interface: GwtResponseWriter
Write a list of message to the associated HTTP response. This method may be more optimal to the single message version. Flush the HTTP output stream if flush is true.

Specified by:
write in interface GwtResponseWriter
Throws:
IOException
SerializationException

heartbeat

public void heartbeat()
               throws IOException
Description copied from interface: GwtResponseWriter
Write a heartbeat message to the associated HTTP response.

Specified by:
heartbeat in interface GwtResponseWriter
Throws:
IOException

getLastWriteTime

public long getLastWriteTime()
Description copied from interface: GwtResponseWriter
Returns the last time a write has been performed

Specified by:
getLastWriteTime in interface GwtResponseWriter
Returns:

doSendError

protected abstract void doSendError(int statusCode,
                                    String message)
                             throws IOException
Throws:
IOException

doSuspend

protected abstract void doSuspend()
                           throws IOException
Throws:
IOException

doWrite

protected abstract void doWrite(List<? extends Serializable> messages)
                         throws IOException,
                                SerializationException
Throws:
IOException
SerializationException

doHeartbeat

protected abstract void doHeartbeat()
                             throws IOException
Throws:
IOException

doTerminate

protected abstract void doTerminate()
                             throws IOException
Throws:
IOException

shouldEscapeText

protected boolean shouldEscapeText()

escapeText

protected void escapeText(boolean escape)

supportsDeflate

protected boolean supportsDeflate()

hasSession

protected boolean hasSession()

serialize

protected String serialize(Object message)
                    throws SerializationException
Throws:
SerializationException

getJsonSerializer

protected JSONSerializer getJsonSerializer()


Copyright © 2014. All Rights Reserved.