Set the Service name of an own service

Matthew Johnson dbus at matthew.ath.cx
Wed Jul 9 08:05:37 PDT 2008


On Wed Jul 09 07:14, hannehomuth wrote:
> In the main method (not seen here) I opened a Connection and exported my
> Object to the Dbus. And it worked. When I open the D-Feet Dbus Debugger (a
> little tool to check whats going on on the dbus) I see my Object with the
> object path and all methods, but the name of my service is something like
> :1.15 or :1.10 or something else. It raises the more I start my app. This is
> the unique name I think. But how kann I set a name like (my.own.Dbusservice
> or org.freedesktop.Notifications)?
> I've already declared a .service file to /usr/share/dbus-1/services which
> looks like this.

You need to call requestBusName on your connection object. Documentation
is in the Javadoc here:

   http://dbus.freedesktop.org/doc/dbus-java/api/org/freedesktop/dbus/DBusConnection.html#requestBusName(java.lang.String)

You would call it with something like this:

   DBusConnection c = DBusConnection.getConnection(DBusConnection.SESSION);
   ...
   c.requestBusName("my.dbus.service");

> [D-BUS Service]
> Name=de.sourcepark.PicoLcd
> Exec=/home/jhomuth/NetBeansProjects/PicoLCDDbusDaemon/dist/PicoLCDDbusDaemon.jar

If you are autostarting you must be careful to export your objects (with
c.exportObject("/some/path", exportedobject)) _before_ requesting a bus
name, otherwise the message which autostarted it will not be delivered
correctly.

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/20080709/902884e1/attachment.pgp 


More information about the dbus mailing list