hypfvieh / dbus-java

Improved version of java DBus library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/)
https://hypfvieh.github.io/dbus-java/
MIT License
180 stars 72 forks source link

How to export/publish Property in interface? #242

Closed JiaAnWei closed 2 weeks ago

JiaAnWei commented 9 months ago

Hello all, I am a newbie use this dubs-Java 3.2.3 for jdk8, and can’t find any tutorial to export/publish Property like the busctl view below.

NAME. TYPE. SIGNATURE RESULT/VALUE foo.bar interface - - .helloWorld method - a .IDprop property u 12345

I could only export an interface with helloWorld, but didn’t find any way to add Property to interface. Any one can help? Thank all!

hypfvieh commented 9 months ago

Please stop using ancient versions of dbus-java or Java! dbus-java 3.x is EOL since 09/2022, probably has several bugs and will no longer be supported by any means. Also using Java versions which are EOL since 03/2022 (only commerical "support" still available) is a bad idea due to missing security fixes etc.

Anyway, to publish a property on the bus, you may take a look at DBusProperty annotation. See javadoc in the class on how to use it. I can only highly endorse the use of dbus-java 5.x (no release yet, but snaphots are available), which greatly improves the way to use or provide properties on DBus (see #235) and uses a lot of the features Java 17 provides for about 2 years. It also fixes a lot of bugs, concurrency issues, removes the use of unsupported/unmaintained libmatthew and so on.

JiaAnWei commented 9 months ago

Thanks for your support, hypfvieh. That’s really a good choice to use new version, and the annotations looks very friendly.