thinkmap.client.util
Class EventMulticaster

java.lang.Object
  extended by thinkmap.client.util.EventMulticaster
All Implemented Interfaces:
EventListener, IErrorListener, IContextListener

public class EventMulticaster
extends Object
implements IContextListener, IErrorListener

EventMulticaster multicasts events to IEntitySetListener, IPropertyListener, and IInteractionListener. Its design and purpose are similar to AWTEventMulticaster.

Version:
$Revision: 1.11.2.1 $
See Also:
thinkmap.client.IEntitySetListener, thinkmap.expression.runtime.IPropertyListener, thinkmap.client.IInteractionListener

Field Summary
protected  EventListener a
           
protected  EventListener b
           
 
Constructor Summary
protected EventMulticaster(EventListener a, EventListener b)
           
 
Method Summary
static IContextListener add(IContextListener a, IContextListener b)
           
static IErrorListener add(IErrorListener a, IErrorListener b)
           
protected static EventListener addInternal(EventListener a, EventListener b)
          Returns the resulting multicast listener from adding listener a and listener b together.
static boolean contains(EventListener l, EventListener oldl)
          Determine if an EventListener constains a specified listener.
 void contextDestroyed(IThinkmapContext itc)
          Called when the given context has been destroyed.
 void contextInitializing(IThinkmapContext itc)
          Called when the given context is initializing.
 void contextStarting(IThinkmapContext itc)
          Called when the given context is starting.
 void contextStopping(IThinkmapContext itc)
          Called when the given context is stopping.
 void errorOccurred(Throwable t)
           
static int getListenerCount(EventListener l)
           
static EventListener[] getListeners(EventListener l, Class listenerType)
          Get all listeners in a particular EventListener of a particular type.
protected  EventListener remove(EventListener oldl)
           
static IContextListener remove(IContextListener a, IContextListener b)
           
static IErrorListener remove(IErrorListener a, IErrorListener b)
           
protected static EventListener removeInternal(EventListener l, EventListener oldl)
          Returns the resulting multicast listener after removing the old listener from listener l.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

a

protected final EventListener a

b

protected final EventListener b
Constructor Detail

EventMulticaster

protected EventMulticaster(EventListener a,
                           EventListener b)
Method Detail

add

public static IContextListener add(IContextListener a,
                                   IContextListener b)

remove

public static IContextListener remove(IContextListener a,
                                      IContextListener b)

add

public static IErrorListener add(IErrorListener a,
                                 IErrorListener b)

remove

public static IErrorListener remove(IErrorListener a,
                                    IErrorListener b)

contextInitializing

public void contextInitializing(IThinkmapContext itc)
                         throws Exception
Description copied from interface: IContextListener
Called when the given context is initializing. Listeners should construct and configure objects that depend on the context at this time. This method will only be called once per context.

Specified by:
contextInitializing in interface IContextListener
Parameters:
itc - the context that is initializing
Throws:
Exception - if an error occurs while processing this event.

contextStarting

public void contextStarting(IThinkmapContext itc)
Description copied from interface: IContextListener
Called when the given context is starting. All objects that depend on the context should have been initialized before this method is called. Listeners should start any services they offer at this time. A context may be started, stopped, and started again many times.

Specified by:
contextStarting in interface IContextListener
Parameters:
itc - the context that is starting

contextStopping

public void contextStopping(IThinkmapContext itc)
Description copied from interface: IContextListener
Called when the given context is stopping. Listeners should stop any services they offer at this time.

Specified by:
contextStopping in interface IContextListener
Parameters:
itc - the context that is starting

contextDestroyed

public void contextDestroyed(IThinkmapContext itc)
Description copied from interface: IContextListener
Called when the given context has been destroyed. Listeners should dispose and de-register objects that depend on the context at this time. This method will only be called once per context.

Specified by:
contextDestroyed in interface IContextListener
Parameters:
itc - the context that is being destroyed

errorOccurred

public void errorOccurred(Throwable t)
Specified by:
errorOccurred in interface IErrorListener

contains

public static boolean contains(EventListener l,
                               EventListener oldl)
Determine if an EventListener constains a specified listener.

Parameters:
l - an EventListener
oldl - a listener to search for
Returns:
true if listener l contains oldl

addInternal

protected static EventListener addInternal(EventListener a,
                                           EventListener b)
Returns the resulting multicast listener from adding listener a and listener b together. If listener a is null, it returns listener b; If listener b is null, it returns listener a. If neither are null, then it creates and returns a new AWTEventMulticaster instance which chains a with b.

Parameters:
a - event listener a
b - event listener b
Returns:
the resulting multicast listener

removeInternal

protected static EventListener removeInternal(EventListener l,
                                              EventListener oldl)
Returns the resulting multicast listener after removing the old listener from listener l. If listener l equals the old listener OR listener l is null, returns null. Else if listener l is an instance of EventListener, then it removes the old listener from it. Else, returns listener l.

Parameters:
l - the listener being removed from
oldl - the listener being removed
Returns:
the resulting multicast listener

remove

protected EventListener remove(EventListener oldl)

getListenerCount

public static int getListenerCount(EventListener l)

getListeners

public static EventListener[] getListeners(EventListener l,
                                           Class listenerType)
Get all listeners in a particular EventListener of a particular type.

Parameters:
l - the event listener
listenerType - a class of listeners to find
Returns:
an array of listeners of the specified type


Copyright © 2013 Thinkmap, Inc. All Rights Reserved.