用于激活与documentation的无线连接的ActivateConnection
表示,您可以提供"/"
作为第二和第三参数,以使dbus为您选择合理的默认值。
由于Java中函数的绑定为DBusInterface
类型,您该怎么做?您几乎不能写(DBusInterface)"/"
,对吗?
如果有人可以回答上述问题,我将非常感谢。对于有更多时间或对该领域有了解的任何人,我要解决的real问题是我对ActivateConnection
的呼叫崩溃了。这是导致崩溃的代码。它引用this interface。
var nmIface = (NetworkManagerIface) instance.getRemoteObject(NetworkManagerIface._NM_IFACE, NetworkManagerIface._NM_PATH, NetworkManagerIface.class);
System.out.println("Connect:" + connMatch.getObjectPath());
System.out.println("Adaptor:" + adaptor.getObjectPath());
System.out.println("AccessP:" + accessMatch.getObjectPath());
for (DBusPath devName : nmIface.GetDevices()) {
System.out.println(" Device:" + devName.getPath());
}
nmIface.ActivateConnection(connMatch, adaptor, accessMatch);
并产生此输出(SO插入的颜色):
Connect:/org/freedesktop/NetworkManager/Settings/4
Adaptor:/org/freedesktop/NetworkManager/Devices/3
AccessP:/org/freedesktop/NetworkManager/AccessPoint/248
Device:/org/freedesktop/NetworkManager/Devices/1
Device:/org/freedesktop/NetworkManager/Devices/2
Device:/org/freedesktop/NetworkManager/Devices/3
Exception in thread "JavaFX Application Thread" org.freedesktop.dbus.exceptions.DBusExecutionException: Failed to construct D-Bus type: Not an object exported or imported by this connection at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:102)
at org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:228)
at com.sun.proxy.$Proxy23.ActivateConnection(Unknown Source)
at com.mycompany.Wifi.activateConnection(Wifi.java:322)
如果任何人都可以提供有关that可能出什么问题的指示,我将不胜感激。
您的绑定几乎可以肯定是错误的。如果我们查看Activate Connection的文档,就会发现它具有以下参数:
ActivateConnection (IN o connection,
IN o device,
IN o specific_object,
OUT o active_connection);
在这种情况下,'o'告诉您此参数类型是什么。类型是在DBus specification中指定的,但是出于我们的目的,我们所需要知道的就是'o'表示此参数是对象路径。这将对应于dbus-java中的Path
类型(如果使用的是2.7绑定)或Path
类型(如果使用的是hypfvieh的更新的3.2绑定)。
当前类型是:
DBusPath
但是考虑到'o'的实际含义,可能应该是:
DBusPath
一个更好的解决方案是对dbus-java(hypfvieh版本)使用public DBusInterface ActivateConnection(DBusInterface connection, DBusInterface device, DBusInterface specific_object);
程序来获取public DBusInterface ActivateConnection(DBusPath connection, DBusPath device, DBusPath specific_object);
并自动为您创建此类。