|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.configuration.event.EventSource
A base class for objects that can generate configuration events.
This class implements functionality for managing a set of event listeners
that can be notified when an event occurs. It can be extended by
configuration classes that support the event machanism. In this case these
classes only need to call the fireEvent()
method when an event
is to be delivered to the registered listeners.
Adding and removing event listeners can happen concurrently to manipulations on a configuration that cause events. The operations are synchronized.
With the detailEvents
property the number of detail events can
be controlled. Some methods in configuration classes are implemented in a way
that they call other methods that can generate their own events. One example
is the setProperty()
method that can be implemented as a
combination of clearProperty()
and addProperty()
.
With detailEvents
set to true, all involved methods
will generate events (i.e. listeners will receive property set events,
property clear events, and property add events). If this mode is turned off
(which is the default), detail events are suppressed, so only property set
events will be received. Note that the number of received detail events may
differ for different configuration implementations.
for instance has a custom implementation of HierarchicalConfiguration
setProperty()
, which
does not generate any detail events.
Constructor Summary | |
EventSource()
Creates a new instance of EventSource . |
Method Summary | |
void |
addConfigurationListener(ConfigurationListener l)
Adds a configuration listener to this object. |
void |
clearConfigurationListeners()
Removes all registered configuration listeners. |
protected ConfigurationEvent |
createEvent(int type,
String propName,
Object propValue,
boolean before)
Creates a ConfigurationEvent object based on the passed in
parameters. |
protected void |
fireEvent(int type,
String propName,
Object propValue,
boolean before)
Creates an event object and delivers it to all registered event listeners. |
Collection |
getConfigurationListeners()
Returns a collection with all configuration event listeners that are currently registered at this object. |
boolean |
isDetailEvents()
Returns a flag whether detail events are enabled. |
boolean |
removeConfigurationListener(ConfigurationListener l)
Removes the specified event listener so that it does not receive any further events caused by this object. |
void |
setDetailEvents(boolean enable)
Determines whether detail events should be generated. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public EventSource()
EventSource
.
Method Detail |
public void addConfigurationListener(ConfigurationListener l)
l
- the listener to addpublic boolean removeConfigurationListener(ConfigurationListener l)
l
- the listener to be removed
public Collection getConfigurationListeners()
ConfigurationListener
s (this collection cannot be
changed)public void clearConfigurationListeners()
public boolean isDetailEvents()
public void setDetailEvents(boolean enable)
setDetailEvents(false)
was called three times, you will
have to invoke the method as often to enable the details.
enable
- a flag if detail events should be enabled or disabledprotected void fireEvent(int type, String propName, Object propValue, boolean before)
detailEvents
property), and if
listeners are registered.
type
- the event's typepropName
- the name of the affected property (can be null)propValue
- the value of the affected property (can be null)before
- the before update flagprotected ConfigurationEvent createEvent(int type, String propName, Object propValue, boolean before)
ConfigurationEvent
object based on the passed in
parameters. This is called by fireEvent()
if it decides
that an event needs to be generated.
type
- the event's typepropName
- the name of the affected property (can be null)propValue
- the value of the affected property (can be null)before
- the before update flag
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |