Open glassfishrobot opened 14 years ago
Reported by ralfhergert
lexi said: I'll address this; however the plugin will then be overtaken to the JAXB2 Basics (http://confluence.highsource.org/display/J2B/Home).
mwise said: Was this ever addressed? I've downloaded the latest version 1.1-SNAPSHOT from http://download.java.net/maven/2/org/jvnet/jaxb2-commons/property-listener-injector/ and this still has the bug. Also properties that are primitives rather than objects don't get firePropertyChange calls injected.
Having got hold of the sources from the above location, I can attempt to fix this myself, but I would rather pull in a publically-available plugin/dependency...
lexi said: Seems like the plugin was not maintained since cvs->svn move.
Was assigned to lexi
This issue was imported from java.net JIRA JAXB2_COMMONS-25
So far I did not found any explicit statement in the Java Bean Specification, that PropertyChangeEvents have not to be fired before an attribute was changed. But in all implementations of the Java framework and all examples using PropertyChangedEvents the events are fired only after a change and not before.
Maybe the property-listener-injector should be follow this behavior too? Arranging this is pretty simple. Just modify the code generating the body of the setMethod in:
com.sun.tools.xjc.addon.property_listener_injector.SingleField:201
JBlock body = $set.body(); if (boundType!=null) { if (boundType==Kind.VETOABLE)
{ JTryBlock tryBlock = body._try(); JClass vetoableClass = (JClass) codeModel._ref(java.beans.PropertyVetoException.class); tryBlock.body().add( JExpr.ref("support").invoke("fireVetoableChange"). arg(prop.getName(false)).arg(JExpr.refthis(ref().name())).arg($value)); //tryBlock.body().directStatement("support.fireVetoableChange(\"" + prop.getName(false)+ "\"," + ref().name() + ", value);"); JCatchBlock catchBlock = tryBlock._catch(vetoableClass); catchBlock.body().directStatement("return;"); body.assign(JExpr._this().ref(ref()),castToImplType($value)); }
else
{ JVar $oldValue = body.decl(setterType, "oldValue", JExpr.ref("value")); body.assign(JExpr._this().ref(ref()),castToImplType($value)); body.add(JExpr.ref("support").invoke("firePropertyChange"). arg(prop.getName(false)).arg($oldValue).arg($value)); }
} else
{ body.assign(JExpr._this().ref(ref()),castToImplType($value)); }
The pom.xml needs an update too. I compiled it versus com.sun.xml.bind/jaxb-xjc/2.2
Environment
Operating System: All Platform: All
Affected Versions
[current]