From 2012533afb67397403142cd165ecded7e5a0f8bb Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Sun, 10 Jun 2012 23:38:23 +0000 Subject: QPID-4027 when retrieving objects from the map they are now directly returned with being assigned to a local jobject, as it then looses the type information when received at the Java layer. The code now avoids using cached JNIEnv pointers as if it gets called from a different thread the ref will be now and a seg fault will occur. The encoding type is set for String properties. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/address-refactor2@1348682 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/messaging/cpp/CppReceiver.java | 2 +- .../java/org/apache/qpid/messaging/cpp/CppTest.java | 10 +++++++--- .../java/org/apache/qpid/messaging/cpp/TextMessage.java | 17 ++++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) (limited to 'qpid/java/client-api/src') diff --git a/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/CppReceiver.java b/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/CppReceiver.java index 102820850f..8c95b1468e 100644 --- a/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/CppReceiver.java +++ b/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/CppReceiver.java @@ -42,7 +42,7 @@ public class CppReceiver implements Receiver public Message fetch(long timeout) { org.apache.qpid.messaging.cpp.jni.Message m = _cppReceiver.fetch(); - return new TextMessage(m.getContent()); + return new TextMessage(m); } @Override diff --git a/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/CppTest.java b/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/CppTest.java index 5214a66caf..9e28f7bcc5 100644 --- a/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/CppTest.java +++ b/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/CppTest.java @@ -51,12 +51,16 @@ public class CppTest System.out.println("Received message " + m + " with content type : " + m.getContentType() + " and content : " + m.getContent()); Map props = m.getProperties(); - if (props != null) + System.out.println("Props size : " + props.size()); + System.out.println("Props empty : " + props.isEmpty()); + System.out.println("Contains key 'color' : " + props.containsKey("color")); + for (String key : props.keySet()) { - //System.out.println("Color : " + m.getProperties().get("color")); - System.out.println("Price : " + props.get("price")); + System.out.println("Key=" + key + ", value=" + props.get(key)); } + System.out.println("Unspecified property : " + props.get("Unspecified-Prop")); + ssn.close(); con.close(); } diff --git a/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/TextMessage.java b/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/TextMessage.java index 0ee90e3339..1602a486b3 100644 --- a/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/TextMessage.java +++ b/qpid/java/client-api/src/main/java/org/apache/qpid/messaging/cpp/TextMessage.java @@ -23,18 +23,22 @@ public class TextMessage implements org.apache.qpid.messaging.Message { org.apache.qpid.messaging.cpp.jni.Message _cppMessage; - + public TextMessage(String text) { _cppMessage = new org.apache.qpid.messaging.cpp.jni.Message(text); _cppMessage.setContentType("text/plain"); } - + + public TextMessage(org.apache.qpid.messaging.cpp.jni.Message msg) + { + _cppMessage = msg; + } + @Override public Object getContent() { - // TODO Auto-generated method stub - return null; + return _cppMessage.getContent(); } @Override @@ -67,8 +71,7 @@ public class TextMessage implements org.apache.qpid.messaging.Message @Override public String getContentType() { - // TODO Auto-generated method stub - return null; + return _cppMessage.getContentType(); } @Override @@ -200,7 +203,7 @@ public class TextMessage implements org.apache.qpid.messaging.Message { _cppMessage.setProperty(key, value); } - + protected org.apache.qpid.messaging.cpp.jni.Message getCppMessage() { return _cppMessage; -- cgit v1.2.1