Package org.apache.fop.events
Class DefaultEventBroadcaster
- java.lang.Object
-
- org.apache.fop.events.DefaultEventBroadcaster
-
- All Implemented Interfaces:
EventBroadcaster
- Direct Known Subclasses:
FOUserAgent.FOPEventBroadcaster
public class DefaultEventBroadcaster extends java.lang.Object implements EventBroadcaster
Default implementation of the EventBroadcaster interface. It holds a list of event listeners and can provideEventProducerinstances for type-safe event production.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<EventModel>eventModelsprotected CompositeEventListenerlistenersHolds all registered event listenersprivate java.util.Mapproxies
-
Constructor Summary
Constructors Constructor Description DefaultEventBroadcaster()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEventListener(EventListener listener)Adds an event listener to the broadcaster.static voidaddEventModel(EventModel eventModel)Adds a newEventModelto the list of registered event models.voidbroadcastEvent(Event event)Broadcasts an event.protected EventProducercreateProxyFor(java.lang.Class clazz)Creates a dynamic proxy for the given EventProducer interface that will handle the conversion of the method call into the broadcasting of an event instance.EventProducergetEventProducerFor(java.lang.Class clazz)Returns an event producer instance for the given interface class.private static EventProducerModelgetEventProducerModel(java.lang.Class clazz)booleanhasEventListeners()Indicates whether any listeners have been registered with the broadcaster.private static EventModelloadModel(java.lang.Class resourceBaseClass)Loads an event model and returns its instance.voidremoveEventListener(EventListener listener)Removes an event listener from the broadcaster.
-
-
-
Field Detail
-
listeners
protected CompositeEventListener listeners
Holds all registered event listeners
-
eventModels
private static java.util.List<EventModel> eventModels
-
proxies
private java.util.Map proxies
-
-
Method Detail
-
addEventListener
public void addEventListener(EventListener listener)
Adds an event listener to the broadcaster. It is appended to the list of previously registered listeners (the order of registration defines the calling order).- Specified by:
addEventListenerin interfaceEventBroadcaster- Parameters:
listener- the listener to be added
-
removeEventListener
public void removeEventListener(EventListener listener)
Removes an event listener from the broadcaster. If the event listener is not registered, nothing happens.- Specified by:
removeEventListenerin interfaceEventBroadcaster- Parameters:
listener- the listener to be removed
-
hasEventListeners
public boolean hasEventListeners()
Indicates whether any listeners have been registered with the broadcaster.- Specified by:
hasEventListenersin interfaceEventBroadcaster- Returns:
- true if listeners are present, false otherwise
-
broadcastEvent
public void broadcastEvent(Event event)
Broadcasts an event. This method is usually called from within the observed component.- Specified by:
broadcastEventin interfaceEventBroadcaster- Parameters:
event- the event to be broadcast
-
loadModel
private static EventModel loadModel(java.lang.Class resourceBaseClass)
Loads an event model and returns its instance.- Parameters:
resourceBaseClass- base class to use for loading resources- Returns:
- the newly loaded event model.
-
addEventModel
public static void addEventModel(EventModel eventModel)
Adds a newEventModelto the list of registered event models.- Parameters:
eventModel- the event model instance
-
getEventProducerModel
private static EventProducerModel getEventProducerModel(java.lang.Class clazz)
-
getEventProducerFor
public EventProducer getEventProducerFor(java.lang.Class clazz)
Returns an event producer instance for the given interface class.- Specified by:
getEventProducerForin interfaceEventBroadcaster- Parameters:
clazz- the Class object identifying anEventProducerinterface- Returns:
- the event producer instance
-
createProxyFor
protected EventProducer createProxyFor(java.lang.Class clazz)
Creates a dynamic proxy for the given EventProducer interface that will handle the conversion of the method call into the broadcasting of an event instance.- Parameters:
clazz- a descendant interface of EventProducer- Returns:
- the EventProducer instance
-
-