org.granite.gravity
Class AbstractChannel

java.lang.Object
  extended by org.granite.gravity.AbstractChannel
All Implemented Interfaces:
Channel
Direct Known Subclasses:
AsyncChannel, ContinuationChannel, GenericChannel, JBossWebChannel, TomcatChannel, WebLogicChannel

public abstract class AbstractChannel
extends Object
implements Channel

Author:
Franck WOLFF

Field Summary
protected  String id
           
protected  LinkedList<AsyncPublishedMessage> publishedQueue
           
protected  Lock publishedQueueLock
           
protected  AsyncPublisher publisher
           
protected  LinkedList<AsyncMessage> receivedQueue
           
protected  Lock receivedQueueLock
           
protected  AsyncReceiver receiver
           
protected  ServletConfig servletConfig
           
protected  ConcurrentMap<String,Subscription> subscriptions
           
 
Constructor Summary
protected AbstractChannel(ServletConfig servletConfig, GravityConfig gravityConfig, String id)
           
 
Method Summary
protected abstract  AsyncHttpContext acquireAsyncHttpContext()
           
 Subscription addSubscription(String destination, String subTopicId, String subscriptionId, boolean noLocal)
           
 void destroy()
           
 boolean equals(Object obj)
           
 Gravity getGravity()
           
 String getId()
           
protected  ServletConfig getServletConfig()
           
protected  ServletContext getServletContext()
           
 Collection<Subscription> getSubscriptions()
           
protected abstract  boolean hasAsyncHttpContext()
           
 int hashCode()
           
 boolean hasPublishedMessage()
           
 boolean hasReceivedMessage()
           
 void publish(AsyncPublishedMessage message)
           
protected  boolean queueReceiver()
           
 void receive(AsyncMessage message)
           
protected abstract  void releaseAsyncHttpContext(AsyncHttpContext context)
           
 Subscription removeSubscription(String subscriptionId)
           
 boolean runPublish()
           
 boolean runReceive()
           
 boolean runReceived(AsyncHttpContext asyncHttpContext)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected final String id

servletConfig

protected final ServletConfig servletConfig

subscriptions

protected final ConcurrentMap<String,Subscription> subscriptions

publishedQueue

protected LinkedList<AsyncPublishedMessage> publishedQueue

publishedQueueLock

protected final Lock publishedQueueLock

receivedQueue

protected LinkedList<AsyncMessage> receivedQueue

receivedQueueLock

protected final Lock receivedQueueLock

publisher

protected final AsyncPublisher publisher

receiver

protected final AsyncReceiver receiver
Constructor Detail

AbstractChannel

protected AbstractChannel(ServletConfig servletConfig,
                          GravityConfig gravityConfig,
                          String id)
Method Detail

hasAsyncHttpContext

protected abstract boolean hasAsyncHttpContext()

acquireAsyncHttpContext

protected abstract AsyncHttpContext acquireAsyncHttpContext()

releaseAsyncHttpContext

protected abstract void releaseAsyncHttpContext(AsyncHttpContext context)

getId

public String getId()
Specified by:
getId in interface Channel

getGravity

public Gravity getGravity()
Specified by:
getGravity in interface Channel

addSubscription

public Subscription addSubscription(String destination,
                                    String subTopicId,
                                    String subscriptionId,
                                    boolean noLocal)
Specified by:
addSubscription in interface Channel

getSubscriptions

public Collection<Subscription> getSubscriptions()
Specified by:
getSubscriptions in interface Channel

removeSubscription

public Subscription removeSubscription(String subscriptionId)
Specified by:
removeSubscription in interface Channel

publish

public void publish(AsyncPublishedMessage message)
             throws MessagePublishingException
Specified by:
publish in interface Channel
Throws:
MessagePublishingException

hasPublishedMessage

public boolean hasPublishedMessage()
Specified by:
hasPublishedMessage in interface Channel

runPublish

public boolean runPublish()
Specified by:
runPublish in interface Channel

receive

public void receive(AsyncMessage message)
             throws MessageReceivingException
Specified by:
receive in interface Channel
Throws:
MessageReceivingException

hasReceivedMessage

public boolean hasReceivedMessage()
Specified by:
hasReceivedMessage in interface Channel

runReceive

public boolean runReceive()
Specified by:
runReceive in interface Channel

runReceived

public boolean runReceived(AsyncHttpContext asyncHttpContext)
Specified by:
runReceived in interface Channel

destroy

public void destroy()
Specified by:
destroy in interface Channel

queueReceiver

protected boolean queueReceiver()

getServletConfig

protected ServletConfig getServletConfig()

getServletContext

protected ServletContext getServletContext()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object