PropertyChangeSupport is being added to the entity beans.
2 notes from Mario:
1. The PropertyChange event needs to be firedAFTER the value has been changed in the model and not before.
This is VERY important I think, as a library might use thePropertyChangeEvent just as trigger to react, but read the value fromthe model instead of using the one from the event. The Javadoc inPropertyChangeSupport.firePropertyChange sayes * @param propertyName The programmatic name of the property * that was changed.
1) Libraries like Beansbinding lookup the addPropertyChangeListenerusing reflection on the object you bind. It does this in a reallyfancy way by scanning the class and looking for "add....(PropertyChangeListener)" methods.With the PropertySupport in Ebean this now fails as theaddPropertyChangeListener is just available through the interceptor.I think it will be a good idea, when weaving the entity class, to addthe add-/removePropertyChangeListener stuff too. Using this as thedefault names, it probably make sense to have the names configurable.
Would be great if you could add this to your weaver.
2) PropertyChange events are not fired if the bean is not in theintercepting state. For example, when creating a new bean andattaching PropertyChangeListeners to it (for now through theinterceptor) no event will be fired.
Since the propertyChangeSupport itself checks for changed values thisone is easy to fix by simply moving the ifs if (pcs != null){ pcs.firePropertyChange(propertyName, oldValue, newValue); }in EntityBeanIntercept outside the if (preSetterIsModifyCheck(propertyName)).
I've change that locally and my test case now works again.
Thanks!Mario
This code is now in HEAD. It involves changes to the enhancement (in case you are using the Eclipse plugin for enhancement).