Package org.apache.fop.events
Class DefaultEventBroadcaster
java.lang.Object
org.apache.fop.events.DefaultEventBroadcaster
- All Implemented Interfaces:
EventBroadcaster
- Direct Known Subclasses:
FOUserAgent.FOPEventBroadcaster
Default implementation of the EventBroadcaster interface. It holds a list of event listeners
and can provide
EventProducer
instances for type-safe event production.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static List<EventModel>
protected CompositeEventListener
Holds all registered event listenersprivate Map
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventListener
(EventListener listener) Adds an event listener to the broadcaster.static void
addEventModel
(EventModel eventModel) Adds a newEventModel
to the list of registered event models.void
broadcastEvent
(Event event) Broadcasts an event.protected EventProducer
createProxyFor
(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.getEventProducerFor
(Class clazz) Returns an event producer instance for the given interface class.private static EventProducerModel
getEventProducerModel
(Class clazz) boolean
Indicates whether any listeners have been registered with the broadcaster.private static EventModel
Loads an event model and returns its instance.void
removeEventListener
(EventListener listener) Removes an event listener from the broadcaster.
-
Field Details
-
listeners
Holds all registered event listeners -
eventModels
-
proxies
-
-
Constructor Details
-
DefaultEventBroadcaster
public DefaultEventBroadcaster()
-
-
Method Details
-
addEventListener
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:
addEventListener
in interfaceEventBroadcaster
- Parameters:
listener
- the listener to be added
-
removeEventListener
Removes an event listener from the broadcaster. If the event listener is not registered, nothing happens.- Specified by:
removeEventListener
in interfaceEventBroadcaster
- Parameters:
listener
- the listener to be removed
-
hasEventListeners
public boolean hasEventListeners()Indicates whether any listeners have been registered with the broadcaster.- Specified by:
hasEventListeners
in interfaceEventBroadcaster
- Returns:
- true if listeners are present, false otherwise
-
broadcastEvent
Broadcasts an event. This method is usually called from within the observed component.- Specified by:
broadcastEvent
in interfaceEventBroadcaster
- Parameters:
event
- the event to be broadcast
-
loadModel
Loads an event model and returns its instance.- Parameters:
resourceBaseClass
- base class to use for loading resources- Returns:
- the newly loaded event model.
-
addEventModel
Adds a newEventModel
to the list of registered event models.- Parameters:
eventModel
- the event model instance
-
getEventProducerModel
-
getEventProducerFor
Returns an event producer instance for the given interface class.- Specified by:
getEventProducerFor
in interfaceEventBroadcaster
- Parameters:
clazz
- the Class object identifying anEventProducer
interface- Returns:
- the event producer instance
-
createProxyFor
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
-