com.sun.grizzly.comet
Class DefaultNotificationHandler

java.lang.Object
  extended by com.sun.grizzly.comet.DefaultNotificationHandler
All Implemented Interfaces:
NotificationHandler
Direct Known Subclasses:
DefaultNotificationHandler

public class DefaultNotificationHandler
extends Object
implements NotificationHandler

Default Notificationhandler that uses a thread pool dedicated to the CometEngine to execute the notification process.

Author:
Jeanfrancois Arcand, Gustav Trede

Field Summary
protected  boolean blockingNotification
          true if the caller of CometContext.notify should block when notifying other CometHandler.
protected  ExecutorService threadPool
          The ExecutorService used to execute threaded notification.
 
Constructor Summary
DefaultNotificationHandler()
           
 
Method Summary
 boolean isBlockingNotification()
          Return true if the invoker of notify() should block when notifying Comet Handlers.
 void notify(CometEvent cometEvent, CometHandler cometHandler)
          Notify the CometHandler.
 void notify(CometEvent cometEvent, Iterator<CometHandler> iteratorHandlers)
          Notify all CometHandler.
protected  void notify0(CometEvent cometEvent, CometHandler cometHandler)
          Notify a CometHandler.
 void setBlockingNotification(boolean blockingNotification)
          Set to true if the invoker of notify() should block when notifying Comet Handlers.
 void setSpreadNotifyToManyToThreads(boolean spreadNotifyToManyToThreads)
          if true a notify to Iterator will be spread into one runnable task for each comethandler.
protected  void setThreadPool(ExecutorService threadPool)
          Set the ExecutorService used for notifying the CometHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threadPool

protected ExecutorService threadPool
The ExecutorService used to execute threaded notification.


blockingNotification

protected boolean blockingNotification
true if the caller of CometContext.notify should block when notifying other CometHandler. false is default

Constructor Detail

DefaultNotificationHandler

public DefaultNotificationHandler()
Method Detail

setThreadPool

protected void setThreadPool(ExecutorService threadPool)
Set the ExecutorService used for notifying the CometHandler.


isBlockingNotification

public boolean isBlockingNotification()
Return true if the invoker of notify() should block when notifying Comet Handlers.

Specified by:
isBlockingNotification in interface NotificationHandler

setBlockingNotification

public void setBlockingNotification(boolean blockingNotification)
Set to true if the invoker of notify() should block when notifying Comet Handlers.

Specified by:
setBlockingNotification in interface NotificationHandler

setSpreadNotifyToManyToThreads

public void setSpreadNotifyToManyToThreads(boolean spreadNotifyToManyToThreads)
if true a notify to Iterator will be spread into one runnable task for each comethandler. if false , all comethandlers notify will be executed in 1 Runnable, after each other,

Parameters:
spreadNotifyToManyToThreads -

notify

public void notify(CometEvent cometEvent,
                   Iterator<CometHandler> iteratorHandlers)
            throws IOException
Notify all CometHandler.

Specified by:
notify in interface NotificationHandler
Parameters:
cometEvent - the CometEvent used to notify CometHandler
iteratorHandlers - An iterator over a list of CometHandler
Throws:
IOException

notify

public void notify(CometEvent cometEvent,
                   CometHandler cometHandler)
            throws IOException
Notify the CometHandler.

Specified by:
notify in interface NotificationHandler
Parameters:
cometEvent - cometEvent the CometEvent used to notify CometHandler
cometHandler -
Throws:
IOException

notify0

protected void notify0(CometEvent cometEvent,
                       CometHandler cometHandler)
Notify a CometHandler. CometEvent.INTERRUPT -> CometHandler.onInterrupt CometEvent.NOTIFY -> CometHandler.onEvent CometEvent.INITIALIZE -> CometHandler.onInitialize CometEvent.TERMINATE -> CometHandler.onTerminate CometEvent.READ -> CometHandler.onEvent CometEvent.WRITE -> CometHandler.onEvent

Parameters:
attachment - An object shared amongst CometHandler.
cometHandler - The CometHandler to invoke.


Copyright © 2012 Oracle Corporation. All Rights Reserved.