ApplicationBroadcaster

Kind of class:public class
Package:com.bourre.events
Inherits from:ChannelBroadcaster
Author:Francis Bourre, Romain Flacher
Classpath:com.bourre.events.ApplicationBroadcaster
File last modified:Monday, 24 November 2008, 11:36:53
The ApplicationBroadcaster class is a singleton
implementation of the ChannelBroadcaster class,
used for Inversion of Controls purpose. More formally
the application broadcaster is dedicated to plugin to plugin
communication. When defining a plugin with a specific channel,
and then listeners of this plugin, a channel instance is created
in the ChannelExpert and then this channel is used
in order to create the whole dispatching stuff between these
plugins.

The class defines two constant channels dedicated to an IoC usage.
These channel represents particular behaviors of the application
broadcaster. Such :

  • NO_CHANNEL : That constant, when used as argument of
    the getChannelDispatcher method, force the application
    broadcaster to ignore the call. No broadcaster will be created and
    then returned by the function.
  • SYSTEM_CHANNEL : Defines the default channel of the
    application broadcaster singleton. All objects which add themselves
    as listener without specifying any channel are considered as system
    listeners.

See also:

Summary


Constructor
Constants
Class methods

Constructor

ApplicationBroadcaster

public function ApplicationBroadcaster (

Creates a new ApplicationBroadcaster object. This constructor
is locked using a simple hack, you cannot call the constructor directly.
Please use the ApplicationBroadcaster.getInstance method instead,
in order to retreive the singleton instance of the class.
Parameters:
access:
a lock for direct instanciation of the
ApplicationBroadcaster class

Constants

NO_CHANNEL

public const NO_CHANNEL:EventChannel = new NoChannel()
(read)

Inhibit the behavior of the getChannelDispatcherwhich will return nothing if this channel is passed as argument.

SYSTEM_CHANNEL

public const SYSTEM_CHANNEL:EventChannel = new SystemChannel()
(read)

Default channel for the application broadcaster, all listeners
which not define any channel are considered as system listeners.

Class methods

getInstance

public static function getInstance (

Returns the singleton instance of the ApplicationBroadcasterclass. The class instance is created using the lazy initialisation concept.
Returns:
  • singleton instance of ApplicationBroadcaster

Instance methods

getChannelDispatcher

override public function getChannelDispatcher (
channel:EventChannel = null, owner:Object = null) : Broadcaster

Returns the EventBroadcaster object associated with
the passed-in channel<code>. The <code>owner is an optionnal
parameter which is used to initialize the newly created EventBroadcasterwhen there is no broadcaster for this channel.

There's a particular case defined by this class, when passing the NO_CHANNELchannel in this function, the function will return null instead of a broadcaster.

Parameters:
channel:
the channel for which get the associated broadcaster
owner :
an optional object which will used as source if there
is no broadcaster associated to the channel
Returns:
  • the EventBroadcaster object associated with
    the passed-in channel
Overrides:
  • ChannelBroadcaster.getChannelDispatcher