diff options
author | Robert Varga <nite@hq.sk> | 2016-01-31 12:20:47 +0100 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2016-02-01 04:07:26 +0000 |
commit | 67ba3bed006c8fdaec5cbee897843d54cf2f538d (patch) | |
tree | c2621006466ad41855aaa76ebe97b27521ac4a10 /vpp-japi/japi/test | |
parent | d5201c80078fdecad8e6524e430b4b255f91b6b6 (diff) |
Refactor vpp-japi
vlib does not allow concurrent connections, hence make sure the Java API
does not allow the user to instantiate them.
Also hide native methods from direct user invocation behind defensive
methods also detect if a particular connection has been terminated.
Disconnect is hidden befind standard close() method, as specified by
AutoCloseable.
Change-Id: Ib5079200ae4216cad84358a2174a41e90271a30b
Signed-off-by: Robert Varga <nite@hq.sk>
Diffstat (limited to 'vpp-japi/japi/test')
-rw-r--r-- | vpp-japi/japi/test/demo.java | 17 | ||||
-rw-r--r-- | vpp-japi/japi/test/vppApi.java | 4 |
2 files changed, 7 insertions, 14 deletions
diff --git a/vpp-japi/japi/test/demo.java b/vpp-japi/japi/test/demo.java index ef419d70..ea1db84b 100644 --- a/vpp-japi/japi/test/demo.java +++ b/vpp-japi/japi/test/demo.java @@ -15,9 +15,11 @@ import org.openvpp.vppjapi.*; -public class demo extends vppApi { +public class demo { public static void main (String[] args) throws Exception { - vppApi api = new vppApi (); + vppApi api = new vppApi ("JavaTest"); + System.out.printf ("Connected OK..."); + String intlist; int [] contexts; int i, limit; @@ -25,15 +27,6 @@ public class demo extends vppApi { int rv, errors, saved_error; long before, after; - rv = api.clientConnect ("JavaTest"); - if (rv == 0) - System.out.printf ("Connected OK..."); - else - { - System.out.printf ("clientConnect returned %d\n", rv); - System.exit (1); - } - if (false) { intlist = api.getInterfaceList (""); @@ -171,7 +164,7 @@ public class demo extends vppApi { limit, after - before, limit / (after - before)); - api.clientDisconnect(); + api.close(); System.out.printf ("Done...\n"); } } diff --git a/vpp-japi/japi/test/vppApi.java b/vpp-japi/japi/test/vppApi.java index 96ba4a27..87af3292 100644 --- a/vpp-japi/japi/test/vppApi.java +++ b/vpp-japi/japi/test/vppApi.java @@ -16,13 +16,13 @@ import java.net.InetAddress; import org.openvpp.vppjapi.*; -public class vppApi extends vppConn { +public class vppApi { native int controlPing(); native void test (byte[] array, byte[] array2); public static void main (String[] args) throws Exception { - vppApi api = new vppApi (); + vppConn api = new vppConn (); String ipv6 = "db01::feed"; String ipv4 = "192.168.1.1"; InetAddress addr6 = InetAddress.getByName(ipv6); |