dbus java bindings name registery and introspection problem

ozgur cagdas ocagdas at yahoo.com
Thu Feb 11 03:26:46 PST 2010


Hi,

I have written the below interface and it's implementation just to practice java dbus bindings but the problem is, when I compile it and run, it doesn't register the name 'com.mycompany.wrapper_interface' but a standard name assigned by the bus something like ':1.99'. 

Just probably because my implementation of Introspect method returns null, I cannot introspect this interface either. Previously I've used Qt dbus bindings and in that case using annotations was enough to make the interface introspectable. So, what should I do to make this interface introspectable? I hope the answer is not simply 'fil the Introspect method manually' or at least there is a better alternative do exists.

Cheers,

Ozgur.

ps: I am using dbus-java-2.7

package com.mycompany.wrapper_interface;

import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusInterfaceName;
import org.freedesktop.dbus.DBusSignal;
import org.freedesktop.DBus.Introspectable;
import org.freedesktop.dbus.exceptions.DBusException;

@DBusInterfaceName("com.mycompany.wrapper_interface.DvbDemuxInterface") //although this shouldn't be necessary since it's same with the package name, using anyway
public interface DvbDemuxInterface extends DBusInterface, Introspectable {

    public class DvbDemuxDbusSigNo1 extends DBusSignal {

        public DvbDemuxDbusSigNo1(String path, String name) throws DBusException {
            super(path, name);
        }
    }

    @org.freedesktop.DBus.Description("Print something for me")
    @org.freedesktop.DBus.Method.NoReply
    public void printSomethingForMe();
}

package com.mycompany.wrapper;

import org.freedesktop.dbus.DBusConnection;
import org.freedesktop.dbus.exceptions.*;
import com.mycompany.wrapper_interface.*;

public class DvbDemux implements DvbDemuxInterface{

    public static void main(String[] args) {
        System.out.println("Creating DvbDemuxConnection");

        DBusConnection conn = null;
        try {
            conn = DBusConnection.getConnection(DBusConnection.SESSION);
        } catch (DBusException De) {
            System.exit(1);
        }

        int count = 2;
        while(count != 0) {
            try {
                try {
                        conn.sendSignal(new DvbDemuxInterface.DvbDemuxDbusSigNo1(
                                        "/com/mycompany/wrapper_interface",
                                        "just_a_param"
                                        ));
                    } catch (DBusException De) {
                        System.exit(1);
                    }
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            count--;
        }

        System.out.println("Exiting DvbDemuxConnection");
    }

    public boolean isRemote() {
        return false;
    }

    @Override
    public void printSomethingForMe() {
        System.out.println("Here is a print for you!!!\n");
    }

    @Override
    public String Introspect() {
        return null;
    }
}


      


More information about the dbus mailing list