public interface CometNotifier extends ItsNatUserData
The ItsNat COMET approach is based on AJAX or SCRIPT, the client is ever waiting for an asynchronous event to return. When new code must be sent to the client this event returns and updates the client and automatically a new asynchronous request is sent to the server waiting to new asynchronous server changes (technique sometimes called as "long polling").
Use COMET if you have to monitor by web a never ending server process.
Current implementation does not need a special server but it locks a thread per client (and a HTTP connection per client). This thread is stalled most of the time, the scalability issue is more related to the maximun number of threads the system can manage.
ClientDocument.createCometNotifier()
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(org.w3c.dom.events.EventListener listener)
Adds an event listener to this Comet notifier.
|
ClientDocument |
getClientDocument()
Returns the parent client document this object belongs to.
|
long |
getEventTimeout()
Returns the default timeout in client of COMET AJAX/SCRIPT events.
|
long |
getExpirationDelay()
Returns the maximum expiration delay.
|
ItsNatDocument |
getItsNatDocument()
Returns the asociated document.
|
boolean |
isStopped()
Informs whether this notifier is stopped.
|
void |
notifyClient()
Notifies the client thread to send pending document modifications.
|
void |
removeEventListener(org.w3c.dom.events.EventListener listener)
Removes the specified event listener from this Comet notifier.
|
void |
setExpirationDelay(long expirationDelay)
Sets the maximum expiration delay.
|
void |
stop()
Stops and disposes this notifier.
|
containsUserValueName, getUserValue, getUserValueNames, removeUserValue, setUserValue
ClientDocument getClientDocument()
ItsNatDocument getItsNatDocument()
void notifyClient()
This method may be called by a non-servlet based thread, and no
synchronization of the ItsNatDocument
is necessary.
The client thread is woke up to send document modifications to the client and a new web request is sent to the document again to wait a new notification.
void stop()
A stopped Comet notifier is invalid and cannot be reused.
boolean isStopped()
stop()
or the associated document was destroyed.long getExpirationDelay()
This limit is defined to avoid an unlimited wait because the notifier process has ended and the notifier was not explicitly stopped.
setExpirationDelay(long)
void setExpirationDelay(long expirationDelay)
expirationDelay
- the maximum expiration delay in milliseconds.getExpirationDelay()
long getEventTimeout()
This is the maximum time a stalled COMET request will wait to receive
a notification, if this limit is reached the last request is aborted
stopping the COMET process. If a timeout is defined this value should be greater than getExpirationDelay()
.
COMET events are ever asynchronous.
void addEventListener(org.w3c.dom.events.EventListener listener)
This method is not synchronized and must be called from a web request thread (in this context this method is thread safe because the ItsNat document is automatically synchronized).
Event listeners are dispatched using a web request thread, therefore the ItsNat document object is already synchronized and Java code can be the same as a normal event processing.
The event object used when dispatching the listener is a not a "real" DOM client event and most of methods have no meaning.
listener
- the listener to add.removeEventListener(EventListener)
void removeEventListener(org.w3c.dom.events.EventListener listener)
This method is not synchronized and must be called from a web request thread (in this context this method is thread safe because the ItsNat document is automatically synchronized).
listener
- the listener to remove.addEventListener(EventListener)
Copyright © 2007 Innowhere Software Services S.L. All Rights Reserved.