Property change notification doesn't work for Java
|
18-04-2012, 04:33 PM
Post: #1
|
|||
|
|||
Property change notification doesn't work for Java
If a Java control point tries to set a notification for a change to a single named property, the property change listener is never called. A workaround is to listen for changes to all properties (which does work), but this is inefficient if only one property has changed.
The fix is in the generated Java proxy code. In the constructor, instead of code like this for a property Foo: Code: iFooChanged = new PropertyChangeListener(); the code should be like this: Code: iFooChanged = new PropertyChangeListener() { |
|||
18-04-2012, 04:40 PM
Post: #2
|
|||
|
|||
RE: Property change notification doesn't work for Java
Thanks for debugging this! I'll get a fix committed tomorrow.
|
|||
19-04-2012, 01:31 PM
Post: #3
|
|||
|
|||
RE: Property change notification doesn't work for Java
Unit tests get into stack overflowing loops after this change.
I updated the T4 template CpUpnpJava.tt with the generic version of the fix you suggested, rebuilt and ran TestDvDeviceJava. It gives pages of output of the form Code: at org.openhome.net.controlpoint.CpProxy.reportEvent(CpProxy.java:168) |
|||
19-04-2012, 03:27 PM
Post: #4
|
|||
|
|||
RE: Property change notification doesn't work for Java
My apologies. The correct code is as follows:
Code: iFooChanged = new PropertyChangeListener(); I believe the previous code worked when the control point had set a change listener for the Foo property (which was the case that I tested), but not when the control point had only set a generic property change listener (as in the test case). I've tested this version of the code to make sure that it's OK in both cases. |
|||
19-04-2012, 04:06 PM
Post: #5
|
|||
|
|||
RE: Property change notification doesn't work for Java
Thanks, that seems better.
I've committed this locally now. The changes will hopefully make it onto github this evening. |
|||
20-04-2012, 02:27 PM
Post: #6
|
|||
|
|||
RE: Property change notification doesn't work for Java | |||
« Next Oldest | Next Newest »
|