
On 02/26/2014 08:47 PM, Chris Ellis wrote:
Hi all
I'm new to this list, I've been making use of the Libvirt Java bindings recently. I wanted to make use of domain events yesterday so my application can be alerted when the state of a domain changes etc.
Sideline observations (I'm not a user of the Java bindings):
Events can be listened to by, registering via the Connect object, as follows:
con.domainEventRegisterAny(DomainEventID.VIR_DOMAIN_EVENT_ID_LIFECYCLE, new DomainLifecycleEventHandler() {
That's a bit verbose. For example, the C code had to use 'RegisterAny' because it already had an older 'Register', and C doesn't allow overloads. But in Java, there is no loss of information if you just do: con.domainEventRegister(DomainEventID.LIFECYCLE, new DomainLifecycleEventHandler() {...}) Or even be more object oriented, and have 15 overloads, one for each type of handler class, so that the caller can merely do: con.domainEventRegister(new DomainLifecycleEventHandler() {...}) and it becomes obvious based on the type of handler that I passed in which C event id must be used.
I've put my clone of the libvirt-java git repository on Github, my modifications to the Java binding are in a separate branch and should be simple to merge. The changes can be viewed at:
https://github.com/intrbiz/libvirt-java/compare/master...ce-domain-events
On this list, it's easier to review patches if you use 'git send-email' to post your series on the list, than it it to make us chase down a random git repository. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org