Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.cometd.client
Class BayeuxClient

    java.lang.Object
      org.mortbay.component.AbstractLifeCycle
          org.mortbay.cometd.client.BayeuxClient

All Implemented Interfaces:
  org.cometd.Client, LifeCycle

Direct Known Subclasses:
  OortComet

    public class BayeuxClient

extends AbstractLifeCycle
implements org.cometd.Client

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.

Author:
  gregw
See Also:
  `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.

Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle
`LifeCycle.Listener`

Field Summary
`protected Address` | `_cometdAddress`
`protected org.cometd.Extension[]` | `_extensions`
`protected HttpClient` | `_httpClient`
`protected JSON` | `_jsonOut`
`protected MessagePool` | `_msgPool`

Fields inherited from class org.mortbay.component.AbstractLifeCycle
`_listeners`

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(org.cometd.Extension ext)`
`void` | `addListener(org.cometd.ClientListener listener)`
`protected void` | `customize(HttpExchange exchange)` Customize an Exchange.
`void` | `deliver(org.cometd.Client from, org.cometd.Message message)` (non-Javadoc)
`void` | `deliver(org.cometd.Client from, java.lang.String toChannel, java.lang.Object data, java.lang.String id)`
`void` | `disconnect()` Disconnect this client.
`protected void` | `doStart()`
`protected void` | `doStop()`
`void` | `endBatch()`
`protected void` | `extendIn(org.cometd.Message message)` Called to extend inbound messages
`protected void` | `extendOut(org.cometd.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()`
`org.cometd.Listener` | `getListener()` Deprecated.
`int` | `getMaxQueue()`
`java.util.Queue<org.cometd.Message>` | `getQueue()`
`boolean` | `hasMessages()`
`protected boolean` | `isInitialized()`
`boolean` | `isLocal()`
`boolean` | `isPolling()`
`protected void` | `metaConnect(boolean success, org.cometd.Message message)` Called with the results of a /meta/connect message
`protected void` | `metaHandshake(boolean success, boolean reestablish, org.cometd.Message message)` Called with the results of a /meta/handshake message
`protected void` | `metaPublishFail(java.lang.Throwable e, org.cometd.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(org.cometd.Extension extension)`
`void` | `removeListener(org.cometd.ClientListener 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(org.cometd.Listener listener)` Deprecated.
`void` | `setMaxQueue(int max)`
`void` | `startBatch()`
`void` | `subscribe(java.lang.String toChannel)`
`java.util.List<org.cometd.Message>` | `takeMessages()`
`void` | `unsubscribe(java.lang.String toChannel)`

