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

[libvirt] [libvirt-java] [PATCH 64/65] Replace static connectionVersion method with getLibVersion



Since the libvirt version information is a property of an *instance* of a
connnection, the method to retrieve this information should not be static.

Deprecate its use and recommend using aConnect.getLibVersion instead.

Signed-off-by: Claudio Bley <cbley av-test de>
---
 src/main/java/org/libvirt/Connect.java          |   18 ++++++++++++++++++
 src/test/java/org/libvirt/TestJavaBindings.java |    2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/libvirt/Connect.java b/src/main/java/org/libvirt/Connect.java
index 72f60f1..e909b29 100644
--- a/src/main/java/org/libvirt/Connect.java
+++ b/src/main/java/org/libvirt/Connect.java
@@ -112,7 +112,9 @@ public class Connect {
      *            the connection to use.
      * @return -1 in case of failure, versions have the format major * 1,000,000
      *         + minor * 1,000 + release.
+     * @deprecated Use { link #getLibVersion} instead.
      */
+    @Deprecated
     public static long connectionVersion(Connect conn) {
         LongByReference libVer = new LongByReference();
         int result = Libvirt.INSTANCE.virConnectGetLibVersion(conn.VCP, libVer);
@@ -144,6 +146,22 @@ public class Connect {
     }
 
     /**
+     * Get the libvirt library version of this connection.
+     *
+     * @see <a
+     *      href="http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetLibVersion";>Libvirt
+     *      Documentation</a>
+     * @return The version of libvirt used by the daemon running on
+     *         the connected host in the format { code major *
+     *         1,000,000 + minor * 1,000 + release}.
+     */
+    public long getLibVersion() throws LibvirtException {
+        LongByReference libVer = new LongByReference();
+        processError(libvirt.virConnectGetLibVersion(this.VCP, libVer));
+        return libVer.getValue();
+    }
+
+    /**
      * Sets the error function to a user defined callback
      *
      * @param callback
diff --git a/src/test/java/org/libvirt/TestJavaBindings.java b/src/test/java/org/libvirt/TestJavaBindings.java
index 86a1f53..c8674ad 100644
--- a/src/test/java/org/libvirt/TestJavaBindings.java
+++ b/src/test/java/org/libvirt/TestJavaBindings.java
@@ -56,7 +56,7 @@ public final class TestJavaBindings extends TestCase {
         assertEquals("conn.getMaxVcpus(xen)", 32, conn.getMaxVcpus("xen"));
         assertNotNull("conn.getHostName()", conn.getHostName());
         assertNotNull("conn.getCapabilities()", conn.getCapabilities());
-        assertTrue("conn.connectionVersion()", Connect.connectionVersion(conn) > 6000);        
+        assertTrue("conn.getLibVersion() > 6000", conn.getLibVersion() > 6000);        
         assertEquals("conn.getVersion()", 2, conn.getVersion());
         assertTrue("conn.isAlive", conn.isAlive());
         assertTrue("conn.isEncrypted", conn.isEncrypted() == 0);
-- 
1.7.9.5


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