Java DBus Namespace problem.

Arigead captain.deadly at
Mon Mar 1 23:38:01 PST 2010

Matthew Johnson wrote:
> On Mon Mar 01 17:12, Arigead wrote:
>> Hello all,
>>     I've got a wee problem with Java DBus code I'm trying to write to
>> use the org.navit_project.navit interfaces. My problem is that there are
>> methods in the interface org.navit_project.navit and in the interface
>> org.navit_project.navit.navit
>> I've got an Interface file for the upper Interface:
>> package org.navit_project;
>> @DBusInterfaceName("org.navit_project.navit")
>> public interface navit extends DBusInterface
>> {
>>     public Path callback_attr_new(String signalname, String attribute);
>> }
>> But if I do the same thing again for org.navit_project.navit.navit:
>> package org.navit_project.navit;
>> @DBusInterfaceName("org.navit_project.navit.navit")
>> public interface navit extends DBusInterface
>> {
>>     public String method(String attribute);
>> }
>> It'll cause namespace conflicts in the Java namespace? That's a question
>> as I'm not an expert in Java but I would have thought that this would
>> cause some confusion in the code which calls methods from both namespaces.
>> import org.navit_project.navit
>> import org.navit_project.navit.navit
> It's worse than that, you just can't have a class/interface with the same name
> as the package.
> Two options here, firstly, the @DBusInterfaceName you currently have are
> redundant, that's the default which dbus-java automatically uses
> (  You can use @DBusInterfaceName to change the name, so you
> could use the Java package navit_dbus_interfaces, and call one navit and the
> other navit_navit (or something), then use @DBusInterfaceName to make the
> correct.
> The other option is to declare one interface as a member of the other:
> package org.navit_project;
> public interface navit extends DBusInterface
> {
>    public static interface navit extends DBusInterface
>    {
>       ...
>    }
>    ...
> }
> Then, you can refer to both org.navit_project.navit.navit and
> org.navit_project.navit.navit in your Java code and everything will work
> correctly.
> On the import side, you are right that you can't import both of them, but you
> can always use the fully qualified form everywhere you would just
> name the class, or you can import org.navit_project.navit and then refer to
> navit and navit.navit.
> Finally, may I say what a poor choice of interface names that is from whoever
> designed them (-;
> Matt

    thanks a million for that you've certainly answered the question
fully. I'll try put one interface inside the other as you suggest. As
for the bad names for interfaces you'll get no argument from me ;-)

Thanks again.

More information about the dbus mailing list