org.mortbay.cometd
Class AbstractBayeux

java.lang.Object
  extended by org.mortbay.cometd.AbstractBayeux
All Implemented Interfaces:
Bayeux

public abstract class AbstractBayeux
extends Object
implements Bayeux

Author:
gregw, aabeling: added JSONP transport

Field Summary
static String ADVICE_FIELD
           
static String CHANNEL_FIELD
           
static String CLIENT_FIELD
           
static String DATA_FIELD
           
static String EXT_FIELD
           
static String ID_FIELD
           
static String META
           
static String META_CONNECT
           
static ChannelId META_CONNECT_ID
           
static String META_DISCONNECT
           
static ChannelId META_DISCONNECT_ID
           
static String META_HANDSHAKE
           
static ChannelId META_HANDSHAKE_ID
           
static String META_PING
           
static ChannelId META_PING_ID
           
static String META_RECONNECT
           
static ChannelId META_RECONNECT_ID
           
static String META_STATUS
           
static ChannelId META_STATUS_ID
           
static String META_SUBSCRIBE
           
static ChannelId META_SUBSCRIBE_ID
           
static String META_UNSUBSCRIBE
           
static ChannelId META_UNSUBSCRIBE_ID
           
static String SUBSCRIPTION_FIELD
           
static String SUCCESSFUL_FIELD
           
static String TIMESTAMP_FIELD
           
static String TRANSPORT_FIELD
           
static JSON.Literal TRANSPORTS
           
 
Fields inherited from interface dojox.cometd.Bayeux
DOJOX_COMETD_BAYEUX
 
Constructor Summary
protected AbstractBayeux()
           
 
Method Summary
 void addFilter(String channels, DataFilter filter)
           
 void advise(Client client, Transport transport, Object advice)
          Send advice to a client
 boolean getAlwaysResumePoll()
           
 ChannelImpl getChannel(ChannelId id)
           
 ChannelImpl getChannel(String id)
           
 Channel getChannel(String id, boolean create)
           
 ChannelId getChannelId(String id)
           
 Client getClient(String client_id)
           
 Set getClientIDs()
           
 long getClientTimeoutMs()
           
 int getLogLevel()
           
protected  long getRandom(long variation)
           
 SecurityPolicy getSecurityPolicy()
           
 String handle(ClientImpl client, Transport transport, Map<String,Object> message)
          Handle a Bayeux message.
 boolean hasChannel(String id)
           
protected  void initialize(ServletContext context)
           
 boolean isInitialized()
           
 boolean isJSONCommented()
           
 boolean isLogDebug()
           
 boolean isLogInfo()
           
 void logDebug(String message)
           
 void logDebug(String message, Throwable th)
           
 void logInfo(String message)
           
 Client newClient(String idPrefix, Listener listener)
           
abstract  ClientImpl newRemoteClient()
           
 Transport newTransport(ClientImpl client, Map message)
          Create new transport object for a bayeux message
 void publish(ChannelId to, Client from, Object data, String msgId)
           
 void publish(Client fromClient, String toChannelId, Object data, String msgId)
          Deliver data to a channel.
 boolean removeChannel(ChannelId channelId)
           
 void removeFilter(String channels, DataFilter filter)
           
 void setAlwaysResumePoll(boolean always)
           
 void setClientTimeoutMs(long ms)
           
 void setJSONCommented(boolean commented)
           
 void setLogLevel(int logLevel)
           
 void setSecurityPolicy(SecurityPolicy securityPolicy)
           
 void subscribe(String toChannel, Client subscriber)
          Subscribe to a channel.
 void unsubscribe(String toChannel, Client subscriber)
          Unsubscribe to a channel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

META

public static final String META
See Also:
Constant Field Values

META_CONNECT

public static final String META_CONNECT
See Also:
Constant Field Values

META_DISCONNECT

public static final String META_DISCONNECT
See Also:
Constant Field Values

META_HANDSHAKE

public static final String META_HANDSHAKE
See Also:
Constant Field Values

META_PING

public static final String META_PING
See Also:
Constant Field Values

META_RECONNECT

public static final String META_RECONNECT
See Also:
Constant Field Values

META_STATUS

public static final String META_STATUS
See Also:
Constant Field Values

META_SUBSCRIBE

public static final String META_SUBSCRIBE
See Also:
Constant Field Values

META_UNSUBSCRIBE

public static final String META_UNSUBSCRIBE
See Also:
Constant Field Values

CLIENT_FIELD

public static final String CLIENT_FIELD
See Also:
Constant Field Values

DATA_FIELD

public static final String DATA_FIELD
See Also:
Constant Field Values

CHANNEL_FIELD

public static final String CHANNEL_FIELD
See Also:
Constant Field Values

ID_FIELD

public static final String ID_FIELD
See Also:
Constant Field Values

TIMESTAMP_FIELD

public static final String TIMESTAMP_FIELD
See Also:
Constant Field Values

TRANSPORT_FIELD

public static final String TRANSPORT_FIELD
See Also:
Constant Field Values

ADVICE_FIELD

public static final String ADVICE_FIELD
See Also:
Constant Field Values

SUCCESSFUL_FIELD

public static final String SUCCESSFUL_FIELD
See Also:
Constant Field Values

SUBSCRIPTION_FIELD

public static final String SUBSCRIPTION_FIELD
See Also:
Constant Field Values