Methods inherited from class org.mortbay.component.AbstractLifeCycle
`addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _httpClient

    protected HttpClient _httpClient

### _msgPool

    protected MessagePool _msgPool

### _cometdAddress

    protected Address _cometdAddress

### _extensions

    protected org.cometd.Extension[] _extensions

### _jsonOut

    protected JSON _jsonOut

Constructor Detail

### BayeuxClient

    public BayeuxClient(HttpClient client,
                        java.lang.String url)

### BayeuxClient

    public BayeuxClient(HttpClient client,
                        java.lang.String url,
                        java.util.Timer timer)

### BayeuxClient

    public BayeuxClient(HttpClient client,
                        Address address,
                        java.lang.String path,
                        java.util.Timer timer)

### BayeuxClient

    public BayeuxClient(HttpClient client,
                        Address address,
                        java.lang.String uri)

Method Detail

### addExtension

    public void addExtension(org.cometd.Extension ext)

  Specified by:
    `addExtension` in interface `org.cometd.Client`

### removeExtension

    public void removeExtension(org.cometd.Extension extension)

  Specified by:
    `removeExtension` in interface `org.cometd.Client`

### setBackOffInterval

    public 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.

  Parameters:
    `interval` -

### getBackoffInterval

    public int getBackoffInterval()

  Returns:
    the backoff interval to wait before retrying an unsuccessful or failed message

### setBackoffMaxRetries

    public void setBackoffMaxRetries(int retries)

  Deprecated. We retry an infinite number of times. use `getBackoffIncrement()` to set limits

### getBackoffMaxRetries

    public int getBackoffMaxRetries()

  Deprecated.

### setBackoffIncrement

    public void setBackoffIncrement(int interval)

  . Each retry will increment by this intervel, until we reach _backoffMaxInterval

### getBackoffIncrement

    public int getBackoffIncrement()

  Returns:
    the backoff interval used to increase the backoff time when retrying an unsuccessful or failed message.

### setBackoffMaxInterval

    public void setBackoffMaxInterval(int interval)

### getBackoffMaxInterval

    public int getBackoffMaxInterval()

### getId

    public java.lang.String getId()

  Specified by:
    `getId` in interface `org.cometd.Client`

### doStart

    protected void doStart()
                    throws java.lang.Exception

  Overrides:
    `doStart` in class `AbstractLifeCycle`
  Throws:
    `java.lang.Exception`

### doStop

    protected void doStop()
                   throws java.lang.Exception

  Overrides:
    `doStop` in class `AbstractLifeCycle`
  Throws:
    `java.lang.Exception`

### isPolling

    public boolean isPolling()

### deliver

    public void deliver(org.cometd.Client from,
                        org.cometd.Message message)

  (non-Javadoc)

### deliver

    public void deliver(org.cometd.Client from,
                        java.lang.String toChannel,
                        java.lang.Object data,
                        java.lang.String id)

  Specified by:
    `deliver` in interface `org.cometd.Client`

### getListener

    public org.cometd.Listener getListener()

  Deprecated.

### hasMessages

    public boolean hasMessages()

  Specified by:
    `hasMessages` in interface `org.cometd.Client`

### isLocal

    public boolean isLocal()

  Specified by:
    `isLocal` in interface `org.cometd.Client`

### publish

    public void publish(java.lang.String toChannel,
                        java.lang.Object data,
                        java.lang.String msgId)

### subscribe

    public void subscribe(java.lang.String toChannel)

### unsubscribe

    public void unsubscribe(java.lang.String toChannel)

### remove

    public void remove()

  Deprecated. use `disconnect()`

  Disconnect this client.

### disconnect

    public void disconnect()

  Disconnect this client.

  Specified by:
    `disconnect` in interface `org.cometd.Client`

### setListener

    public void setListener(org.cometd.Listener listener)

  Deprecated.

### takeMessages

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

  Specified by:
    `takeMessages` in interface `org.cometd.Client`

### endBatch

    public void endBatch()

  Specified by:
    `endBatch` in interface `org.cometd.Client`

### startBatch

    public void startBatch()

  Specified by:
    `startBatch` in interface `org.cometd.Client`

### customize

    protected void customize(HttpExchange exchange)

  Customize an Exchange. Called when an exchange is about to be sent to allow Cookies and Credentials to be customized. Default implementation sets any cookies

### setCookie

    public void setCookie(javax.servlet.http.Cookie cookie)

### getCookie

    public javax.servlet.http.Cookie getCookie(java.lang.String name)

### addListener

    public void addListener(org.cometd.ClientListener listener)

  Specified by:
    `addListener` in interface `org.cometd.Client`

### removeListener

    public void removeListener(org.cometd.ClientListener listener)

  Specified by:
    `removeListener` in interface `org.cometd.Client`

### getMaxQueue

    public int getMaxQueue()

  Specified by:
    `getMaxQueue` in interface `org.cometd.Client`

### getQueue

    public java.util.Queue<org.cometd.Message> getQueue()

  Specified by:
    `getQueue` in interface `org.cometd.Client`

### setMaxQueue

    public void setMaxQueue(int max)

  Specified by:
    `setMaxQueue` in interface `org.cometd.Client`

### send

    protected boolean send(BayeuxClient.Exchange exchange,
                           boolean backoff)

  Send the exchange, possibly using a backoff.

  Parameters:
    `exchange` -
    `backoff` - if true, use backoff algorithm to send
  Returns:

### send

    protected void send(HttpExchange exchange)
                 throws java.io.IOException

  Send the exchange.

  Parameters:
    `exchange` -
  Throws:
    `java.io.IOException`

### setInitialized

    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. True when handshake and then connect has happened.

  Parameters:
    `b` -

### isInitialized

    protected boolean isInitialized()

### metaConnect

    protected void metaConnect(boolean success,
                               org.cometd.Message message)

  Called with the results of a /meta/connect message

  Parameters:
    `success` - connect was returned with this status

### metaHandshake

    protected void metaHandshake(boolean success,
                                 boolean reestablish,
                                 org.cometd.Message message)

  Called with the results of a /meta/handshake message

  Parameters:
    `success` - connect was returned with this status
    `reestablish` - the client was previously connected.

### metaPublishFail

    protected void metaPublishFail(java.lang.Throwable e,
                                   org.cometd.Message[] messages)

  Called with the results of a failed publish

### extendOut

    protected java.lang.String extendOut(java.lang.String msg)

  Called to extend outbound string messages. Some messages are sent as preformatted JSON strings (eg handshake and connect messages). This extendOut method is a variation of the `extendOut(Message)` method to efficiently cater for these preformatted strings.

  This method calls the `Extension`s added by `addExtension(Extension)`

  Parameters:
    `msg` -
  Returns:
    the extended message

### extendOut

    protected void extendOut(org.cometd.Message message)

  Called to extend outbound messages

  This method calls the `Extension`s added by `addExtension(Extension)`

### extendIn

    protected void extendIn(org.cometd.Message message)

  Called to extend inbound messages

  This method calls the `Extension`s added by `addExtension(Extension)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.