qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject svn commit: r1350712 - in /qpid/branches/address-refactor2/qpid/cpp/bindings: qpid/java/java.i swig_java_cpp_helper.i
Date Fri, 15 Jun 2012 17:24:10 GMT
Author: rajith
Date: Fri Jun 15 17:24:09 2012
New Revision: 1350712

URL: http://svn.apache.org/viewvc?rev=1350712&view=rev
Log:
QPID-4027 Added one-to-one exception mapping between c++ and java to
provide the application/users more detailed error information.

Modified:
    qpid/branches/address-refactor2/qpid/cpp/bindings/qpid/java/java.i
    qpid/branches/address-refactor2/qpid/cpp/bindings/swig_java_cpp_helper.i

Modified: qpid/branches/address-refactor2/qpid/cpp/bindings/qpid/java/java.i
URL: http://svn.apache.org/viewvc/qpid/branches/address-refactor2/qpid/cpp/bindings/qpid/java/java.i?rev=1350712&r1=1350711&r2=1350712&view=diff
==============================================================================
--- qpid/branches/address-refactor2/qpid/cpp/bindings/qpid/java/java.i (original)
+++ qpid/branches/address-refactor2/qpid/cpp/bindings/qpid/java/java.i Fri Jun 15 17:24:09
2012
@@ -64,6 +64,77 @@ std::string toString()
 }
 
 }