EXT_FIELD

public static final String EXT_FIELD
See Also:
Constant Field Values

META_CONNECT_ID

public static final ChannelId META_CONNECT_ID

META_DISCONNECT_ID

public static final ChannelId META_DISCONNECT_ID

META_HANDSHAKE_ID

public static final ChannelId META_HANDSHAKE_ID

META_PING_ID

public static final ChannelId META_PING_ID

META_RECONNECT_ID

public static final ChannelId META_RECONNECT_ID

META_STATUS_ID

public static final ChannelId META_STATUS_ID

META_SUBSCRIBE_ID

public static final ChannelId META_SUBSCRIBE_ID

META_UNSUBSCRIBE_ID

public static final ChannelId META_UNSUBSCRIBE_ID

TRANSPORTS

public static final JSON.Literal TRANSPORTS
Constructor Detail

AbstractBayeux

protected AbstractBayeux()
Parameters:
context. - The logLevel init parameter is used to set the logging to 0=none, 1=info, 2=debug
Method Detail

addFilter

public void addFilter(String channels,
                      DataFilter filter)
Specified by:
addFilter in interface Bayeux
Parameters:
channels - A ChannelId
filter - The filter instance to apply to new channels matching the pattern

removeFilter

public void removeFilter(String channels,
                         DataFilter filter)
Specified by:
removeFilter in interface Bayeux

getChannel

public ChannelImpl getChannel(ChannelId id)
Parameters:
id -
Returns:

getChannel

public ChannelImpl getChannel(String id)

getChannel

public Channel getChannel(String id,
                          boolean create)
Specified by:
getChannel in interface Bayeux

getChannelId

public ChannelId getChannelId(String id)

getClient

public Client getClient(String client_id)
Specified by:
getClient in interface Bayeux
Returns:

getClientIDs

public Set getClientIDs()

getClientTimeoutMs

public long getClientTimeoutMs()

getLogLevel

public int getLogLevel()
Returns:
the logLevel. 0=none, 1=info, 2=debug

getSecurityPolicy

public SecurityPolicy getSecurityPolicy()

handle

public String handle(ClientImpl client,
                     Transport transport,
                     Map<String,Object> message)
              throws IOException
Handle a Bayeux message. This is normally only called by the bayeux servlet or a test harness.

Parameters:
client - The client if known
transport - The transport to use for the message
message - The bayeux message.
Throws:
IOException

hasChannel

public boolean hasChannel(String id)
Specified by:
hasChannel in interface Bayeux

isInitialized

public boolean isInitialized()

isJSONCommented

public boolean isJSONCommented()
Returns:
the commented

isLogDebug

public boolean isLogDebug()

isLogInfo

public boolean isLogInfo()

logDebug

public void logDebug(String message)

logDebug

public void logDebug(String message,
                     Throwable th)

logInfo

public void logInfo(String message)

newClient

public Client newClient(String idPrefix,
                        Listener listener)
Specified by:
newClient in interface Bayeux
Returns:

newRemoteClient

public abstract ClientImpl newRemoteClient()

newTransport

public Transport newTransport(ClientImpl client,
                              Map message)
Create new transport object for a bayeux message

Parameters:
client - The client
message - the bayeux message
Returns:
the negotiated transport.

publish

public void publish(ChannelId to,
                    Client from,
                    Object data,
                    String msgId)

publish

public void publish(Client fromClient,
                    String toChannelId,
                    Object data,
                    String msgId)
Description copied from interface: Bayeux
Deliver data to a channel.

Specified by:
publish in interface Bayeux
Parameters:
fromClient - The client sending the data
toChannelId - The Channel ID to which the data is targetted
data - The data itself which must be an Object that can be encoded with JSON.
msgId - optional message ID or null for automatic generation of a message ID.

removeChannel

public boolean removeChannel(ChannelId channelId)

setClientTimeoutMs

public void setClientTimeoutMs(long ms)

setJSONCommented

public void setJSONCommented(boolean commented)
Parameters:
commented - the commented to set

setLogLevel

public void setLogLevel(int logLevel)
Parameters:
logLevel - the logLevel: 0=none, 1=info, 2=debug

setSecurityPolicy

public void setSecurityPolicy(SecurityPolicy securityPolicy)

subscribe

public void subscribe(String toChannel,
                      Client subscriber)
Description copied from interface: Bayeux
Subscribe to a channel. Equivalent to getChannel(toChannel).subscribe(subscriber).

Specified by:
subscribe in interface Bayeux

unsubscribe

public void unsubscribe(String toChannel,
                        Client subscriber)
Description copied from interface: Bayeux
Unsubscribe to a channel

Specified by:
unsubscribe in interface Bayeux

initialize

protected void initialize(ServletContext context)

advise

public void advise(Client client,
                   Transport transport,
                   Object advice)
            throws IOException
Send advice to a client

Parameters:
client - The client to send the advice to
transport - The transport to use
advice - The advice to send.
Throws:
IOException

getRandom

protected long getRandom(long variation)

getAlwaysResumePoll

public boolean getAlwaysResumePoll()

setAlwaysResumePoll

public void setAlwaysResumePoll(boolean always)
Parameters:
always - True if polls are always resumed when messages are received. This may be needed for some cross domain transports.


Copyright © 2007 Mort Bay Consulting. All Rights Reserved.