diff options
author | Tibor Sirovatka <tsirovat@cisco.com> | 2016-05-18 14:54:50 +0200 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2016-06-09 02:22:34 +0000 |
commit | 42bb61fd162b3dd469c9d98a9dc6d3e2b2eaffce (patch) | |
tree | 133e183e7b02d7d7e01f1ea1353421d8a65ddb2b /vpp-api/java/jvpp/gen/jvpp_impl_gen.py | |
parent | b10427e06077dbe3a9ea9922b97941204001f6b9 (diff) |
HONEYCOMB-67 Introduce exception handling into JVPP
Send calls throws VppInvocationException on failure
Failed requests (negative retval) reported over onError callback interface method
Removed retval attributes from dto/xxxReply.java calls
Change-Id: Ibd4e90c320d080e02d75b4bd056a7b11c8e37aa7
Signed-off-by: Tibor Sirovatka <tsirovat@cisco.com>
Diffstat (limited to 'vpp-api/java/jvpp/gen/jvpp_impl_gen.py')
-rw-r--r-- | vpp-api/java/jvpp/gen/jvpp_impl_gen.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/vpp-api/java/jvpp/gen/jvpp_impl_gen.py b/vpp-api/java/jvpp/gen/jvpp_impl_gen.py index 4e408c364b1..dfec6a743de 100644 --- a/vpp-api/java/jvpp/gen/jvpp_impl_gen.py +++ b/vpp-api/java/jvpp/gen/jvpp_impl_gen.py @@ -39,8 +39,10 @@ public interface JVpp extends java.lang.AutoCloseable { /** * Generic dispatch method for sending requests to VPP + * + * @throws org.openvpp.jvpp.VppInvocationException if send request had failed */ - int send($base_package.$dto_package.JVppRequest request); + int send($base_package.$dto_package.JVppRequest request) throws org.openvpp.jvpp.VppInvocationException; @Override void close(); @@ -76,7 +78,7 @@ public final class JVppImpl implements $base_package.JVpp { } @Override - public int send($base_package.$dto_package.JVppRequest request) { + public int send($base_package.$dto_package.JVppRequest request) throws org.openvpp.jvpp.VppInvocationException { return request.send(this); } @@ -84,23 +86,29 @@ $methods } """) -method_template = Template(""" int $name($base_package.$dto_package.$request request);""") +method_template = Template(""" int $name($base_package.$dto_package.$request request) throws org.openvpp.jvpp.VppInvocationException;""") method_native_template = Template( """ private static native int ${name}0($base_package.$dto_package.$request request);""") -method_impl_template = Template(""" public final int $name($base_package.$dto_package.$request request) { - if(request == null) { - throw new java.lang.NullPointerException("Null request object"); - } +method_impl_template = Template(""" public final int $name($base_package.$dto_package.$request request) throws org.openvpp.jvpp.VppInvocationException { + java.util.Objects.requireNonNull(request,"Null request object"); connection.checkActive(); - return ${name}0(request); + int result=${name}0(request); + if(result<0){ + throw new org.openvpp.jvpp.VppInvocationException("${name}",result); + } + return result; } """) -no_arg_method_template = Template(""" int $name();""") -no_arg_method_native_template = Template(""" private static native int ${name}0();""") -no_arg_method_impl_template = Template(""" public final int $name() { +no_arg_method_template = Template(""" int $name() throws org.openvpp.jvpp.VppInvocationException;""") +no_arg_method_native_template = Template(""" private static native int ${name}0() throws org.openvpp.jvpp.VppInvocationException;""") +no_arg_method_impl_template = Template(""" public final int $name() throws org.openvpp.jvpp.VppInvocationException { connection.checkActive(); - return ${name}0(); + int result=${name}0(); + if(result<0){ + throw new org.openvpp.jvpp.VppInvocationException("${name}",result); + } + return result; } """) |