+
+%exception {
+
+    try {
+        $action
+    // --> Receive exceptions
+    } catch (qpid::messaging::NoMessageAvailable& ex) {
+        jenv->ThrowNew(JAVA_NO_MSG_AVAILABLE_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::FetchError& ex) {
+        jenv->ThrowNew(JAVA_FETCH_EXP, ex.what());
+        return $null;
+    // --> Send exceptions
+    } catch (qpid::messaging::TargetCapacityExceeded& ex) {
+        jenv->ThrowNew(JAVA_TARGET_CAP_EXCEEDED_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::SendError& ex) {
+        jenv->ThrowNew(JAVA_SEND_EXP, ex.what());
+        return $null;
+    // --> Address exceptions
+    } catch (qpid::messaging::NotFound& ex) {
+        jenv->ThrowNew(JAVA_ADDR_NOT_FOUND_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::AssertionFailed& ex) {
+        jenv->ThrowNew(JAVA_ADDR_ASSERTION_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::MalformedAddress& ex) {
+        jenv->ThrowNew(JAVA_MALFORMED_ADDR_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::ResolutionError & ex) {
+        jenv->ThrowNew(JAVA_ADDR_RESOLUTION_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::TransactionAborted & ex) {
+        jenv->ThrowNew(JAVA_TX_ABORTED_EXP, ex.what());
+        return $null;
+    // --> Session exceptions
+    } catch (qpid::messaging::TransactionError & ex) {
+        jenv->ThrowNew(JAVA_TRANSACTION_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::UnauthorizedAccess & ex) {
+        jenv->ThrowNew(JAVA_UNAUTHORIZED_EXP, ex.what());
+        return $null;
+    // transport
+    } catch (qpid::messaging::TransportFailure & ex) {
+        jenv->ThrowNew(JAVA_TRANSPORT_FAILURE_EXP, ex.what());
+        return $null;
+    // general catch all exceptions
+    } catch (qpid::messaging::ConnectionError& ex) {
+        jenv->ThrowNew(JAVA_NO_MSG_AVAILABLE_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::SessionError& ex) {
+        jenv->ThrowNew(JAVA_NO_MSG_AVAILABLE_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::SenderError& ex) {
+        jenv->ThrowNew(JAVA_NO_MSG_AVAILABLE_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::ReceiverError& ex) {
+        jenv->ThrowNew(JAVA_NO_MSG_AVAILABLE_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::AddressError& ex) {
+        jenv->ThrowNew(JAVA_NO_MSG_AVAILABLE_EXP, ex.what());
+        return $null;
+    } catch (qpid::messaging::MessagingException& ex) {
+        jenv->ThrowNew(JAVA_NO_MSG_AVAILABLE_EXP, ex.what());
+        return $null;
+    } catch (qpid::types::Exception& ex) {
+        jenv->ThrowNew(JAVA_RUNTIME_EXP, ex.what());
+        return $null;
+    }
+}
+
 %rename(NativeConnection) qpid::messaging::Connection;
 %rename(NativeSession) qpid::messaging::Session;
 %rename(NativeSender) qpid::messaging::Sender;

Modified: qpid/branches/address-refactor2/qpid/cpp/bindings/swig_java_cpp_helper.i
URL: http://svn.apache.org/viewvc/qpid/branches/address-refactor2/qpid/cpp/bindings/swig_java_cpp_helper.i?rev=1350712&r1=1350711&r2=1350712&view=diff
==============================================================================
--- qpid/branches/address-refactor2/qpid/cpp/bindings/swig_java_cpp_helper.i (original)
+++ qpid/branches/address-refactor2/qpid/cpp/bindings/swig_java_cpp_helper.i Fri Jun 15 17:24:09
2012
@@ -79,10 +79,41 @@ static jmethodID JAVA_DOUBLE_CTOR;
 static jmethodID JAVA_DOUBLE_VALUE_METHOD;
 
 static jclass JAVA_ILLEGAL_ARGUMENT_EXP;
+static jclass JAVA_RUNTIME_EXP;
 static jclass JAVA_JNI_LAYER_EXP;
 static jmethodID JAVA_JNI_LAYER_EXP_CTOR1; // takes a msg.
 static jmethodID JAVA_JNI_LAYER_EXP_CTOR2; // takes a msg and a throwable.
 
+// receiver
+static jclass JAVA_NO_MSG_AVAILABLE_EXP;
+static jclass JAVA_FETCH_EXP;
+
+// sender
+static jclass JAVA_TARGET_CAP_EXCEEDED_EXP;
+static jclass JAVA_SEND_EXP;
+
+// address
+static jclass JAVA_ADDR_NOT_FOUND_EXP;
+static jclass JAVA_MALFORMED_ADDR_EXP;
+static jclass JAVA_ADDR_RESOLUTION_EXP;
+static jclass JAVA_ADDR_ASSERTION_EXP;
+
+// session
+static jclass JAVA_TRANSACTION_EXP;
+static jclass JAVA_TX_ABORTED_EXP;
+static jclass JAVA_UNAUTHORIZED_EXP;
+
+// transport
+static jclass JAVA_TRANSPORT_FAILURE_EXP;
+
+// general catch all
+static jclass JAVA_MESSAGING_EXP;
+static jclass JAVA_CONNECTION_EXP;
+static jclass JAVA_SESSION_EXP;
+static jclass JAVA_SENDER_EXP;
+static jclass JAVA_RECEIVER_EXP;
+static jclass JAVA_ADDR_EXP;
+
 static jobject createGlobalRef(JNIEnv* env,jobject obj)
 {
     return env->NewGlobalRef(obj);
@@ -160,10 +191,43 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM
    JAVA_FLOAT_VALUE_METHOD = getMethodID(env,JAVA_FLOAT_CLASS,"floatValue", "()F");
 
    JAVA_ILLEGAL_ARGUMENT_EXP = static_cast<jclass>(createGlobalRef(env,findClass(env,"java/lang/IllegalArgumentException")));
+   JAVA_RUNTIME_EXP   = static_cast<jclass>(createGlobalRef(env,findClass(env,"java/lang/RuntimeException")));
    JAVA_JNI_LAYER_EXP = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/cpp/JNILayerException")));
    JAVA_JNI_LAYER_EXP_CTOR1 = getMethodID(env,JAVA_JNI_LAYER_EXP, "<init>", "(Ljava/lang/String;)V");
    JAVA_JNI_LAYER_EXP_CTOR2 = getMethodID(env,JAVA_JNI_LAYER_EXP, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V");
 
+   // Messaging exceptions ---------------
+
+   // receiver
+   JAVA_NO_MSG_AVAILABLE_EXP = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/NoMessageAvailableException")));
+   JAVA_FETCH_EXP            = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/FetchException")));
+
+   // sender
+   JAVA_TARGET_CAP_EXCEEDED_EXP = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/TargetCapacityExceededException")));
+   JAVA_SEND_EXP                = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/SendException")));
+
+   // address
+   JAVA_ADDR_NOT_FOUND_EXP   = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/AddressNotFoundException")));
+   JAVA_MALFORMED_ADDR_EXP   = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/MalformedAddressException")));
+   JAVA_ADDR_RESOLUTION_EXP  = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/AddressResolutionException")));
+   JAVA_ADDR_ASSERTION_EXP   = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/AddressAssertionFailedException")));
+
+   // session
+   JAVA_TRANSACTION_EXP  = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/TransactionException")));
+   JAVA_TX_ABORTED_EXP   = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/TransactionAbortedException")));
+   JAVA_UNAUTHORIZED_EXP = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/UnauthorizedAccessException")));
+
+   // transport
+   JAVA_TRANSPORT_FAILURE_EXP   = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/TransportFailureException")));
+
+   // general catch all
+   JAVA_MESSAGING_EXP = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/MessagingException")));
+   JAVA_CONNECTION_EXP = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/ConnectionException")));
+   JAVA_SESSION_EXP    = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/SessionException")));
+   JAVA_SENDER_EXP     = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/SenderException")));
+   JAVA_RECEIVER_EXP   = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/ReceiverException")));
+   JAVA_ADDR_EXP       = static_cast<jclass>(createGlobalRef(env,findClass(env,"org/apache/qpid/messaging/AddressException")));
+
    if (env->ExceptionCheck())
    {
       // The JVM will throw an exception on the Java side.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message