org.apache.tomcat.bayeux
Class ClientImpl

java.lang.Object
  extended by org.apache.tomcat.bayeux.ClientImpl
All Implemented Interfaces:
Client

public class ClientImpl
extends java.lang.Object
implements Client


Field Summary
static java.lang.String COMET_EVENT_ATTR
           
protected  int desirectConnType
          The desired connection type
protected static java.util.LinkedList<Message> EMPTY_LIST
           
protected  org.jboss.servlet.http.HttpEvent event
          Currently associated event.
protected  java.lang.String id
          Unique id representing this client
protected  Listener listener
          The callback object for local clients
protected  boolean local
          Same JVM clients, get local=true
protected  java.util.LinkedList<Message> messages
          queued message for remote clients.
protected  java.util.concurrent.atomic.AtomicInteger nrofsubscriptions
           
static int SUPPORT_CALLBACK_POLL
           
static int SUPPORT_LONG_POLL
           
protected  int supportedConnTypes
          supported connection types, defaults to long-polling
protected  boolean useJsonFiltered
          Does this client use json-comment-filtered messages
 
Constructor Summary
protected ClientImpl(java.lang.String id, boolean local)
           
 
Method Summary
protected  void addCometEvent(org.jboss.servlet.http.HttpEvent event)
           
 void deliver(Message message)
          Deliver a message to this client only Deliver a message directly to the client.
 void deliver(Message[] message)
          Deliver a batch of messages to this client only Deliver a batch messages directly to the client.
protected  void deliverInternal(ChannelImpl channel, Message[] msgs)
           
protected  void deliverInternal(ChannelImpl channel, MessageImpl message)
           
 void endBatch()
          Ends a batch. since batches can be nested, messages will only be delivered after the endBatch has been called as many times as startBatch has.
 int getDesirectConnType()
           
 java.lang.String getId()
          Returns a unique id for this client.
protected  Listener getListener()
           
 int getSupportedConnTypes()
           
 boolean hasMessages()
          Returns true if this client is holding messages to be delivered to the remote client.
 boolean isLocal()
           
 boolean isSubscribed()
           
protected  void removeCometEvent(org.jboss.servlet.http.HttpEvent event)
           
 void setDesirectConnType(int desirectConnType)
           
 void setListener(Listener listener)
           
 void setSupportedConnTypes(int supportedConnTypes)
           
 void setUseJsonFiltered(boolean useJsonFiltered)
           
 void startBatch()
          Starts a batch, no messages will be delivered until endBatch is called.
protected  void subscribed(ChannelImpl ch)
           
 boolean supportsCallbackPoll()
           
 boolean supportsLongPoll()
           
 java.util.List<Message> takeMessages()
           
 java.lang.String toString()
           
protected  void unsubscribed(ChannelImpl ch)
           
 boolean useJsonFiltered()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUPPORT_CALLBACK_POLL

public static final int SUPPORT_CALLBACK_POLL
See Also:
Constant Field Values

SUPPORT_LONG_POLL

public static final int SUPPORT_LONG_POLL
See Also:
Constant Field Values

COMET_EVENT_ATTR

public static final java.lang.String COMET_EVENT_ATTR
See Also:
Constant Field Values

EMPTY_LIST

protected static java.util.LinkedList<Message> EMPTY_LIST

messages

protected java.util.LinkedList<Message> messages
queued message for remote clients.


event

protected org.jboss.servlet.http.HttpEvent event
Currently associated event.


id

protected java.lang.String id
Unique id representing this client


supportedConnTypes

protected int supportedConnTypes
supported connection types, defaults to long-polling


desirectConnType

protected int desirectConnType
The desired connection type


useJsonFiltered

protected boolean useJsonFiltered
Does this client use json-comment-filtered messages


local

protected boolean local
Same JVM clients, get local=true


listener

protected Listener listener
The callback object for local clients


nrofsubscriptions

protected java.util.concurrent.atomic.AtomicInteger nrofsubscriptions
Constructor Detail

ClientImpl

protected ClientImpl(java.lang.String id,
                     boolean local)
Method Detail

deliver

public void deliver(Message message)
Description copied from interface: Client
Deliver a message to this client only Deliver a message directly to the client. The message is not filtered or published to a channel.

Specified by:
deliver in interface Client

deliver

public void deliver(Message[] message)
Description copied from interface: Client
Deliver a batch of messages to this client only Deliver a batch messages directly to the client. The messages are not filtered or published to a channel.

Specified by:
deliver in interface Client

deliverInternal

protected void deliverInternal(ChannelImpl channel,
                               MessageImpl message)

deliverInternal

protected void deliverInternal(ChannelImpl channel,
                               Message[] msgs)

getId

public java.lang.String getId()
Description copied from interface: Client
Returns a unique id for this client. The id is unique within this Bayeux session.

Specified by:
getId in interface Client
Returns:
String - will not be null

getListener

protected Listener getListener()

hasMessages

public boolean hasMessages()
Description copied from interface: Client
Returns true if this client is holding messages to be delivered to the remote client. This method always returns false for local clients, since messages are delivered instantly using the Listener(callback) object

Specified by:
hasMessages in interface Client
Returns:
boolean

isLocal

public boolean isLocal()
Specified by:
isLocal in interface Client
Returns:
True if the client is local. False if this client is either a remote HTTP client or a java client to a remote server.

getSupportedConnTypes

public int getSupportedConnTypes()

getDesirectConnType

public int getDesirectConnType()

useJsonFiltered

public boolean useJsonFiltered()

setListener

public void setListener(Listener listener)

setSupportedConnTypes

public void setSupportedConnTypes(int supportedConnTypes)

setUseJsonFiltered

public void setUseJsonFiltered(boolean useJsonFiltered)

setDesirectConnType

public void setDesirectConnType(int desirectConnType)

supportsCallbackPoll

public boolean supportsCallbackPoll()

supportsLongPoll

public boolean supportsLongPoll()

takeMessages

public java.util.List<Message> takeMessages()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isSubscribed

public boolean isSubscribed()

addCometEvent

protected void addCometEvent(org.jboss.servlet.http.HttpEvent event)

removeCometEvent

protected void removeCometEvent(org.jboss.servlet.http.HttpEvent event)

subscribed

protected void subscribed(ChannelImpl ch)

unsubscribed

protected void unsubscribed(ChannelImpl ch)

startBatch

public void startBatch()
Description copied from interface: Client
Starts a batch, no messages will be delivered until endBatch is called. Batches can be nested, and messages will only be delivered after the last endBatch has been called.

Specified by:
startBatch in interface Client

endBatch

public void endBatch()
Description copied from interface: Client
Ends a batch. since batches can be nested, messages will only be delivered after the endBatch has been called as many times as startBatch has.

Specified by:
endBatch in interface Client


Copyright © 2000-2009 Apache Software Foundation. All Rights Reserved.