|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectAbstractLifeCycle
org.cometd.client.BayeuxClient
public class BayeuxClient
Bayeux protocol Client.
Implements a Bayeux Ajax Push client as part of the cometd project.
The HttpClient attributes are used to share a Timer and MessagePool instance between all Bayeux clients sharing the same HttpClient.
http://cometd.org
Nested Class Summary | |
---|---|
protected class |
BayeuxClient.Connect
The Bayeux Connect exchange. |
protected class |
BayeuxClient.Exchange
The base class for all bayeux exchanges. |
protected class |
BayeuxClient.Handshake
The Bayeux handshake exchange. |
protected class |
BayeuxClient.Publish
Publish message exchange. |
Field Summary | |
---|---|
protected MessagePool |
_msgPool
|
Constructor Summary | |
---|---|
BayeuxClient(HttpClient client,
Address address,
java.lang.String uri)
|
|
BayeuxClient(HttpClient client,
Address address,
java.lang.String path,
java.util.Timer timer)
|
|
BayeuxClient(HttpClient client,
java.lang.String url)
|
|
BayeuxClient(HttpClient client,
java.lang.String url,
java.util.Timer timer)
|
Method Summary | |
---|---|
void |
addExtension(Extension ext)
Adds a bayeux client extension. |
void |
addListener(ClientListener listener)
Adds a listener. |
protected void |
customize(HttpExchange exchange)
Customize an Exchange. |
void |
deliver(Client from,
Message message)
(non-Javadoc) |
void |
deliver(Client from,
java.lang.String toChannel,
java.lang.Object data,
java.lang.String id)
Delivers a message to the remote client represented by this object. |
void |
disconnect()
Disconnect this client. |
protected void |
doStart()
|
protected void |
doStop()
|
void |
endBatch()
Ends a batch of messages. |
protected void |
extendIn(Message message)
Called to extend inbound messages |
protected void |
extendOut(Message message)
Called to extend outbound messages |
protected java.lang.String |
extendOut(java.lang.String msg)
Called to extend outbound string messages. |
int |
getBackoffIncrement()
|
int |
getBackoffInterval()
|
int |
getBackoffMaxInterval()
|
int |
getBackoffMaxRetries()
Deprecated. |
javax.servlet.http.Cookie |
getCookie(java.lang.String name)
|
java.lang.String |
getId()
|
Listener |
getListener()
Deprecated. |
int |
getMaxQueue()
|
java.util.Queue<Message> |
getQueue()
|
boolean |
hasMessages()
|
protected boolean |
isInitialized()
|
boolean |
isLocal()
|
boolean |
isPolling()
|
protected void |
metaConnect(boolean success,
Message message)
Called with the results of a /meta/connect message |
protected void |
metaHandshake(boolean success,
boolean reestablish,
Message message)
Called with the results of a /meta/handshake message |
protected void |
metaPublishFail(java.lang.Throwable e,
Message[] messages)
Called with the results of a failed publish |
void |
publish(java.lang.String toChannel,
java.lang.Object data,
java.lang.String msgId)
|
void |
remove()
Deprecated. use disconnect() |
void |
removeExtension(Extension ext)
Removes a bayeux client extension. |
void |
removeListener(ClientListener listener)
Removes a listener |
protected boolean |
send(BayeuxClient.Exchange exchange,
boolean backoff)
Send the exchange, possibly using a backoff. |
protected void |
send(HttpExchange exchange)
Send the exchange. |
void |
setBackoffIncrement(int interval)
. |
void |
setBackOffInterval(int interval)
If unable to connect/handshake etc, even if following the interval in the advice, wait for this interval initially, and try again. |
void |
setBackoffMaxInterval(int interval)
|
void |
setBackoffMaxRetries(int retries)
Deprecated. We retry an infinite number of times. use getBackoffIncrement() to set limits |
void |
setCookie(javax.servlet.http.Cookie cookie)
|
protected void |
setInitialized(boolean b)
False when we have received a success=false message in response to a Connect, or we have had an exception when sending or receiving a Connect. |
void |
setListener(Listener listener)
Deprecated. |
void |
setMaxQueue(int max)
|
void |
startBatch()
Starts a batch of messages. |
void |
subscribe(java.lang.String toChannel)
|
java.util.List<Message> |
takeMessages()
Takes any messages queued for a client. |
void |
unsubscribe(java.lang.String toChannel)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected MessagePool _msgPool
Constructor Detail |
---|
public BayeuxClient(HttpClient client, java.lang.String url)
public BayeuxClient(HttpClient client, java.lang.String url, java.util.Timer timer)
public BayeuxClient(HttpClient client, Address address, java.lang.String path, java.util.Timer timer)
public BayeuxClient(HttpClient client, Address address, java.lang.String uri)
Method Detail |
---|
public void addExtension(Extension ext)
Client
addExtension
in interface Client
ext
- the extension to addClient.removeExtension(Extension)
public void removeExtension(Extension ext)
Client
removeExtension
in interface Client
ext
- the extension to remove��Client.addExtension(Extension)
public void setBackOffInterval(int interval)
interval
- public int getBackoffInterval()
public void setBackoffMaxRetries(int retries)
getBackoffIncrement()
to set limits
public int getBackoffMaxRetries()
public void setBackoffIncrement(int interval)
public int getBackoffIncrement()
public void setBackoffMaxInterval(int interval)
public int getBackoffMaxInterval()
public java.lang.String getId()
getId
in interface Client
protected void doStart() throws java.lang.Exception
java.lang.Exception
protected void doStop() throws java.lang.Exception
java.lang.Exception
public boolean isPolling()
public void deliver(Client from, Message message)
public void deliver(Client from, java.lang.String toChannel, java.lang.Object data, java.lang.String id)
Client
deliver
in interface Client
from
- the Client that sends the messagetoChannel
- the channel onto which the message is sentdata
- the data of the messageid
- the message IDpublic Listener getListener()
public boolean hasMessages()
hasMessages
in interface Client
public boolean isLocal()
isLocal
in interface Client
public void publish(java.lang.String toChannel, java.lang.Object data, java.lang.String msgId)
public void subscribe(java.lang.String toChannel)
public void unsubscribe(java.lang.String toChannel)
public void remove()
disconnect()
public void disconnect()
disconnect
in interface Client
public void setListener(Listener listener)
public java.util.List<Message> takeMessages()
Client
takeMessages
in interface Client
public void endBatch()
Client
Client.startBatch()
is called.
Batches may be nested and messages are only sent once all batches are ended.
endBatch
in interface Client
Client.startBatch()
public void startBatch()
Client
Client.endBatch()
is called.
Batches may be nested and messages are only sent once all batches are ended.
startBatch
in interface Client
Client.endBatch()
protected void customize(HttpExchange exchange)
public void setCookie(javax.servlet.http.Cookie cookie)
public javax.servlet.http.Cookie getCookie(java.lang.String name)
public void addListener(ClientListener listener)
Client
addListener
in interface Client
listener
- the listener to addClient.removeListener(ClientListener)
public void removeListener(ClientListener listener)
Client
removeListener
in interface Client
listener
- the listener to removeClient.addListener(ClientListener)
public int getMaxQueue()
getMaxQueue
in interface Client
Client.setMaxQueue(int)
public java.util.Queue<Message> getQueue()
getQueue
in interface Client
public void setMaxQueue(int max)
setMaxQueue
in interface Client
max
- The size which if a client queue exceeds, forces a call to
QueueListener.queueMaxed(Client, Client, Message)
to check if the message should be added.
If set to -1, there is no queue limit. If set to zero, messages are not queued.Client.getMaxQueue()
protected boolean send(BayeuxClient.Exchange exchange, boolean backoff)
exchange
- backoff
- if true, use backoff algorithm to send
protected void send(HttpExchange exchange) throws java.io.IOException
exchange
-
java.io.IOException
protected void setInitialized(boolean b)
b
- protected boolean isInitialized()
protected void metaConnect(boolean success, Message message)
success
- connect was returned with this statusprotected void metaHandshake(boolean success, boolean reestablish, Message message)
success
- connect was returned with this statusreestablish
- the client was previously connected.protected void metaPublishFail(java.lang.Throwable e, Message[] messages)
protected java.lang.String extendOut(java.lang.String msg)
extendOut(Message)
method to efficiently cater for these
preformatted strings.
This method calls the Extension
s added by addExtension(Extension)
msg
-
protected void extendOut(Message message)
This method calls the Extension
s added by addExtension(Extension)
protected void extendIn(Message message)
This method calls the Extension
s added by addExtension(Extension)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |