Interface EventSource
- All Known Subinterfaces:
ConfigurationBuilder<T>
- All Known Implementing Classes:
AbstractConfiguration
,AbstractHierarchicalConfiguration
,AbstractYAMLBasedConfiguration
,AppletConfiguration
,BaseConfiguration
,BaseEventSource
,BaseHierarchicalConfiguration
,BasicConfigurationBuilder
,CombinedConfiguration
,CombinedConfigurationBuilder
,CombinedReloadingController
,CompositeConfiguration
,DatabaseConfiguration
,DataConfiguration
,DynamicCombinedConfiguration
,EnvironmentConfiguration
,FileBasedConfigurationBuilder
,INIConfiguration
,JNDIConfiguration
,JSONConfiguration
,MapConfiguration
,MultiFileConfigurationBuilder
,PatternSubtreeConfigurationWrapper
,PropertiesConfiguration
,PropertyListConfiguration
,ReloadingCombinedConfigurationBuilder
,ReloadingController
,ReloadingFileBasedConfigurationBuilder
,ReloadingMultiFileConfigurationBuilder
,ServletConfiguration
,ServletContextConfiguration
,ServletFilterConfiguration
,ServletRequestConfiguration
,SubnodeConfiguration
,SubsetConfiguration
,SystemConfiguration
,XMLConfiguration
,XMLPropertiesConfiguration
,XMLPropertyListConfiguration
,YAMLConfiguration
public interface EventSource
An interface for configuration implementations which support registration of event listeners.
Through the methods provided by this interface it is possible to register and remove listeners for different events supported by this library. The event type to be handled by a listener must be provided; the specified event listener must be compatible with this event type. By using generic type parameters, the compiler can check this.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescription<T extends Event>
voidaddEventListener
(EventType<T> eventType, EventListener<? super T> listener) Adds an event listener for the specified event type.<T extends Event>
booleanremoveEventListener
(EventType<T> eventType, EventListener<? super T> listener) Removes the event listener registration for the given event type and listener.
-
Method Details
-
addEventListener
Adds an event listener for the specified event type. This listener is notified about events of this type and all its sub types.- Type Parameters:
T
- the type of events processed by this listener- Parameters:
eventType
- the event type (must not be null)listener
- the listener to be registered (must not be null)- Throws:
IllegalArgumentException
- if a required parameter is null
-
removeEventListener
<T extends Event> boolean removeEventListener(EventType<T> eventType, EventListener<? super T> listener) Removes the event listener registration for the given event type and listener. An event listener instance may be registered multiple times for different event types. Therefore, when removing a listener the event type of the registration in question has to be specified. The return value indicates whether a registration was removed. A value of false means that no such combination of event type and listener was found.- Type Parameters:
T
- the type of events processed by this listener- Parameters:
eventType
- the event typelistener
- the event listener to be removed- Returns:
- a flag whether a listener registration was removed
-