dbus-java-2.6 No signal notification

Kees Jongenburger kees.jongenburger at gmail.com
Mon Nov 2 15:03:42 PST 2009


On Mon, Nov 2, 2009 at 7:34 PM, pgodin <pgodin at rheinmetall.ca> wrote:
> Using dbus-1.2.14, dbus-java-2.6, jdk-1.6.0_16 and bluez-4.56,:
> Java application isn't notified when a signal is sent on dbus. Using
> dbus-monitor I can see signals being passed on the system bus. My proof
> of concept application uses dbus to setup a bluetooth adapter
> visibility. I would also like it to be notified of signals such as
> device removal and addition although this example listens for
> PopertyChanged signals. My gut feeling is that I am not using dbus as it
> should be although I went through the documentation and several online
> discussions. I you believe my problem better be posted on the bluez
> list, please tell me so.

I am pretty new to all this but I think you are indeed doing it the wrong way.

> public class DBusConn
> {
>    public DBusConn()
>    {
>        DBusConnection connection = null;
>        try
>        {
>            connection =
> DBusConnection.getConnection(DBusConnection.SYSTEM);
>            final Manager manager =
> connection.getRemoteObject("org.bluez", "/", Manager.class);

Getting a reference to a remote object

>            final Path defaultAdapterPath = manager.DefaultAdapter();
>            final Adapter adapter =
> connection.getRemoteObject("org.bluez", defaultAdapterPath.getPath(),
> Adapter.class);


> connection.addSigHandler(org.bluez.Adapter.PropertyChanged.class,

Registering to receive Signal but this is totally unrelated to the
previous code (getting hold of
remote objects). I aksed the same kind of question yesterday signals
are sent "to" object and not from so I threory
you need to implement the Object before you can listen to changed.

However apparently the Java implementation makes it possible to listen
to those signals but in that case you don't need to
get hold of the remote objects a all.

Here is an example that works for me

package com.test;

import org.freedesktop.dbus.DBusConnection;
import org.freedesktop.dbus.DBusSigHandler;
import org.freedesktop.dbus.exceptions.DBusException;

 * dbus-send \
        --system \
        /com/test/Notification \

public class RunNotification implements DBusSigHandler<Notification.Notify> {

        public static void main(String[] args) throws DBusException {
                RunNotification instance = new RunNotification();
                DBusConnection conn  =
                conn.addSigHandler(Notification.Notify.class, instance);

        public void handle(Notification.Notify arg0) {

More information about the dbus mailing list