org.enhydra.barracuda.core.event
Interface EventBroker

All Known Implementing Classes:
DefaultEventBroker

public interface EventBroker

This interface defines the methods needed to implement an EventBroker


Method Summary
 void addEventAlias(Class event)
          Manually register aliases for a given event (the aliases will be determined automatically based on the class name and the event ID)
 void addEventAlias(Class event, String alias)
          Manually add an alias for a given event.
 void addEventListener(ListenerFactory factory)
          register a listener id, so that events addressed to a specific listener can be delivered
 void addEventListener(ListenerFactory factory, Class event)
          add an event listener for a particular class of an event.
 void dispatchEvent(EventContext context)
          Dispatch a queue of events.
 String getEventExtension()
          Return the event extension handled by this event broker
 ListenerFactory getEventListener(Object id)
          Get a specific listener based on listener ID
 List getEventListeners(Class event)
          Get a List of listeners for a type of event.
 String matchEventClass(String eventStr)
          Given a partial event class name, return the fully qualified class name if it's possible to determine.
 String matchListenerID(String idStr)
          Given a partial id name, return the fully qualified listener ID if it's possible to determine.
 void purgeEventListener(ListenerFactory factory)
          remove all references to an event listener, both for id and for any event classes it has registered an interest in.
 void removeEventListener(ListenerFactory factory)
          remove a listener from general availability
 void removeEventListener(ListenerFactory factory, Class event)
          remove an event listener for specific types of events If the class referenced is not an instance of BaseEvent, a InvalidClassException will be thrown.
 

Method Detail

getEventExtension

public String getEventExtension()
Return the event extension handled by this event broker

Returns:
the event extension associated with this broker

addEventListener

public void addEventListener(ListenerFactory factory)
register a listener id, so that events addressed to a specific listener can be delivered

Parameters:
factory - the listener factory to be added

addEventListener

public void addEventListener(ListenerFactory factory,
                             Class event)
                      throws InvalidClassException
add an event listener for a particular class of an event. If the class referenced is not an instance of BaseEvent, a ClassNotEventException will be thrown. Note that this method also registers the listener in the idMap as well.

Parameters:
factory - the listener factory to be added
event - the specific class of event for which the factory is listening
Throws:
InvalidClassException - if the event class does not implement BaseEvent

removeEventListener

public void removeEventListener(ListenerFactory factory)
remove a listener from general availability

Parameters:
factory - the listener factory to be removed

removeEventListener

public void removeEventListener(ListenerFactory factory,
                                Class event)
                         throws InvalidClassException
remove an event listener for specific types of events If the class referenced is not an instance of BaseEvent, a InvalidClassException will be thrown. Note that this method effectively deregisters the listener from the idMap as well.

Parameters:
factory - the listener factory to be removed
event - the specific class of event for which the factory is listening
Throws:
InvalidClassException - if the event class does not implement BaseEvent

purgeEventListener

public void purgeEventListener(ListenerFactory factory)
remove all references to an event listener, both for id and for any event classes it has registered an interest in.

Parameters:
factory - the listener factory to be removed

addEventAlias

public void addEventAlias(Class event)
                   throws InvalidClassException
Manually register aliases for a given event (the aliases will be determined automatically based on the class name and the event ID)

Parameters:
event - the specific class of event we'd like to alias
Throws:
InvalidClassException - if the event class does not implement BaseEvent

addEventAlias

public void addEventAlias(Class event,
                          String alias)
                   throws InvalidClassException
Manually add an alias for a given event. Note that the alias parameter will be converted into all possible aliases based on '.' delimiters.

Parameters:
event - the specific class of event we'd like to alias
alias - the alias for this event
Throws:
InvalidClassException - if the event class does not implement BaseEvent

getEventListener

public ListenerFactory getEventListener(Object id)
Get a specific listener based on listener ID

Parameters:
id - the listener id we're looking for
Returns:
the ListenerFactory that matches that id

getEventListeners

public List getEventListeners(Class event)
                       throws InvalidClassException
Get a List of listeners for a type of event. Returns a copy of the broker's internal list, so you can do what you want with it. If the class referenced is not an instance of BaseEvent, a InvalidClassException will be thrown.

Parameters:
event - the event class we are looking for
Returns:
a List of listeners that are interested in this class of event
Throws:
InvalidClassException - if the event class does not implement BaseEvent

matchEventClass

public String matchEventClass(String eventStr)
                       throws InvalidClassException
Given a partial event class name, return the fully qualified class name if it's possible to determine. If it is unknown, throw and InvalidClassException. This method is primarily used by the ApplicationGateway to support event aliasing.

Parameters:
eventStr - the event name alias
Returns:
the fully qualified event class name
Throws:
InvalidClassException - if the eventStr cannot be unambiguously matched to a class name

matchListenerID

public String matchListenerID(String idStr)
                       throws InvalidClassException
Given a partial id name, return the fully qualified listener ID if it's possible to determine. If it is unknown, throw and InvalidClassException. This method is primarily used by the ApplicationGateway to support id aliasing.

Parameters:
idStr - the id name alias
Returns:
the fully qualified listener id name
Throws:
InvalidClassException - if the idStr cannot be unambiguously matched to a listener id name

dispatchEvent

public void dispatchEvent(EventContext context)
                   throws EventException

Dispatch a queue of events. Generally, the queue will only contain one event, however, if you ever need to dispatch multiple events at once, the broker can handle it. All the real dispatching work is carried out by the underlying event dispatcher.

The event queue you pass in should contain several pieces of state information:

Parameters:
context - the event context containing event, queue, and, sometimes, http information
Throws:
EventException


Copyright © 2003 BarracudaMVC.org All Rights Reserved.