Class ConfigurationErrorEvent
- All Implemented Interfaces:
Serializable
An event class that is used for reporting errors that occurred while processing configuration properties.
Some configuration implementations (e.g. DatabaseConfiguration
or
JNDIConfiguration
use an underlying storage that can throw an exception on
each property access. In earlier versions of this library such exceptions were logged and then silently ignored. This
makes it impossible for a client to find out that something went wrong.
To give clients better control over the handling of errors that might occur while interacting with a configuration object, a specialized error event type is introduced. Clients can register as listeners of this event type at a configuration object and are then notified about all internal errors related to the source configuration object.
This class defines similar properties to the ConfigurationEvent
class. This makes it possible to find out
which operation was performed on a configuration causing this error event. In addition, a Throwable
object is
available representing the occurred error. Note that depending on the event type and the occurred exception not all
of the other properties (e.g. name of the affected property or its value) may be available.
- Since:
- 1.4
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final EventType<ConfigurationErrorEvent>
Constant for the common event type for all error events.static final EventType<ConfigurationErrorEvent>
Constant for the event type indicating a read error.static final EventType<ConfigurationErrorEvent>
Constant for the event type indicating a write error.Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionConfigurationErrorEvent
(Object source, EventType<? extends ConfigurationErrorEvent> eventType, EventType<?> operationType, String propName, Object propValue, Throwable cause) Creates a new instance ofConfigurationErrorEvent
and sets all its properties. -
Method Summary
Modifier and TypeMethodDescriptiongetCause()
Gets the cause of this error event.EventType<?>
Gets theEventType
of the operation which caused this error.Gets the name of the property that was accessed when this error occurred.Gets the value of the property that was accessed when this error occurred.Methods inherited from class org.apache.commons.configuration2.event.Event
appendPropertyRepresentation, getEventType, toString
Methods inherited from class java.util.EventObject
getSource
-
Field Details
-
ANY
Constant for the common event type for all error events. Specific types for error events use this type as super type.- Since:
- 2.0
-
READ
Constant for the event type indicating a read error. Errors of this type are generated if the underlying data store throws an exception when reading a property.- Since:
- 2.0
-
WRITE
Constant for the event type indicating a write error. Errors of this type are generate if the underlying data store throws an exception when updating data.- Since:
- 2.0
-
-
Constructor Details
-
ConfigurationErrorEvent
public ConfigurationErrorEvent(Object source, EventType<? extends ConfigurationErrorEvent> eventType, EventType<?> operationType, String propName, Object propValue, Throwable cause) Creates a new instance ofConfigurationErrorEvent
and sets all its properties.- Parameters:
source
- the event sourceeventType
- the type of this eventoperationType
- the event type of the operation causing this errorpropName
- the name of the affected propertypropValue
- the value of the affected propertycause
- the exception object that caused this event
-
-
Method Details
-
getCause
Gets the cause of this error event. This is theThrowable
object that caused this event to be fired.- Returns:
- the cause of this error event
-
getErrorOperationType
Gets theEventType
of the operation which caused this error.- Returns:
- the event type of the operation causing this error
-
getPropertyName
Gets the name of the property that was accessed when this error occurred.- Returns:
- the property name related to this error (may be null)
-
getPropertyValue
Gets the value of the property that was accessed when this error occurred.- Returns:
- the property value related this error (may be null)
-