commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: [Configuration] Problem in using FileChangedReloadingStrategy events ...
Date Tue, 15 Feb 2011 08:06:51 GMT
Yes, you've stumbled on one of the uglinesses of Commons Configuration.  We should convert
these to an Enum in the experimental branch.

The particular event you encountered is defined in AbstractFileConfiguration. 

    /** Constant for the configuration reload event.*/
    public static final int EVENT_RELOAD = 20;

    /** Constant fro the configuration changed event. */
    public static final int EVENT_CONFIG_CHANGED = 21;

Ralph


On Feb 14, 2011, at 10:35 PM, Moein Enayati wrote:

> Dear All
> 
> I’ve just  have an XMLConfiguration object  initialized like this :
> 
> 
> * *
> 
> *            this.xmlConfig = new XMLConfiguration("preferences.xml");*
> 
> *            this.xmlConfig.setAutoSave(true);*
> 
> *            this.xmlConfig.setReloadingStrategy(new
> FileChangedReloadingStrategy());*
> 
> 
> 
> 
> and a bean  implements ConfigurationListener  Interface like this :
> 
> 
> 
> 
> *public abstract class DefaultBean implements
> Serializable,ConfigurationListener {*
> 
> *protected PropertyChangeSupport propertyChangeSupport = new
> PropertyChangeSupport(this);*
> 
> * public abstract String getXmlBeanPropertyAddress();*
> 
> * public void configurationChanged(ConfigurationEvent event) {*
> 
> *System.out.println(“Event Type Value is 20 ! >> ”+event.getType());*
> 
> *}*
> 
> *}*
> 
> 
> Also I’ve registered my bean and the XMLConfigoration as listeners :
> 
> 
> 
> 
> *        this.xmlConfig.addConfigurationListener(myBeanInstance);*
> 
> *
> myBeanInstance.addPropertyChangeListener(getPropertyChangeListener());*
> 
> 
> 
> 
> To test the AutoReloadEvents , simply I used a timer which gets a property
> of my XMLConfiguration object each 2 Seconds and it seems working .
> *myBeanInstance.
> configurationChanged() * is invoked  about two minutes after any change in
> the source *preferences.xml*.
> 
> *
> *
> 
> *But there is a small problem! *
> 
> 
> The *event.getType()* returns a value of  *20*  which I could not find it in
> *XMLConfiguration.EVENT_* constants.
> 
> Would you please help me to find the mistake I’ve probably done or is there
> any way to have a trace line?
> 
> 
> 
> I could find only these EVENT_ constants :
> 
> 
> 
> *XMLConfiguration.EVENT_ADD_NODES = 11*
> 
> *XMLConfiguration.EVENT_ADD_PROPERTY = 1*
> 
> *XMLConfiguration.EVENT_CLEAR = 4*
> 
> *XMLConfiguration.EVENT_CLEAR_PROPERTY = 2*
> 
> *XMLConfiguration.EVENT_CLEAR_TREE =10*
> 
> *XMLConfiguration.EVENT_READ_PROPERTY =5*
> 
> *XMLConfiguration.EVENT_SET_PROPERTY =3*
> 
> *XMLConfiguration.EVENT_SUBNODE_CHANGED =12*
> 
> 
> 
> 
> Thanks / Moein


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message