You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by oh...@apache.org on 2007/01/15 22:16:16 UTC
svn commit: r496497 -
/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
Author: oheger
Date: Mon Jan 15 13:16:16 2007
New Revision: 496497
URL: http://svn.apache.org/viewvc?view=rev&rev=496497
Log:
CONFIGURATION-245: Added a convenience method for registering a logging error listener to AbstractConfiguration
Modified:
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java?view=diff&rev=496497&r1=496496&r2=496497
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/AbstractConfiguration.java Mon Jan 15 13:16:16 2007
@@ -27,6 +27,8 @@
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.FilterIterator;
+import org.apache.commons.configuration.event.ConfigurationErrorEvent;
+import org.apache.commons.configuration.event.ConfigurationErrorListener;
import org.apache.commons.configuration.event.EventSource;
import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
import org.apache.commons.lang.BooleanUtils;
@@ -76,18 +78,37 @@
*/
public abstract class AbstractConfiguration extends EventSource implements Configuration
{
- /** Constant for the add property event type.*/
+ /**
+ * Constant for the add property event type.
+ * @since 1.3
+ */
public static final int EVENT_ADD_PROPERTY = 1;
- /** Constant for the clear property event type.*/
+ /**
+ * Constant for the clear property event type.
+ * @since 1.3
+ */
public static final int EVENT_CLEAR_PROPERTY = 2;
- /** Constant for the set property event type.*/
+ /**
+ * Constant for the set property event type.
+ * @since 1.3
+ */
public static final int EVENT_SET_PROPERTY = 3;
- /** Constant for the clear configuration event type.*/
+ /**
+ * Constant for the clear configuration event type.
+ * @since 1.3
+ */
public static final int EVENT_CLEAR = 4;
+ /**
+ * Constant for the get property event type. This event type is used for
+ * error events.
+ * @since 1.4
+ */
+ public static final int EVENT_READ_PROPERTY = 5;
+
/** start token */
protected static final String START_TOKEN = "${";
@@ -117,7 +138,7 @@
/** Stores the logger.*/
private Log log;
-
+
/**
* Creates a new instance of <code>AbstractConfiguration</code>.
*/
@@ -331,6 +352,27 @@
public void setLogger(Log log)
{
this.log = (log != null) ? log : new NoOpLog();
+ }
+
+ /**
+ * Adds a special
+ * <code>{@link org.apache.commons.configuration.event.ConfigurationErrorListener}</code>
+ * object to this configuration that will log all internal errors. This
+ * method is intended to be used by certain derived classes, for which it is
+ * known that they can fail on property access (e.g.
+ * <code>DatabaseConfiguration</code>).
+ *
+ * @since 1.4
+ */
+ public void addErrorLogListener()
+ {
+ addErrorListener(new ConfigurationErrorListener()
+ {
+ public void configurationError(ConfigurationErrorEvent event)
+ {
+ getLogger().warn("Internal error", event.getCause());
+ }
+ });
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org