Extract class out of an RemoteObject

Matthew Johnson dbus at matthew.ath.cx
Mon Jun 30 09:16:10 PDT 2008


On Mon Jun 30 09:07, hannehomuth wrote:
> 3.       DBusInterface remoteObject;
> 4.       conn = DBusConnection.getConnection(DBusConnection.SESSION);
> 5.       remoteObject = conn.getRemoteObject("org.gnome.seahorse",
> "/org/gnome/seahorse/keys");                    
> 
> But now my Question. How can I call a Method? Is'nt it wrong that my
> variable remoteObject is from the typ DbusInterface. I think it have to be a
> Typ like GnomeKeyringDbusInterface or such a class. 

Because Java is a static language you have to create a .java file
corresponding to GnomeKeyringDbusInterface. Either you can write that by
hand, or you can use CreateInterface (comes with dbus-java) to convert
introspection to  java.

Once you have that compiled with the rest of your source, you can simply
cast the remote object to the right type. If you specify the type when
creating the object you don't even need the cast, and it saves a round
trip when the bindings introspect for you. Once you have an object of
the correct type you can just call methods as if they are local.

So, the code would look like:

   ... // connect to the bus etc
   GnomeKeyringDbusInterface remoteObject;
   remoteObject = conn.getRemoteObject("org.gnome.seahorse", "/org/gnome/seahorse/keys", GnomeKeyringDbusInterface.class)
   remoteObject.GetKeyTypes();

or

   GnomeKeyringDbusInterface remoteObject;
   remoteObject = (GnomeKeyringDbusInterface) conn.getRemoteObject("org.gnome.seahorse", "/org/gnome/seahorse/keys")
   remoteObject.GetKeyTypes();

This should (hopefully) all be documented at
http://dbus.freedesktop.org/doc/dbus-java

Matt

-- 
www.matthew.ath.cx
D-Bus Java
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/dbus/attachments/20080630/10bc865f/attachment.pgp 


More information about the dbus mailing list