[PATCH 5/5] [mamajni] Add AppDAtaType


Ian Bell <IBell@...>
 

From 863540789f9a685952ee37b8aee23792a992e8e8 Mon Sep 17 00:00:00 2001

Message-Id: <863540789f9a685952ee37b8aee23792a992e8e8.1348836736.git.ibell@...>

In-Reply-To: <96f0ea876c43e27f628c68dca155ce2f5b82fa09.1348836736.git.ibell@...>

References: <96f0ea876c43e27f628c68dca155ce2f5b82fa09.1348836736.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Fri, 28 Sep 2012 13:51:19 +0100

Subject: [PATCH 5/5] [mamajni] Add AppDAtaType

 

Adde the ability to set and get the AppDataType on a subscription

in java.

 

Signed-off-by: Ian Bell <ibell@...>

---

mama/jni/build.xml                                 |    2 +-

mama/jni/src/c/mamasubscriptionjni.c               |   55 ++++++++++++++++++++

mama/jni/src/com/wombat/mama/MamaMdDataType.java   |   31 +++++++++++

mama/jni/src/com/wombat/mama/MamaSubscription.java |   13 +++--

4 files changed, 96 insertions(+), 5 deletions(-)

 

diff --git a/mama/jni/build.xml b/mama/jni/build.xml

index 8c30432..b5708dc 100644

--- a/mama/jni/build.xml

+++ b/mama/jni/build.xml

@@ -207,7 +207,7 @@

         </copy>                                   

 

         <javadoc access="public" source="1.5" destdir="${dist}/doc" failonerror="no" Overview="overview-jni.html" doctitle="MAMA (Middleware Agnostic Messaging API) JNI specification, v${version}" Bottom="Copyright 2011 NYSE Technologies" Windowtitle="MAMA JNI ${version}">

-                                              <Header>&lt;img src='{@docRoot}resources/nyse_technologies.png' alt='NYSE Technologies' /&gt;&lt;br/&gt;&lt;b&gt;MAMA JNI&lt;/b&gt;&lt;br&gt;&lt;font size='-1'&gt;version ${version}&lt;/font&gt;</Header>

+                                             <Header>&lt;img src='{@docRoot}resources/openmama.png' alt='NYSE Technologies' /&gt;&lt;br/&gt;&lt;b&gt;MAMA JNI&lt;/b&gt;&lt;br&gt;&lt;font size='-1'&gt;version ${version}&lt;/font&gt;</Header>

                                               <fileset dir="./src">

                 <include name="**/*.java"></include>               

             </fileset>                                                                                

diff --git a/mama/jni/src/c/mamasubscriptionjni.c b/mama/jni/src/c/mamasubscriptionjni.c

index bb3c1a7..08b251f 100644

--- a/mama/jni/src/c/mamasubscriptionjni.c

+++ b/mama/jni/src/c/mamasubscriptionjni.c

@@ -1790,3 +1790,58 @@ JNIEXPORT void JNICALL Java_com_wombat_mama_MamaSubscription_deallocate(JNIEnv *

         }

     }

}

+

+JNIEXPORT void JNICALL Java_com_wombat_mama_MamaSubscription_setTheAppDataType (JNIEnv * env, jobject this, jint value)

+{

+    mama_status     status              =   MAMA_STATUS_OK;

+    jlong           subscriptionPointer =   0;

+    char errorString[UTILS_MAX_ERROR_STRING_LENGTH];

+

+    subscriptionPointer =

+        (*env)->GetLongField(env,this,subscriptionPointerFieldId_g);

+

+    assert(0!=subscriptionPointer);

+

+    if (MAMA_STATUS_OK!=(status=mamaSubscription_setAppDataType(

+                             CAST_JLONG_TO_POINTER(mamaSubscription,subscriptionPointer),

+                             (uint8_t)value)))

+    {

+        utils_buildErrorStringForStatus (

+            errorString,

+            UTILS_MAX_ERROR_STRING_LENGTH,

+            "Could not set AppDatatype for mamaSubscription.",

+            status);

+        utils_throwWombatException (env,errorString);

+    }

+

+    return;

+}

+

+JNIEXPORT jint JNICALL Java_com_wombat_mama_MamaSubscription_getTheAppDataType (JNIEnv* env, jobject this)

+{

+    mama_status     status              =   MAMA_STATUS_OK;

+    jlong           subscriptionPointer =   0;

+    jint            appdatatype         =   0;

+    char errorString[UTILS_MAX_ERROR_STRING_LENGTH];

+

+    subscriptionPointer = (*env)->GetLongField(env,this,subscriptionPointerFieldId_g);

+

+    MAMA_THROW_NULL_PARAMETER_RETURN_VALUE(subscriptionPointer,

+    "MamaSubscription.getAppDataType(): Null parameter, subcription may have been destroyed.", NULL);

+

+    assert(0!=subscriptionPointer);

+

+    if (MAMA_STATUS_OK!=(status=mamaSubscription_getAppDataType(

+                    CAST_JLONG_TO_POINTER(mamaSubscription,subscriptionPointer),

+                    &appdatatype)))

+    {

+        utils_buildErrorStringForStatus(

+                errorString,

+                UTILS_MAX_ERROR_STRING_LENGTH,

+                "Could not get AppDatatype for mamaSubscription.",

+                status);

+        utils_throwWombatException(env,errorString);

+    }

+

+    return appdatatype;

+}

