Skip to content

Commit

Permalink
Issue #253: Improved handling of @DBusBoundProperty annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
hypfvieh committed Mar 12, 2024
1 parent b2fdd8a commit 6e8e715
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ The library will remain open source and MIT licensed and can still be used, fork
- Use Junit BOM thanks to [spannm](https://github.com/spannm) ([PR#248](https://github.com/hypfvieh/dbus-java/issues/248))
- More Java 17 syntactic sugar, thanks to [spannm](https://github.com/spannm) ([PR#249](https://github.com/hypfvieh/dbus-java/issues/249))
- Added support for custom ClassLoader/ModuleLayer when configuring Transport (allows usage of third party transports when e.g. using JPMS) ([#251](https://github.com/hypfvieh/dbus-java/issues/251))
- Improved handling of `@DBusBoundProperty` annotation ([#253](https://github.com/hypfvieh/dbus-java/issues/253)), ([PR#252](https://github.com/hypfvieh/dbus-java/issues/252))

##### Changes in 5.0.0 (2024-01-25):
- **Updated minimum required Java version to 17**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,24 @@ public static Object handleDBusBoundProperty(AbstractConnection _conn, RemoteObj

String[] variantType = type != null ? new String[] {Marshalling.getDBusType(type)} : null;

RemoteObject propertiesRemoteObj = new RemoteObject(_remote.getBusName(), _remote.getObjectPath(), Properties.class, _remote.isAutostart());

Object result = null;

if (access == Access.READ) {
return RemoteInvocationHandler.executeRemoteMethod(_remote, PROP_GET_METHOD,
result = RemoteInvocationHandler.executeRemoteMethod(propertiesRemoteObj, PROP_GET_METHOD,
new Type[] {_method.getGenericReturnType()}, _conn, RemoteInvocationHandler.CALL_TYPE_SYNC, null, DBusNamingUtil.getInterfaceName(_method.getDeclaringClass()), name);
} else {
return RemoteInvocationHandler.executeRemoteMethod(_remote, PROP_SET_METHOD, variantType,
result = RemoteInvocationHandler.executeRemoteMethod(propertiesRemoteObj, PROP_SET_METHOD, variantType,
new Type[] {_method.getGenericReturnType()}, _conn, RemoteInvocationHandler.CALL_TYPE_SYNC, null, DBusNamingUtil.getInterfaceName(_method.getDeclaringClass()), name, _args[0]);
}

// requested return type is not Variant but the result is -> unwrap Variant
if (_method.getReturnType() != Variant.class && typeClass != Variant.class && result instanceof Variant<?> v) {
return v.getValue();
}

return result;
}

private static Method getPropertiesMethod(String _method, Class<?>... _signature) {
Expand Down

0 comments on commit 6e8e715

Please sign in to comment.