## org.cometd.oort
Class Oort

    java.lang.Object
      org.mortbay.component.AbstractLifeCycle
          org.cometd.oort.Oort

All Implemented Interfaces:
  LifeCycle

    public class Oort

extends AbstractLifeCycle

Oort cluster of cometd servers.

This class maintains a collection of `OortComet` instances to each comet server identified by calls to `observeComet(String)`. The Oort instance is created and configured by `OortServlet`.

The key configuration parameter that must be set is the Oort URL, which is full public URL to the cometd servlet, eg. http://myserver:8080/context/cometd See `OortServlet` for more configuration detail.

Author:
  gregw

Nested Class Summary
`protected class` `Oort.OortExtension` Extension to detect incoming handshake from other Oort servers and to call `oortHandshook(String, String, String)`.
`protected class` `Oort.RemoteOortClientExtension` An Extension installed on clients for remote Oort servers that prevents publish loops.
`protected class` `Oort.RootOortClientListener` MessageListener that handles publishes to /oort/cloud

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

Field Summary
`protected org.cometd.Bayeux` `_bayeux`
`protected java.util.Set<java.lang.String>` `_channels`
`protected HttpClient` `_httpClient`
`protected java.util.Map<java.lang.String,OortComet>` `_knownCommets`
`protected org.cometd.Client` `_oortClient`
`protected java.util.List<org.cometd.MessageListener>` `_oortMessageListeners`
`protected java.util.Random` `_random`
`protected java.lang.String` `_secret`
`protected java.util.Timer` `_timer`
`protected java.lang.String` `_url`
`static java.lang.String` `OORT_ATTRIBUTE`
`static java.lang.String` `OORT_CHANNELS`
`static java.lang.String` `OORT_CLOUD`
`static java.lang.String` `OORT_URL`

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

Method Summary
`void` `addOortMessageListener(org.cometd.MessageListener listener)` Add a MessageListener that will receive all messages published on /oort/* channels on connected OortComets
`protected void` `doStart()`
`org.cometd.Bayeux` `getBayeux()`
`java.util.Set<java.lang.String>` `getKnownComets()`
`java.lang.String` `getSecret()`
`java.lang.String` `getURL()`
`boolean` `isOort(org.cometd.Client client)`
`void` `observeChannel(java.lang.String channelId)` Observer a channel.
`OortComet` `observeComet(java.lang.String cometUrl)` Observe an Oort Comet server.
`protected void` `oortHandshook(java.lang.String oortUrl, java.lang.String oortSecret, java.lang.String clientId)` Called to register the details of a successful handshake with an Oort comet.
`boolean` `removeOortClientListener(org.cometd.MessageListener listener)` Remove an Oort message listener.
`java.lang.String` `toString()`

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

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

Field Detail

### OORT_URL

    public static final java.lang.String OORT_URL

See Also:
  Constant Field Values

### OORT_CLOUD

    public static final java.lang.String OORT_CLOUD

See Also:
  Constant Field Values

### OORT_CHANNELS

    public static final java.lang.String OORT_CHANNELS

See Also:
  Constant Field Values

### OORT_ATTRIBUTE

    public static final java.lang.String OORT_ATTRIBUTE

See Also:
  Constant Field Values

### _url

    protected java.lang.String _url

### _secret

    protected java.lang.String _secret

### _bayeux

    protected org.cometd.Bayeux _bayeux

### _httpClient

    protected HttpClient _httpClient

### _timer

    protected java.util.Timer _timer

### _random

    protected java.util.Random _random

### _oortClient

    protected org.cometd.Client _oortClient

### _oortMessageListeners

    protected java.util.List<org.cometd.MessageListener> _oortMessageListeners

### _knownCommets

    protected java.util.Map<java.lang.String,OortComet> _knownCommets

### _channels

    protected java.util.Set<java.lang.String> _channels

Method Detail

### getBayeux

    public org.cometd.Bayeux getBayeux()

### getURL

    public java.lang.String getURL()

  Returns:
    The oublic absolute URL of the Oort cometd server.

### getSecret

    public java.lang.String getSecret()

### doStart

    protected void doStart()
                    throws java.lang.Exception

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

### observeComet

    public OortComet observeComet(java.lang.String cometUrl)

  Observe an Oort Comet server.

  The the comet server is not already observed, start a `OortComet` instance for it.

  Parameters:
    `cometUrl` -
  Returns:
    The `OortComet` instance for the comet server.

### getKnownComets

    public java.util.Set<java.lang.String> getKnownComets()

  Returns:
    The set of known Oort comet servers URLs.

### observeChannel

    public void observeChannel(java.lang.String channelId)

  Observer a channel.

  Once observed, all `OortComet` instances subscribe to the channel and will repeat any messages published to the local channel (with loop prevention), so that the messages are distributed to all Oort comet servers.

  Parameters:
    `channelId` -

### addOortMessageListener

    public void addOortMessageListener(org.cometd.MessageListener listener)

  Add a MessageListener that will receive all messages published on /oort/* channels on connected OortComets

  Parameters:
    `listener` -

### removeOortClientListener

    public boolean removeOortClientListener(org.cometd.MessageListener listener)

  Remove an Oort message listener.

  Parameters:
    `listener` -
  Returns:
    true if the listener was removed.

### isOort

    public boolean isOort(org.cometd.Client client)

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### oortHandshook

    protected void oortHandshook(java.lang.String oortUrl,
                                 java.lang.String oortSecret,
                                 java.lang.String clientId)

  Called to register the details of a successful handshake with an Oort comet. A `RemoteOortClientListener` instance is added to the local Oort client instance.

  Parameters:
    `oortUrl` -
    `oortSecret` -
    `clientId` -

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