diff --git a/mama/jni/src/com/wombat/mama/MamaMdDataType.java b/mama/jni/src/com/wombat/mama/MamaMdDataType.java

index 2c6ec5e..5e2c70d 100644

--- a/mama/jni/src/com/wombat/mama/MamaMdDataType.java

+++ b/mama/jni/src/com/wombat/mama/MamaMdDataType.java

@@ -42,6 +42,21 @@ public final class MamaMdDataType

     public static final MamaMdDataType WORLDVIEW = new MamaMdDataType

                              (valueToString (WORLDVIEW_VALUE), WORLDVIEW_VALUE);                        

     

+    public static final int            PROPERTY_VALUE = 4;

+    public static final MamaMdDataType PROPERTY = new MamaMdDataType

+                             (valueToString (PROPERTY_VALUE), PROPERTY_VALUE);                        

+

+    public static final int            USAGE_LOG_VALUE = 5;

+    public static final MamaMdDataType USAGE_LOG = new MamaMdDataType

+                             (valueToString (USAGE_LOG_VALUE), USAGE_LOG_VALUE);                        

+

+    public static final int            NEWS_QUERY_VALUE = 6;

+    public static final MamaMdDataType NEWS_QUERY = new MamaMdDataType

+                             (valueToString (NEWS_QUERY_VALUE), NEWS_QUERY_VALUE);                        

+

+    public static final int            TEMPLATE_VALUE = 7;

+    public static final MamaMdDataType TEMPLATE = new MamaMdDataType

+                             (valueToString (TEMPLATE_VALUE), TEMPLATE_VALUE);                        

     /* No publicly created instances allowed */

     private MamaMdDataType (String name, int value)

     {

@@ -108,6 +123,14 @@ public final class MamaMdDataType

                 return "NEWS_STORY";

             case WORLDVIEW_VALUE:

                 return "WORLDVIEW";   

+            case PROPERTY_VALUE:

+                return "PROPERTY";   

+            case USAGE_LOG_VALUE:

+                return "USAGE_LOG";   

+            case NEWS_QUERY_VALUE:

+                return "NEWS_QUERY";   

+            case TEMPLATE_VALUE:

+                return "TEMPLATE";   

             default:

                 return "UNKNOWN";

         }

@@ -133,6 +156,14 @@ public final class MamaMdDataType

                 return NEWS_STORY;

             case WORLDVIEW_VALUE:

                 return WORLDVIEW;   

+            case PROPERTY_VALUE:

+                return PROPERTY;   

+            case USAGE_LOG_VALUE:

+                return USAGE_LOG;   

+            case NEWS_QUERY_VALUE:

+                return NEWS_QUERY;   

+            case TEMPLATE_VALUE:

+                return TEMPLATE;   

             default:

                 return null;

         }

diff --git a/mama/jni/src/com/wombat/mama/MamaSubscription.java b/mama/jni/src/com/wombat/mama/MamaSubscription.java

index f83aa7b..6916434 100644

--- a/mama/jni/src/com/wombat/mama/MamaSubscription.java

+++ b/mama/jni/src/com/wombat/mama/MamaSubscription.java

@@ -303,14 +303,17 @@ public class MamaSubscription

    

     public void setAppDataType (MamaMdDataType type)

     {

-        final String METHOD_NAME = "setAppDataType(): ";

-        throw new MamaException(METHOD_NAME+"Not yet supported");

+          // Set the MD Data Type as an integer

+          setTheAppDataType (type.getValue());

     }

     public MamaMdDataType getAppDataType ()

     {

-        final String METHOD_NAME = "getAppDataType(): ";

-        throw new MamaException(METHOD_NAME+"Not yet supported");

+        // Get the native value

+        int my_AppDataType = getTheAppDataType();

+

+        // Convert to a MamaMdDataType object

+        return MamaMdDataType.enumObjectForValue(my_AppDataType);

     }

     public void setDebugLevel (Level level)

@@ -350,6 +353,8 @@ public class MamaSubscription

     /* Public Native Functions, all entries here must be fully

      * documented. */

     /* ************************************************** */

+    private native void setTheAppDataType(int value);

+    private native int getTheAppDataType();

     /**

      * Activate a subscription that has been set up by calling MamaSubscription.setup.

--

1.7.9.5

 




Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.