org.bounce.message
Class Distributor

java.lang.Object
  extended by org.bounce.message.Distributor

public class Distributor
extends Object

This class is the Distributor for all messages, it distributes the messages to the topic publishers. The publishers distribute the messages to the subscribers and the subscribers handle the messages.

It keeps a hashtable of publisher per topic, every message will also be sent to all the super topic publishers.

Version:
$Revision: 1.5 $, $Date: 2008/01/28 21:28:37 $
Author:
Edwin Dankert

Constructor Summary
Distributor()
          The constructor for the Distributor.
 
Method Summary
 void distribute(Message message)
          Asks the publishers to publish the message.
 Publisher getPublisher(Class topic)
          Gets a publisher for a specific topic from the controller.
 void setPublisher(Class topic, Publisher publisher)
          Sets a publisher for a specific topic to the controller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Distributor

public Distributor()
The constructor for the Distributor. It creates a Hashtable for all the publishers and sets the default publisher for the top Message 'topic'.

Method Detail

setPublisher

public void setPublisher(Class topic,
                         Publisher publisher)
Sets a publisher for a specific topic to the controller.

Parameters:
topic - the type of the message to subscribe to.
publisher - the publisher that handles the message.

getPublisher

public Publisher getPublisher(Class topic)
Gets a publisher for a specific topic from the controller. If the publisher is null it will return the first publisher found going up the tree.

Parameters:
topic - the topic to get a publisher for.
Returns:
the publisher for this topic if this publisher is not found it will return null.

distribute

public void distribute(Message message)
Asks the publishers to publish the message.

Parameters:
message - the message to publish.


Copyright © 2002-2011 Edwin Dankert. All Rights Reserved.