[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [libvirt-java] [PATCH 00/12] event support



At Thu, 17 Jan 2013 16:18:58 +0100,
Claudio Bley wrote:
> 
> Hi.
> 
> This patch series is for early review. Please comment.

Forgot the sample code. Here it is:

,----
| package org.libvirt.sample;
| 
| import org.libvirt.*;
| 
| class EventSample {
|     volatile static boolean keepGoing = true;
| 
|     public static void main(String[] args) throws LibvirtException {
|         Connect c = null;
|         try {
|             Connect.initEventLoop();
| 
|             c = new Connect("qemu:///system");
| 
|             c.setKeepAlive(3, 10);
| 
|             int cb1 = c.domainEventRegister(new Connect.DomainEvent.LifecycleCallback() {
|                                                 @Override
|                                                 public void onLifecycleChange(Connect c,
|                                                                               Domain d,
|                                                                               Connect.DomainEvent.LifecycleCallback.Event event,
|                                                                               int detail)
|                                                 {
|                                                     System.out.println("lifecycle change: " + d + " " + event + " " + detail);
|                                                 }
|                                            });
| 
|             System.out.println("Press Ctrl+D to exit.\n");
| 
|             new Thread() {
|                 @Override
|                 public void run() {
|                     try {
|                         while (System.in.read() > 0);
|                     } catch (java.io.IOException e) {}
|                     keepGoing = false;
|                 }
|             }.start();
| 
|             while (keepGoing && c.isAlive()) c.processEvent();
| 
|             c.domainEventDeregister(cb1);
|         } finally {
|             if (c != null) c.close();
|         }
|     }
| }
`----

Claudio
-- 
AV-Test GmbH, Henricistra├če 20, 04155 Leipzig, Germany
Phone: +49 341 265 310 19
Web:<http://www.av-test.org>

Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076)
Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]