Get Bounce at SourceForge.net. Fast secure and Free Open Source software downloads

org.bounce.message
Class Distributor

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

public class Distributor
extends java.lang.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

Field Summary
(package private)  java.util.HashMap<java.lang.Class,Publisher> publishers
           
 
Constructor Summary
Distributor()
          The constructor for the Distributor.
 
Method Summary
 void distribute(Message message)
          Asks the publishers to publish the message.
 Publisher getPublisher(java.lang.Class topic)
          Gets a publisher for a specific topic from the controller.
 void setPublisher(java.lang.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
 

Field Detail

publishers

java.util.HashMap<java.lang.Class,Publisher> publishers
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(java.lang.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(java.lang.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.

Get Bounce at SourceForge.net. Fast secure and Free Open Source software downloads

Copyright 2002-2002-2009 Edwin Dankert. All Rights Reserved.