IDL language
David Zeuthen
david at fubar.dk
Sat May 9 06:37:01 PDT 2009
On Sat, 2009-05-09 at 09:02 +0100, Matthew Johnson wrote:
> On Fri May 08 21:37, Havoc Pennington wrote:
> > it would be nice if your app is written in Java, to write a Java
> > interface with some special dbus annotations if needed, and during the
> > build, install a typelib based on that - which could include docs,
> > struct names, the works.
>
> This is, in fact, precisely how dbus-java works now. There is a
> xml-to-java program, but the recommended approach is to just write a
> Java interface file with a very small amount of sugar, and then the
> introspection data is generated from that.
But for writing a Java _client_, xml-to-java will be useful, especially
once the discussed typelib stuff has materialized. Sure, hooking things
up to the build system is painful, but with things like Eclipse this
doesn't have to be hard.
For example, if you wanted to use DeviceKit-disks from Java, wouldn't
you rather want to deal with e.g. AtaSmartData objects (with getters and
setters, e.g. .IsDiskDying()) rather than a Map<String,Variant>?
I know that I would, especially since I'd be able to leverage completion
stuff etc. in Eclipse (then again, I haven't written any serious Java
code or the better part of 5 years).
> This will always be the official way to write dbus services in Java. A
> Java interface basically _is_ IDL, I don't want another one if I can
> help it...
I think the long term plan for C/GObject is something similar and, I for
one, is planning to work on that too. I mean, just adding a few
annotations / magic comments to a GObject class, and, hey, presto, stuff
can be exported on the bus is extremely useful. This is useful
especially if the GObject introspection stuff can install the D-Bus XML
into the typelib repo. Because, then I can generate client code too
without really doing anything.
Also, I think that if I wanted to implement, say, DeviceKit-disks in
Java, I'd want to use the existing IDL / typelib and have have some way
to generate Java interfaces (or base classes) that I would implement in
Java. The compiler would yell at me if I got it wrong.
One of the main reason I think IDL is useful is that it gives us a
reference language when discussing interfaces on mailing lists (e.g.
proposing cross desktop interfaces on xdg-list like org.fd.Screensaver
etc.). It also helps ensure that the code you actually write to
implement said interfaces by giving you errors at compile time rather
than run-time.
IDL also helps if the designer of a D-Bus interface differs from that of
the implementation team. This is often the case in big companies or big
teams and it's often useful to have compilers whine if someone joins the
team and get it wrong. E.g. it helps scale the whole development team by
separating responsibilities <insert other reasons for CORBA here>.
David
More information about the dbus
mailing list