Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat): Add BusName and ObjectPath annotation support for core #272

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

fingergohappy
Copy link

@fingergohappy fingergohappy commented Nov 15, 2024

  • Add BusName and ObjectPath annotations to mark interface bus names and object paths
  • Implement annotation-based remote object retrieval in DBusConnection
  • Add validation for annotation presence and uniqueness with improved error messages

then you can use like this:

@DBusInterfaceName("org.ganesha.nfsd.exportmgr")
@BusName("org.ganesha.nfsd")
@ObjectPath("/org/ganesha/nfsd/ExportMgr")
public interface ExportMgr extends DBusInterface, Properties {
  String AddExport(String path, String expr);

  ShowExportResult ShowExports();

  /**
   * 使用配置文件添加导出
   *
   * @param expr 表达式
   * @param conf 配置文件
   * @return
   */
  String AddExportWithConf(String expr, String conf);

  void RemoveExport(UInt16 exportId);
} 
		ExportMgr remoteObject = connection.getRemoteObject( ExportMgr.class);

It's very convenient to use.

- Add BusName and ObjectPath annotations to mark interface bus names and object paths
- Implement annotation-based remote object retrieval in DBusConnection
- Add validation for annotation presence and uniqueness with improved error messages
- Add BusName and ObjectPath annotations to mark interface bus names and object paths
- Implement annotation-based remote object retrieval in DBusConnection
- Add validation for annotation presence and uniqueness with improved error messages
@hypfvieh
Copy link
Owner

Thanks for the PR, nice idea.
I'm afraid, but I highly doubt that I gonna merge it because your idea will only work in some circumstances.

In your example it will work because you are in charge on how the exported interfaces are defined on the bus (name and path).
But when you write an application which will only "use" DBus to retrieve stuff from another application not under your control, most of the time object path will not be static/constant.

Think of querying any hardware service like bluez or NetworkManager.
There are multiple instances for NetworkManager. While the busname is constant, the objectpath will vary. There are paths for every network device and every wifi access point nearby etc.

In that case the new @ObjectPath annotation will never work because it is a constant value.

Something similar may happen when using the DBusName annotation. There are some cases where the name is fixed. But there are even more cases where the same interface is used for different exported objects and just using different names.
In that case the new annotation will only cover one of many possibilities.

To avoid confusion when using this library I don't want to add additional features which only work in a few cases and introduce possible misunderstanding/allow misusing.

If you still want to use annotations for your setup, you may create a utility method which does the steps you implemented inDBusConnection but in your own code.

@fingergohappy
Copy link
Author

Thanks for the PR, nice idea. I'm afraid, but I highly doubt that I gonna merge it because your idea will only work in some circumstances.

In your example it will work because you are in charge on how the exported interfaces are defined on the bus (name and path). But when you write an application which will only "use" DBus to retrieve stuff from another application not under your control, most of the time object path will not be static/constant.

Think of querying any hardware service like bluez or NetworkManager. There are multiple instances for NetworkManager. While the busname is constant, the objectpath will vary. There are paths for every network device and every wifi access point nearby etc.

In that case the new @ObjectPath annotation will never work because it is a constant value.

Something similar may happen when using the DBusName annotation. There are some cases where the name is fixed. But there are even more cases where the same interface is used for different exported objects and just using different names. In that case the new annotation will only cover one of many possibilities.

To avoid confusion when using this library I don't want to add additional features which only work in a few cases and introduce possible misunderstanding/allow misusing.

If you still want to use annotations for your setup, you may create a utility method which does the steps you implemented inDBusConnection but in your own code.

Thank you for your reply. You're right, it seems I have some misunderstandings about the concept of dbus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants