Hi,
Attached is a patch for OpenMAMA JNI that overloads the MamaPublisher create method. For consistency purposes, the new method requires two String parameters,
source and symbol, as opposed to a single string currently found in the MamaPublisher class.
diff --git a/mama/jni/src/c/mamapublisherjni.c b/mama/jni/src/c/mamapublisherjni.c
index 518bacf..629a51b 100644
--- a/mama/jni/src/c/mamapublisherjni.c
+++ b/mama/jni/src/c/mamapublisherjni.c
@@ -78,7 +78,7 @@ static void MAMACALLTYPE sendCompleteCB (mamaPublisher publisher,
* Method: _create
* Signature: (Lcom/wombat/mama/Transport;Ljava/lang/String;)V
*/
-JNIEXPORT void JNICALL Java_com_wombat_mama_MamaPublisher__1create
+JNIEXPORT void JNICALL Java_com_wombat_mama_MamaPublisher__1create__Lcom_wombat_mama_MamaTransport_2Ljava_lang_String_2
(JNIEnv* env, jobject this, jobject transport, jstring topic)
{
mamaPublisher cPublisher = NULL;
@@ -125,6 +125,66 @@ JNIEXPORT void JNICALL Java_com_wombat_mama_MamaPublisher__1create
return;
}
+ /*
+ * Class: com_wombat_mama_MamaPublisher
+ * Method: _create
+ * Signature: (Lcom/wombat/mama/MamaTransport;Ljava/lang/String;Ljava/lang/String;)V
+ */
+JNIEXPORT void JNICALL Java_com_wombat_mama_MamaPublisher__1create__Lcom_wombat_mama_MamaTransport_2Ljava_lang_String_2Ljava_lang_String_2
+ (JNIEnv* env, jobject this, jobject transport, jstring source, jstring symbol)
+{
+ mamaPublisher cPublisher = NULL;
+ mamaTransport cTransport = NULL;
+ const char* cSource = NULL;
+ const char* cSymbol = NULL;
+ jlong transportPointer = 0;
+ mama_status status = MAMA_STATUS_OK;
+ char errorString[UTILS_MAX_ERROR_STRING_LENGTH];
+
+ /*Get the transport pointer*/
+ assert(transport!=NULL);
+ transportPointer = (*env)->GetLongField(env, transport,
+ transportPointerFieldId_g);
+ cTransport = CAST_JLONG_TO_POINTER(mamaTransport, transportPointer);
+ assert(transportPointer!=0);
+
+ /*Get the char* from the jstring*/
+ if(NULL!=source)
+ {
+ cSource = (*env)->GetStringUTFChars(env,source,0);
+ if(!cSource)return;
+ }
+ if(NULL!=symbol)
+ {
+ cSymbol = (*env)->GetStringUTFChars(env,symbol,0);
+ if(!cSymbol)return;
+ }
+
+ if(MAMA_STATUS_OK!=(mamaPublisher_create(
+ &cPublisher,
+ cTransport,
+ cSymbol,
+ cSource,
+ NULL)))
+ {
+ if(cSource)(*env)->ReleaseStringUTFChars(env,source, cSource);
+ if(cSymbol)(*env)->ReleaseStringUTFChars(env,symbol, cSymbol);
+ utils_buildErrorStringForStatus(
+ errorString, UTILS_MAX_ERROR_STRING_LENGTH,
+ "Failed to create publisher.", status);
+ utils_throwMamaException(env,errorString);
+ return;
+ }
+
+ (*env)->SetLongField(env,this,publisherPointerFieldId_g,
+ CAST_POINTER_TO_JLONG(cPublisher));
+
+ if(cSource)(*env)->ReleaseStringUTFChars(env,source, cSource);
+ if(cSymbol)(*env)->ReleaseStringUTFChars(env,symbol, cSymbol);
+
+ return;
+}
+
/*
* Class: com_wombat_mama_MamaPublisher
* Method: _send
diff --git a/mama/jni/src/com/wombat/mama/MamaPublisher.java b/mama/jni/src/com/wombat/mama/MamaPublisher.java
index 0146945..c1e8dc8 100644
--- a/mama/jni/src/com/wombat/mama/MamaPublisher.java
+++ b/mama/jni/src/com/wombat/mama/MamaPublisher.java
@@ -39,6 +39,11 @@ public class MamaPublisher
{
_create(transport,topic);
}
+
+ public void create (MamaTransport transport, String source, String symbol)
+ {
+ _create(transport,source,symbol);
+ }
public void send (MamaMsg msg)
{
@@ -77,6 +82,8 @@ public class MamaPublisher
}
private native void _create (MamaTransport transport, String topic);
+
+ private native void _create (MamaTransport transport, String source, String symbol);
private native void _send (MamaMsg msg);
--
1.8.4.msysgit.0
Chad Meyer|
Corporate & Investment Bank | PIM Market Data Services |
J.P. Morgan | 4 Metrotech Center 23rd Floor Brooklyn, NY 11201
| Tel:
(718) 242-5165 | M:
(215) 801-2606 |
chad.j.meyer@...
This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as
an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of
JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is proprietary, privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified
that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect
any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage
arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to
http://www.jpmorgan.com/pages/disclosures for disclosures relating to European legal entities.