Package org.zkoss.zkmax.ui.comet
Class CometServerPush
- java.lang.Object
-
- org.zkoss.zkex.ui.comet.CometServerPush
-
- org.zkoss.zkmax.ui.comet.CometServerPush
-
- All Implemented Interfaces:
ServerPush
public class CometServerPush extends CometServerPush
ZK Comet that supports Servlet 3 asynchronous processing. This implementation will detect if the server supports Servlet 3, and then use the right implementation automatically.- Since:
- 6.0.0
- Author:
- tomyeh
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.zkoss.zkex.ui.comet.CometServerPush
CometServerPush.AsyncInfo, CometServerPush.ThreadInfo
-
-
Constructor Summary
Constructors Constructor Description CometServerPush()
The default constructor.CometServerPush(boolean async)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
beforeUpdate(CometServerPush.ThreadInfo info)
protected java.lang.String
getStartScript()
Returns the JavaScript codes to enable (a.k.a., start) the server push.protected java.lang.String
getStopScript()
Returns the JavaScript codes to disable (a.k.a., stop) the server push.protected void
onStart()
Called whenCometServerPush.start(org.zkoss.zk.ui.Desktop)
is called.protected void
processRequest(Execution exec, CometServerPush.AsyncInfo ai)
Called when receiving the comet request from the client.protected boolean
setBusy()
Sets busy and return if it is busy for processing other request.void
start(Desktop desktop)
Starts the server push.-
Methods inherited from class org.zkoss.zkex.ui.comet.CometServerPush
activate, deactivate, getDesktop, getIntPref, getStartScript, isActive, onPiggyback, onStop, resume, schedule, startClientPush, stop, stopClientPush
-
-
-
-
Constructor Detail
-
CometServerPush
public CometServerPush()
The default constructor. It detects if the server supports Servlet 3, and then use the right implementation accordingly.If you prefer to disable the use of Servlet 3 or vice versa, you could specify a library property called
org.zkoss.zkmax.ui.comet.async.disabled
. Notice that enabling the asynchronous support in a server not supporting Servlet 3 is not allowed.
-
CometServerPush
public CometServerPush(boolean async)
- Parameters:
async
- whether to utilities Servlet 3 asynchronous processing support. Don't specify it to true if the server doesn't support Servlet 3. The result is unpredictable.
-
-
Method Detail
-
start
public void start(Desktop desktop)
Description copied from class:CometServerPush
Starts the server push.The derived class rarely need to override this method. Rather, override
CometServerPush.startClientPush()
.- Specified by:
start
in interfaceServerPush
- Overrides:
start
in classCometServerPush
-
getStartScript
protected java.lang.String getStartScript()
Description copied from class:CometServerPush
Returns the JavaScript codes to enable (a.k.a., start) the server push. It is called byCometServerPush.startClientPush()
to prepare the script ofAuScript
that will be sent to the client.- Overrides:
getStartScript
in classCometServerPush
-
getStopScript
protected java.lang.String getStopScript()
Description copied from class:CometServerPush
Returns the JavaScript codes to disable (a.k.a., stop) the server push. It is called byCometServerPush.stopClientPush()
to prepare the script ofAuScript
that will be sent to the client.- Overrides:
getStopScript
in classCometServerPush
-
onStart
protected void onStart()
Description copied from class:CometServerPush
Called whenCometServerPush.start(org.zkoss.zk.ui.Desktop)
is called. This method is called beforeCometServerPush.startClientPush()
, and used to initialize the desktop, if necessary.The default implementation initializes an extension to process the comet request.
- Overrides:
onStart
in classCometServerPush
-
setBusy
protected boolean setBusy()
Description copied from class:CometServerPush
Sets busy and return if it is busy for processing other request. If it is busy, true is returned. If it is not busy, false is returned but it is marked as busy.It is possible since the client might abort the previous one and issue a new one but their server didn't know.
- Overrides:
setBusy
in classCometServerPush
-
processRequest
protected void processRequest(Execution exec, CometServerPush.AsyncInfo ai) throws java.io.IOException
Called when receiving the comet request from the client.- Overrides:
processRequest
in classCometServerPush
- Throws:
java.io.IOException
-
beforeUpdate
protected void beforeUpdate(CometServerPush.ThreadInfo info)
- Overrides:
beforeUpdate
in classCometServerPush
-
-