org.zkoss.zkmax.au.http
Class SmartAuWriter

java.lang.Object
  extended by org.zkoss.zk.au.http.HttpAuWriter
      extended by org.zkoss.zkmax.au.http.SmartAuWriter
All Implemented Interfaces:
AuWriter

public class SmartAuWriter
extends HttpAuWriter

A smart AU writer that will generate some output to client first if the processing takes more than the time specified in the timeout argument of open(java.lang.Object, java.lang.Object, int).

In additions, it compressed the last response in GZIP format to minimize the memory use.

Available in ZK EE

Since:
3.0.1
Author:
tomyeh

Constructor Summary
SmartAuWriter()
           
 
Method Summary
 void close(java.lang.Object request, java.lang.Object response)
          Closes the writer and flush the result to client.
protected  ScalableTimer newTimer()
          Creates an instance of ScalableTimer.
 AuWriter open(java.lang.Object request, java.lang.Object response, int timeout)
          Opens the connection.
protected  byte[] restore(java.lang.Object data)
          Called to decode the last response for repeated request before retrieving.
protected  java.lang.Object save(byte[] data)
          Called to encode the last response for repeated request before storing.
 
Methods inherited from class org.zkoss.zk.au.http.HttpAuWriter
complete, flush, isCompress, resend, setCompress, write, write, writeResponseId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmartAuWriter

public SmartAuWriter()
Method Detail

newTimer

protected ScalableTimer newTimer()
Creates an instance of ScalableTimer.

By default, it creates a scalable timer that will use at most 50 real timers (i.e., new ScalableTimer(50, 25)). If you want to change it, you can override this method.

Since:
3.0.4

open

public AuWriter open(java.lang.Object request,
                     java.lang.Object response,
                     int timeout)
              throws java.io.IOException
Opens the connection. It starts a timer and generate some output to client first if the processing take more than the time specified in the timeout argument.

Specified by:
open in interface AuWriter
Overrides:
open in class HttpAuWriter
Parameters:
request - the request (HttpServletRequest if HTTP)
response - the response (HttpServletResponse if HTTP)
timeout - the elapsed time (milliseconds) before sending a whitespace to the client to indicate the connection is alive. Ignored if non-positive, or the implementation doesn't support this feature.
Returns:
this object
Throws:
java.io.IOException

close

public void close(java.lang.Object request,
                  java.lang.Object response)
           throws java.io.IOException
Description copied from interface: AuWriter
Closes the writer and flush the result to client.

Specified by:
close in interface AuWriter
Overrides:
close in class HttpAuWriter
Parameters:
request - the request (HttpServletRequest if HTTP)
response - the response (HttpServletResponse if HTTP)
Throws:
java.io.IOException

save

protected java.lang.Object save(byte[] data)
Description copied from class: HttpAuWriter
Called to encode the last response for repeated request before storing.

Default: does nothing but return the input argument, data. The derived class might override this method to compress it.

Overrides:
save in class HttpAuWriter
See Also:
HttpAuWriter.restore(java.lang.Object)

restore

protected byte[] restore(java.lang.Object data)
Description copied from class: HttpAuWriter
Called to decode the last response for repeated request before retrieving.

Default: does nothing but return the input argument, data. The derived class might override this method to uncompress it.

Overrides:
restore in class HttpAuWriter
Parameters:
data - the data returned by HttpAuWriter.save(byte[])
Returns:
the byte array that is passed to HttpAuWriter.save(byte[]).


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo