org.granite.gravity
Class AbstractChannel

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

public abstract class AbstractChannel
extends Object
implements Channel

Author:
Franck WOLFF

Field Summary
protected  String clientType
           
protected  ChannelFactory<? extends Channel> factory
           
protected  Gravity gravity
           
protected  AsyncReceiver httpReceiver
           
protected  String id
           
protected  LinkedList<AsyncPublishedMessage> publishedQueue
           
protected  Lock publishedQueueLock
           
protected  AsyncPublisher publisher
           
protected  LinkedList<AsyncMessage> receivedQueue
           
protected  Lock receivedQueueLock
           
protected  String sessionId
           
protected  ConcurrentMap<String,Subscription> subscriptions
           
protected  UdpReceiver udpReceiver
           
 
Constructor Summary
protected AbstractChannel(Gravity gravity, String id, ChannelFactory<? extends Channel> factory, String clientType)
           
 
Method Summary
protected abstract  AsyncHttpContext acquireAsyncHttpContext()
           
 Subscription addSubscription(String destination, String subTopicId, String subscriptionId, boolean noLocal)
           
protected  void createUdpReceiver(UdpReceiverFactory factory, AsyncHttpContext asyncHttpContext)
           
 void destroy()
           
 void destroy(boolean timeout)
           
 boolean equals(Object obj)
           
 String getClientType()
           
 ChannelFactory<? extends Channel> getFactory()
           
 Gravity getGravity()
           
 String getId()
           
 String getSerializerContentType()
           
 Collection<Subscription> getSubscriptions()
           
protected abstract  boolean hasAsyncHttpContext()
           
 int hashCode()
           
 boolean hasPublishedMessage()
           
 boolean hasReceivedMessage()
           
 ObjectOutput newSerializer(GraniteContext context, OutputStream os)
           
 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
 
Methods inherited from interface org.granite.gravity.Channel
close
 

Field Detail

id

protected final String id

sessionId

protected final String sessionId

clientType

protected final String clientType

gravity

protected final Gravity gravity

factory

protected final ChannelFactory<? extends Channel> factory

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

httpReceiver

protected final AsyncReceiver httpReceiver

udpReceiver

protected UdpReceiver udpReceiver
Constructor Detail

AbstractChannel

protected AbstractChannel(Gravity gravity,
                          String id,
                          ChannelFactory<? extends Channel> factory,
                          String clientType)
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

getClientType

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

getFactory

public ChannelFactory<? extends Channel> getFactory()
Specified by:
getFactory 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

newSerializer

public ObjectOutput newSerializer(GraniteContext context,
                                  OutputStream os)

getSerializerContentType

public String getSerializerContentType()

createUdpReceiver

protected void createUdpReceiver(UdpReceiverFactory factory,
                                 AsyncHttpContext asyncHttpContext)

runReceived

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

destroy

public void destroy()

destroy

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

queueReceiver

protected boolean queueReceiver()

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