Bug 116 : PropertyChangeSupport in entity beans
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.0.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
29/05/2009
Updated 
29/05/2009
Type 
Bug
 
Attachments 
No attachments

PropertyChangeSupport is being added to the entity beans.

2 notes from Mario:

1. The PropertyChange event needs to be fired
AFTER the value has been changed in the model and not before.

This is VERY important I think, as a library might use the
PropertyChangeEvent just as trigger to react, but read the value from
the model instead of using the one from the event. The Javadoc in
PropertyChangeSupport.firePropertyChange sayes
* @param propertyName The programmatic name of the property
* that was changed.

 
Rob 29 May 13:57
And also...

1) Libraries like Beansbinding lookup the addPropertyChangeListener
using reflection on the object you bind. It does this in a really
fancy way by scanning the class and looking for "add....
(PropertyChangeListener)" methods.
With the PropertySupport in Ebean this now fails as the
addPropertyChangeListener is just available through the interceptor.
I think it will be a good idea, when weaving the entity class, to add
the add-/removePropertyChangeListener stuff too. Using this as the
default 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 the
intercepting state. For example, when creating a new bean and
attaching PropertyChangeListeners to it (for now through the
interceptor) no event will be fired.

Since the propertyChangeSupport itself checks for changed values this
one 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

Rob 03 Jun 12:51
Now in HEAD

This code is now in HEAD. It involves changes to the enhancement (in case you are using the Eclipse plugin for enhancement).

woResponse

Upload a file