net.groboclown.eventbus.v2
Class EventBus
java.lang.Object
|
+--net.groboclown.eventbus.v2.EventBus
- public class EventBus
- extends Object
Master control unit which is in charge of registering event listeners,
deregistering event listeners, and distributing events. There are
no default distributors, so those must be manually added, or
specified as external distributors through the command-line.
This has been redesigned to allow for multiple busses to co-exist within
the same VM.
- Version:
- Alpha 0.9.0
- Author:
- Matt Albrecht
Constructor Summary |
EventBus()
Default constructor |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
syncObj
private Object syncObj
eventDistributors
private LinkedList eventDistributors
idObject
private HashMap idObject
objectId
private HashMap objectId
filterId
private HashMap filterId
idFilter
private HashMap idFilter
localBusName
private String localBusName
localBusId
private EventBusId localBusId
DEBUG
private static final boolean DEBUG
EventBus
public EventBus()
- Default constructor
addEventDistributor
public void addEventDistributor(String className)
throws IllegalArgumentException
addEventDistributor
public void addEventDistributor(Class c)
throws IllegalArgumentException
addEventDistributor
public void addEventDistributor(IEventDistributor ed)
throws RemoteException
removeEventDistributor
public boolean removeEventDistributor(IEventDistributor ed)
addListener
public void addListener(IEventBusListener listener)
throws RemoteException
- Add the given listener to the list, and generates a filter agent.
removeListener
public boolean removeListener(IEventBusListener listener)
- Deregister the given listener and its filter.
- Returns:
- true if the listener was found and removed, or
false if it could not be found.
getListenersForEvent
public IEventBusListener[] getListenersForEvent(EventBusEvent ebe)
- Used by EventDistributors to retrieve the list of listeners
for the given event.
sendEvent
public void sendEvent(Object source,
Serializable data)
- Sends the event with the given data to the correct listeners. The
sending to the distributors occurs in this thread, while the distributor
sending may occur in any thread.
redirectEvent
public void redirectEvent(EventBusEvent ebe)
- Redirects an EventBusEvent object to this bus's distributor list.
getLocalObject
public Object getLocalObject(EventBusId id)
getBusId
public String getBusId()
loadExternalDistributors
protected void loadExternalDistributors()
getEventId
protected EventBusId getEventId(Object obj)
sendBusEvent
protected void sendBusEvent(String method,
EventBusId data)
debug
private static final void debug(String text)
debug
private static final void debug(String text,
Throwable t)
Written under the LGPL