Class ConfigurationErrorEvent
- java.lang.Object
-
- java.util.EventObject
-
- org.apache.commons.configuration2.event.Event
-
- org.apache.commons.configuration2.event.ConfigurationErrorEvent
-
- All Implemented Interfaces:
java.io.Serializable
public class ConfigurationErrorEvent extends Event
An event class that is used for reporting errors that occurred while processing configuration properties.
Some configuration implementations (e.g.
DatabaseConfiguration
orJNDIConfiguration
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, aThrowable
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:
ConfigurationEvent
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static EventType<ConfigurationErrorEvent>
ANY
Constant for the common event type for all error events.static EventType<ConfigurationErrorEvent>
READ
Constant for the event type indicating a read error.static EventType<ConfigurationErrorEvent>
WRITE
Constant for the event type indicating a write error.
-
Constructor Summary
Constructors Constructor Description ConfigurationErrorEvent(java.lang.Object source, EventType<? extends ConfigurationErrorEvent> eventType, EventType<?> operationType, java.lang.String propName, java.lang.Object propValue, java.lang.Throwable cause)
Creates a new instance ofConfigurationErrorEvent
and sets all its properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Throwable
getCause()
Gets the cause of this error event.EventType<?>
getErrorOperationType()
Gets theEventType
of the operation which caused this error.java.lang.String
getPropertyName()
Gets the name of the property that was accessed when this error occurred.java.lang.Object
getPropertyValue()
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
-
-
-
-
Field Detail
-
ANY
public static final EventType<ConfigurationErrorEvent> 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
public static final EventType<ConfigurationErrorEvent> 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
public static final EventType<ConfigurationErrorEvent> 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 Detail
-
ConfigurationErrorEvent
public ConfigurationErrorEvent(java.lang.Object source, EventType<? extends ConfigurationErrorEvent> eventType, EventType<?> operationType, java.lang.String propName, java.lang.Object propValue, java.lang.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 Detail
-
getErrorOperationType
public EventType<?> getErrorOperationType()
Gets theEventType
of the operation which caused this error.- Returns:
- the event type of the operation causing this error
-
getPropertyName
public java.lang.String 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
public java.lang.Object getPropertyValue()
Gets the value of the property that was accessed when this error occurred.- Returns:
- the property value related this error (may be null)
-
getCause
public java.lang.Throwable 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
-
-