org.cometd.oort
Class Oort

java.lang.Object
  extended by org.mortbay.component.AbstractLifeCycle
      extended by 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  Set<String> _channels
           
protected  HttpClient _httpClient
           
protected  Map<String,OortComet> _knownCommets
           
protected  org.cometd.Client _oortClient
           
protected  List<org.cometd.MessageListener> _oortMessageListeners
           
protected  Random _random
           
protected  String _secret
           
protected  Timer _timer
           
protected  String _url
           
static String OORT_ATTRIBUTE
           
static String OORT_CHANNELS
           
static String OORT_CLOUD
           
static 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()
           
 Set<String> getKnownComets()
           
 String getSecret()
           
 String getURL()
           
 boolean isOort(org.cometd.Client client)
           
 void observeChannel(String channelId)
          Observer a channel.
 OortComet observeComet(String cometUrl)
          Observe an Oort Comet server.
protected  void oortHandshook(String oortUrl, String oortSecret, 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.
 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 String OORT_URL
See Also:
Constant Field Values

OORT_CLOUD

public static final String OORT_CLOUD
See Also:
Constant Field Values

OORT_CHANNELS

public static final String OORT_CHANNELS
See Also:
Constant Field Values

OORT_ATTRIBUTE

public static final String OORT_ATTRIBUTE
See Also:
Constant Field Values

_url

protected String _url

_secret

protected String _secret

_bayeux

protected org.cometd.Bayeux _bayeux

_httpClient

protected HttpClient _httpClient

_timer

protected Timer _timer

_random

protected Random _random

_oortClient

protected org.cometd.Client _oortClient

_oortMessageListeners

protected List<org.cometd.MessageListener> _oortMessageListeners

_knownCommets

protected Map<String,OortComet> _knownCommets

_channels

protected Set<String> _channels
Method Detail

getBayeux

public org.cometd.Bayeux getBayeux()

getURL

public String getURL()
Returns:
The oublic absolute URL of the Oort cometd server.

getSecret

public String getSecret()

doStart

protected void doStart()
                throws Exception
Overrides:
doStart in class AbstractLifeCycle
Throws:
Exception

observeComet

public OortComet observeComet(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 Set<String> getKnownComets()
Returns:
The set of known Oort comet servers URLs.

observeChannel

public void observeChannel(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 String toString()
Overrides:
toString in class Object

oortHandshook

protected void oortHandshook(String oortUrl,
                             String oortSecret,
                             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-2009 Mort Bay Consulting. All Rights Reserved.