You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ra...@apache.org on 2013/07/19 20:44:24 UTC
svn commit: r1504961 [8/11] - in /activemq/activemq-blaze/trunk: ./
src/main/java/org/apache/activeblaze/
src/main/java/org/apache/activeblaze/cluster/
src/main/java/org/apache/activeblaze/group/
src/main/java/org/apache/activeblaze/impl/destination/ s...
Copied: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMapMessage.java (from r752825, activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsMapMessage.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMapMessage.java?p2=activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMapMessage.java&p1=activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsMapMessage.java&r1=752825&r2=1504961&rev=1504961&view=diff
==============================================================================
--- activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsMapMessage.java (original)
+++ activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMapMessage.java Fri Jul 19 18:44:21 2013
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.activeblaze.jms.message;
+package org.apache.activeblaze.wire;
import java.io.IOException;
import java.util.Collections;
@@ -26,14 +26,9 @@ import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.MessageFormatException;
import javax.jms.MessageNotWriteableException;
-
import org.apache.activeblaze.BlazeException;
import org.apache.activeblaze.BlazeRuntimeException;
-import org.apache.activeblaze.wire.BlazeData.BlazeDataBean;
-import org.apache.activeblaze.wire.MapData.MapDataBean;
-import org.apache.activeblaze.wire.MapData.MapDataBuffer;
-import org.apache.activemq.protobuf.Buffer;
-import org.apache.activemq.protobuf.InvalidProtocolBufferException;
+
/**
* A <CODE>MapMessage</CODE> object is used to send a set of name-value pairs. The names are <CODE>String</CODE>
@@ -41,38 +36,37 @@ import org.apache.activemq.protobuf.Inva
* is not null, and not an empty string. The entries can be accessed sequentially or randomly by name. The order of the
* entries is undefined. <CODE>MapMessage</CODE> inherits from the <CODE>Message</CODE> interface and adds a message
* body that contains a Map.
- * <P>
+ * <p/>
* The primitive types can be read or written explicitly using methods for each type. They may also be read or written
* generically as objects. For instance, a call to <CODE>MapMessage.setInt("foo", 6)</CODE> is equivalent to
* <CODE> MapMessage.setObject("foo", new Integer(6))</CODE>. Both forms are provided, because the explicit form is
* convenient for static programming, and the object form is needed when types are not known at compile time.
- * <P>
+ * <p/>
* When a client receives a <CODE>MapMessage</CODE>, it is in read-only mode. If a client attempts to write to the
* message at this point, a <CODE>MessageNotWriteableException</CODE> is thrown. If <CODE>clearBody</CODE> is
* called, the message can now be both read from and written to.
- * <P>
+ * <p/>
* <CODE>MapMessage</CODE> objects support the following conversion table. The marked cases must be supported. The
* unmarked cases must throw a <CODE>JMSException</CODE>. The <CODE>String</CODE> -to-primitive conversions may
* throw a runtime exception if the primitive's <CODE>valueOf()</CODE> method does not accept it as a valid
* <CODE> String</CODE> representation of the primitive.
- * <P>
+ * <p/>
* A value written as the row type can be read as the column type. <p/>
- *
+ * <p/>
* <PRE>
* | | boolean byte short char int long float double String byte[] |----------------------------------------------------------------------
* |boolean | X X |byte | X X X X X |short | X X X X |char | X X |int | X X X |long | X X |float | X X X |double | X X
* |String | X X X X X X X X |byte[] | X |----------------------------------------------------------------------
* <p/>
* </PRE>
- *
* <p/>
- * <P>
+ * <p/>
+ * <p/>
* Attempting to read a null value as a primitive type must be treated as calling the primitive's corresponding
* <code>valueOf(String)</code> conversion method with a null value. Since <code>char</code> does not support a
* <code>String</code> conversion, attempting to read a null value as a <code>char</code> must throw a
* <code>NullPointerException</code>.
- *
- *
+ *
* @see javax.jms.Session#createMapMessage()
* @see javax.jms.BytesMessage
* @see javax.jms.Message
@@ -83,11 +77,15 @@ import org.apache.activemq.protobuf.Inva
public class BlazeJmsMapMessage extends BlazeJmsMessage implements MapMessage {
protected transient Map<String, Object> map = new HashMap<String, Object>();
+ public int getPacketType() {
+ return PacketType.JMS_MAP.getNumber();
+ }
+
public BlazeJmsMapMessage clone() {
BlazeJmsMapMessage copy = new BlazeJmsMapMessage();
try {
copy(copy);
- } catch (BlazeException e) {
+ } catch (Exception e) {
throw new BlazeRuntimeException(e);
}
return copy;
@@ -97,54 +95,46 @@ public class BlazeJmsMapMessage extends
* @param copy
* @throws BlazeException
*/
- protected void copy(BlazeJmsMapMessage copy) throws BlazeException {
+ protected void copy(BlazeJmsMapMessage copy) throws IOException {
storeContent();
super.copy(copy);
}
-
- /**
+
+ /**
* @return the type
* @see org.apache.activeblaze.BlazeMessage#getType()
*/
- public int getType(){
+ public int getType() {
return JmsMessageType.MAP.ordinal();
}
- public void storeContent() {
+ public void storeContent() throws IOException {
super.storeContent();
- if (getContent() != null && !this.map.isEmpty()) {
- MapDataBean mapData = new MapDataBean();
- for (Map.Entry<String, Object> entry : this.map.entrySet()) {
- marshallMap(mapData, entry.getKey().toString(), entry.getValue());
- }
- Buffer payload = mapData.freeze().toUnframedBuffer();
- ((BlazeDataBean)getContent()).setPayload(payload);
- }
+ BufferOutputStream out = new BufferOutputStream(this.map.size() * 16);
+ MarshallingSupport.marshalPrimitiveMap(this.map, out);
+ out.flush();
+ this.payload = out.toBuffer();
+
}
/**
* Builds the message body from data
- *
- * @throws IOException
*/
- protected void loadContent() {
- if (getContent() != null && this.map.isEmpty()) {
- try {
- MapDataBuffer mapData = MapDataBuffer.parseUnframed(getContent().getPayload());
- this.map = unmarshall(mapData);
- } catch (InvalidProtocolBufferException e) {
- throw new BlazeRuntimeException(e);
+ protected void loadContent() throws IOException {
+ if (this.map.isEmpty()) {
+
+ if (this.payload != null && this.map.isEmpty()) {
+ BufferInputStream in = new BufferInputStream(this.payload);
+ this.map = MarshallingSupport.unmarshalPrimitiveMap(in);
}
}
}
/**
* Clears out the message body. Clearing a message's body does not clear its header values or property entries.
- * <P>
+ * <p/>
* If this message body was read-only, calling this method leaves the message body in the same state as an empty
* body in a newly created message.
- *
- * @throws JMSException
*/
public void clearBody() throws JMSException {
super.clearBody();
@@ -153,14 +143,11 @@ public class BlazeJmsMapMessage extends
/**
* Returns the <CODE>boolean</CODE> value with the specified name.
- *
- * @param name
- * the name of the <CODE>boolean</CODE>
+ *
+ * @param name the name of the <CODE>boolean</CODE>
* @return the <CODE>boolean</CODE> value with the specified name
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public boolean getBoolean(String name) throws JMSException {
initializeReading();
@@ -179,14 +166,11 @@ public class BlazeJmsMapMessage extends
/**
* Returns the <CODE>byte</CODE> value with the specified name.
- *
- * @param name
- * the name of the <CODE>byte</CODE>
+ *
+ * @param name the name of the <CODE>byte</CODE>
* @return the <CODE>byte</CODE> value with the specified name
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public byte getByte(String name) throws JMSException {
initializeReading();
@@ -205,14 +189,11 @@ public class BlazeJmsMapMessage extends
/**
* Returns the <CODE>short</CODE> value with the specified name.
- *
- * @param name
- * the name of the <CODE>short</CODE>
+ *
+ * @param name the name of the <CODE>short</CODE>
* @return the <CODE>short</CODE> value with the specified name
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public short getShort(String name) throws JMSException {
initializeReading();
@@ -234,14 +215,11 @@ public class BlazeJmsMapMessage extends
/**
* Returns the Unicode character value with the specified name.
- *
- * @param name
- * the name of the Unicode character
+ *
+ * @param name the name of the Unicode character
* @return the Unicode character value with the specified name
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public char getChar(String name) throws JMSException {
initializeReading();
@@ -257,14 +235,11 @@ public class BlazeJmsMapMessage extends
/**
* Returns the <CODE>int</CODE> value with the specified name.
- *
- * @param name
- * the name of the <CODE>int</CODE>
+ *
+ * @param name the name of the <CODE>int</CODE>
* @return the <CODE>int</CODE> value with the specified name
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public int getInt(String name) throws JMSException {
initializeReading();
@@ -289,14 +264,11 @@ public class BlazeJmsMapMessage extends
/**
* Returns the <CODE>long</CODE> value with the specified name.
- *
- * @param name
- * the name of the <CODE>long</CODE>
+ *
+ * @param name the name of the <CODE>long</CODE>
* @return the <CODE>long</CODE> value with the specified name
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public long getLong(String name) throws JMSException {
initializeReading();
@@ -324,14 +296,11 @@ public class BlazeJmsMapMessage extends
/**
* Returns the <CODE>float</CODE> value with the specified name.
- *
- * @param name
- * the name of the <CODE>float</CODE>
+ *
+ * @param name the name of the <CODE>float</CODE>
* @return the <CODE>float</CODE> value with the specified name
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public float getFloat(String name) throws JMSException {
initializeReading();
@@ -350,14 +319,11 @@ public class BlazeJmsMapMessage extends
/**
* Returns the <CODE>double</CODE> value with the specified name.
- *
- * @param name
- * the name of the <CODE>double</CODE>
+ *
+ * @param name the name of the <CODE>double</CODE>
* @return the <CODE>double</CODE> value with the specified name
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public double getDouble(String name) throws JMSException {
initializeReading();
@@ -379,15 +345,12 @@ public class BlazeJmsMapMessage extends
/**
* Returns the <CODE>String</CODE> value with the specified name.
- *
- * @param name
- * the name of the <CODE>String</CODE>
+ *
+ * @param name the name of the <CODE>String</CODE>
* @return the <CODE>String</CODE> value with the specified name; if there is no item by this name, a null value
* is returned
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public String getString(String name) throws JMSException {
initializeReading();
@@ -403,15 +366,12 @@ public class BlazeJmsMapMessage extends
/**
* Returns the byte array value with the specified name.
- *
- * @param name
- * the name of the byte array
+ *
+ * @param name the name of the byte array
* @return a copy of the byte array value with the specified name; if there is no item by this name, a null value is
* returned.
- * @throws JMSException
- * if the JMS provider fails to read the message due to some internal error.
- * @throws MessageFormatException
- * if this type conversion is invalid.
+ * @throws JMSException if the JMS provider fails to read the message due to some internal error.
+ * @throws MessageFormatException if this type conversion is invalid.
*/
public byte[] getBytes(String name) throws JMSException {
initializeReading();
@@ -424,15 +384,14 @@ public class BlazeJmsMapMessage extends
/**
* Returns the value of the object with the specified name.
- * <P>
+ * <p/>
* This method can be used to return, in objectified format, an object in the Java programming language ("Java
* object") that had been stored in the Map with the equivalent <CODE>setObject</CODE> method call, or its
* equivalent primitive <CODE>set <I>type </I></CODE> method.
- * <P>
+ * <p/>
* Note that byte values are returned as <CODE>byte[]</CODE>, not <CODE>Byte[]</CODE>.
- *
- * @param name
- * the name of the Java object
+ *
+ * @param name the name of the Java object
* @return a copy of the Java object value with the specified name, in objectified format (for example, if the
* object was set as an <CODE>int</CODE>, an <CODE>Integer</CODE> is returned); if there is no item by
* this name, a null value is returned
@@ -444,7 +403,7 @@ public class BlazeJmsMapMessage extends
/**
* Returns an <CODE>Enumeration</CODE> of all the names in the <CODE>MapMessage</CODE> object.
- *
+ *
* @return an enumeration of all the names in this <CODE>MapMessage</CODE>
*/
public Enumeration<String> getMapNames() {
@@ -464,13 +423,9 @@ public class BlazeJmsMapMessage extends
/**
* Sets a <CODE>boolean</CODE> value with the specified name into the Map.
- *
- * @param name
- * the name of the <CODE>boolean</CODE>
- * @param value
- * the <CODE>boolean</CODE> value to set in the Map
- *
- *
+ *
+ * @param name the name of the <CODE>boolean</CODE>
+ * @param value the <CODE>boolean</CODE> value to set in the Map
*/
public void setBoolean(String name, boolean value) {
initializeWriting();
@@ -479,12 +434,9 @@ public class BlazeJmsMapMessage extends
/**
* Sets a <CODE>byte</CODE> value with the specified name into the Map.
- *
- * @param name
- * the name of the <CODE>byte</CODE>
- * @param value
- * the <CODE>byte</CODE> value to set in the Map
- *
+ *
+ * @param name the name of the <CODE>byte</CODE>
+ * @param value the <CODE>byte</CODE> value to set in the Map
*/
public void setByte(String name, byte value) {
initializeWriting();
@@ -493,14 +445,10 @@ public class BlazeJmsMapMessage extends
/**
* Sets a <CODE>short</CODE> value with the specified name into the Map.
- *
- * @param name
- * the name of the <CODE>short</CODE>
- * @param value
- * the <CODE>short</CODE> value to set in the Map
- * @throws IllegalArgumentException
- * if the name is null or if the name is an empty string.
- *
+ *
+ * @param name the name of the <CODE>short</CODE>
+ * @param value the <CODE>short</CODE> value to set in the Map
+ * @throws IllegalArgumentException if the name is null or if the name is an empty string.
*/
public void setShort(String name, short value) {
initializeWriting();
@@ -509,14 +457,10 @@ public class BlazeJmsMapMessage extends
/**
* Sets a Unicode character value with the specified name into the Map.
- *
- * @param name
- * the name of the Unicode character
- * @param value
- * the Unicode character value to set in the Map
- * @throws IllegalArgumentException
- * if the name is null or if the name is an empty string.
- *
+ *
+ * @param name the name of the Unicode character
+ * @param value the Unicode character value to set in the Map
+ * @throws IllegalArgumentException if the name is null or if the name is an empty string.
*/
public void setChar(String name, char value) {
initializeWriting();
@@ -525,14 +469,10 @@ public class BlazeJmsMapMessage extends
/**
* Sets an <CODE>int</CODE> value with the specified name into the Map.
- *
- * @param name
- * the name of the <CODE>int</CODE>
- * @param value
- * the <CODE>int</CODE> value to set in the Map
- * @throws IllegalArgumentException
- * if the name is null or if the name is an empty string.
- *
+ *
+ * @param name the name of the <CODE>int</CODE>
+ * @param value the <CODE>int</CODE> value to set in the Map
+ * @throws IllegalArgumentException if the name is null or if the name is an empty string.
*/
public void setInt(String name, int value) {
initializeWriting();
@@ -541,12 +481,9 @@ public class BlazeJmsMapMessage extends
/**
* Sets a <CODE>long</CODE> value with the specified name into the Map.
- *
- * @param name
- * the name of the <CODE>long</CODE>
- * @param value
- * the <CODE>long</CODE> value to set in the Map
- *
+ *
+ * @param name the name of the <CODE>long</CODE>
+ * @param value the <CODE>long</CODE> value to set in the Map
*/
public void setLong(String name, long value) {
initializeWriting();
@@ -555,13 +492,11 @@ public class BlazeJmsMapMessage extends
/**
* Sets a <CODE>float</CODE> value with the specified name into the Map.
- *
- * @param name
- * the name of the <CODE>float</CODE>
- * @param value
- * the <CODE>float</CODE> value to set in the Map
- *
- * if the message is in read-only mode.
+ *
+ * @param name the name of the <CODE>float</CODE>
+ * @param value the <CODE>float</CODE> value to set in the Map
+ * <p/>
+ * if the message is in read-only mode.
*/
public void setFloat(String name, float value) {
initializeWriting();
@@ -570,17 +505,12 @@ public class BlazeJmsMapMessage extends
/**
* Sets a <CODE>double</CODE> value with the specified name into the Map.
- *
- * @param name
- * the name of the <CODE>double</CODE>
- * @param value
- * the <CODE>double</CODE> value to set in the Map
- * @throws JMSException
- * if the JMS provider fails to write the message due to some internal error.
- * @throws IllegalArgumentException
- * if the name is null or if the name is an empty string.
- * @throws MessageNotWriteableException
- * if the message is in read-only mode.
+ *
+ * @param name the name of the <CODE>double</CODE>
+ * @param value the <CODE>double</CODE> value to set in the Map
+ * @throws JMSException if the JMS provider fails to write the message due to some internal error.
+ * @throws IllegalArgumentException if the name is null or if the name is an empty string.
+ * @throws MessageNotWriteableException if the message is in read-only mode.
*/
public void setDouble(String name, double value) throws JMSException {
initializeWriting();
@@ -589,17 +519,12 @@ public class BlazeJmsMapMessage extends
/**
* Sets a <CODE>String</CODE> value with the specified name into the Map.
- *
- * @param name
- * the name of the <CODE>String</CODE>
- * @param value
- * the <CODE>String</CODE> value to set in the Map
- * @throws JMSException
- * if the JMS provider fails to write the message due to some internal error.
- * @throws IllegalArgumentException
- * if the name is null or if the name is an empty string.
- * @throws MessageNotWriteableException
- * if the message is in read-only mode.
+ *
+ * @param name the name of the <CODE>String</CODE>
+ * @param value the <CODE>String</CODE> value to set in the Map
+ * @throws JMSException if the JMS provider fails to write the message due to some internal error.
+ * @throws IllegalArgumentException if the name is null or if the name is an empty string.
+ * @throws MessageNotWriteableException if the message is in read-only mode.
*/
public void setString(String name, String value) throws JMSException {
initializeWriting();
@@ -608,18 +533,13 @@ public class BlazeJmsMapMessage extends
/**
* Sets a byte array value with the specified name into the Map.
- *
- * @param name
- * the name of the byte array
- * @param value
- * the byte array value to set in the Map; the array is copied so that the value for <CODE>name </CODE>
- * will not be altered by future modifications
- * @throws JMSException
- * if the JMS provider fails to write the message due to some internal error.
- * @throws NullPointerException
- * if the name is null, or if the name is an empty string.
- * @throws MessageNotWriteableException
- * if the message is in read-only mode.
+ *
+ * @param name the name of the byte array
+ * @param value the byte array value to set in the Map; the array is copied so that the value for <CODE>name </CODE>
+ * will not be altered by future modifications
+ * @throws JMSException if the JMS provider fails to write the message due to some internal error.
+ * @throws NullPointerException if the name is null, or if the name is an empty string.
+ * @throws MessageNotWriteableException if the message is in read-only mode.
*/
public void setBytes(String name, byte[] value) throws JMSException {
initializeWriting();
@@ -632,21 +552,14 @@ public class BlazeJmsMapMessage extends
/**
* Sets a portion of the byte array value with the specified name into the Map.
- *
- * @param name
- * the name of the byte array
- * @param value
- * the byte array value to set in the Map
- * @param offset
- * the initial offset within the byte array
- * @param length
- * the number of bytes to use
- * @throws JMSException
- * if the JMS provider fails to write the message due to some internal error.
- * @throws IllegalArgumentException
- * if the name is null or if the name is an empty string.
- * @throws MessageNotWriteableException
- * if the message is in read-only mode.
+ *
+ * @param name the name of the byte array
+ * @param value the byte array value to set in the Map
+ * @param offset the initial offset within the byte array
+ * @param length the number of bytes to use
+ * @throws JMSException if the JMS provider fails to write the message due to some internal error.
+ * @throws IllegalArgumentException if the name is null or if the name is an empty string.
+ * @throws MessageNotWriteableException if the message is in read-only mode.
*/
public void setBytes(String name, byte[] value, int offset, int length) throws JMSException {
initializeWriting();
@@ -657,22 +570,16 @@ public class BlazeJmsMapMessage extends
/**
* Sets an object value with the specified name into the Map.
- * <P>
+ * <p/>
* This method works only for the objectified primitive object types (<code>Integer</code>,<code>Double</code>,
* <code>Long</code> ...), <code>String</code> objects, and byte arrays.
- *
- * @param name
- * the name of the Java object
- * @param value
- * the Java object value to set in the Map
- * @throws JMSException
- * if the JMS provider fails to write the message due to some internal error.
- * @throws IllegalArgumentException
- * if the name is null or if the name is an empty string.
- * @throws MessageFormatException
- * if the object is invalid.
- * @throws MessageNotWriteableException
- * if the message is in read-only mode.
+ *
+ * @param name the name of the Java object
+ * @param value the Java object value to set in the Map
+ * @throws JMSException if the JMS provider fails to write the message due to some internal error.
+ * @throws IllegalArgumentException if the name is null or if the name is an empty string.
+ * @throws MessageFormatException if the object is invalid.
+ * @throws MessageNotWriteableException if the message is in read-only mode.
*/
public void setObject(String name, Object value) throws JMSException {
initializeWriting();
@@ -689,9 +596,8 @@ public class BlazeJmsMapMessage extends
/**
* Indicates whether an item exists in this <CODE>MapMessage</CODE> object.
- *
- * @param name
- * the name of the item to test
+ *
+ * @param name the name of the item to test
* @return true if the item exists
*/
public boolean itemExists(String name) {
Propchange: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMapMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMapMessage.java
------------------------------------------------------------------------------
svn:executable = *
Copied: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessage.java (from r752825, activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsMessage.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessage.java?p2=activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessage.java&p1=activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsMessage.java&r1=752825&r2=1504961&rev=1504961&view=diff
==============================================================================
--- activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsMessage.java (original)
+++ activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessage.java Fri Jul 19 18:44:21 2013
@@ -14,8 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.activeblaze.jms.message;
+package org.apache.activeblaze.wire;
+import java.io.IOException;
import java.util.Enumeration;
import javax.jms.DeliveryMode;
@@ -23,27 +24,38 @@ import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageFormatException;
-
-import org.apache.activeblaze.BlazeException;
import org.apache.activeblaze.BlazeMessage;
import org.apache.activeblaze.BlazeMessageFormatException;
import org.apache.activeblaze.BlazeRuntimeException;
import org.apache.activeblaze.jms.BlazeJmsDestination;
import org.apache.activeblaze.util.Callback;
-import org.apache.activeblaze.wire.BlazeData.BlazeDataBean;
/**
* Implementation of a Jms Message
- *
*/
public class BlazeJmsMessage extends BlazeMessage implements Message {
-
- protected enum JmsMessageType{MESSAGE,BYTES,MAP,OBJECT,STREAM,TEXT}
+
+ protected enum JmsMessageType {MESSAGE, BYTES, MAP, OBJECT, STREAM, TEXT}
+
protected transient Callback<BlazeJmsMessage> acknowledgeCallback;
protected transient BlazeJmsDestination jmsDestination;
protected transient BlazeJmsDestination jmsReplyToDestination;
+ protected Buffer payload;
+
+ public BlazeJmsMessage() {
+ setNoLocal(true);
+ }
+
+ /**
+ * Get the packetType
+ *
+ * @return the packetType
+ */
+ public int getPacketType() {
+ return PacketType.JMS_MESSAGE.getNumber();
+ }
- /**
+ /**
* @return clone of a BlazeMessage
* @see org.apache.activeblaze.BlazeMessage#clone()
*/
@@ -51,24 +63,24 @@ public class BlazeJmsMessage extends Bla
BlazeJmsMessage copy = new BlazeJmsMessage();
try {
copy(copy);
- } catch (BlazeException e) {
+ } catch (Exception e) {
throw new BlazeRuntimeException(e);
}
return copy;
}
- protected void copy(BlazeJmsMessage copy) throws BlazeException {
+ protected void copy(BlazeJmsMessage copy) throws IOException {
super.copy(copy);
copy.acknowledgeCallback = this.acknowledgeCallback;
copy.jmsDestination = this.jmsDestination;
copy.jmsReplyToDestination = this.jmsReplyToDestination;
}
-
- /**
+
+ /**
* @return the type
* @see org.apache.activeblaze.BlazeMessage#getType()
*/
- public int getType(){
+ public int getType() {
return JmsMessageType.MESSAGE.ordinal();
}
@@ -97,30 +109,21 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @throws JMSException
* @see javax.jms.Message#clearBody()
*/
public void clearBody() throws JMSException {
- BlazeDataBean data = (BlazeDataBean) getContent();
- if (data != null) {
- data.clearPayload();
- }
+ this.payload = null;
}
/**
* @see javax.jms.Message#clearProperties()
*/
public void clearProperties() {
- BlazeDataBean data = (BlazeDataBean) getContent();
- if (data != null) {
- data.clearMapData();
- }
+ super.clear();
}
/**
- * @param name
* @return boolean value
- * @throws JMSException
* @see javax.jms.Message#getBooleanProperty(java.lang.String)
*/
public boolean getBooleanProperty(String name) throws JMSException {
@@ -132,9 +135,7 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
* @return byte value
- * @throws JMSException
* @see javax.jms.Message#getByteProperty(java.lang.String)
*/
public byte getByteProperty(String name) throws JMSException {
@@ -146,9 +147,7 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
* @return double value
- * @throws JMSException
* @see javax.jms.Message#getDoubleProperty(java.lang.String)
*/
public double getDoubleProperty(String name) throws JMSException {
@@ -160,9 +159,7 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
* @return float value
- * @throws JMSException
* @see javax.jms.Message#getFloatProperty(java.lang.String)
*/
public float getFloatProperty(String name) throws JMSException {
@@ -174,9 +171,7 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
* @return int value
- * @throws JMSException
* @see javax.jms.Message#getIntProperty(java.lang.String)
*/
public int getIntProperty(String name) throws JMSException {
@@ -239,8 +234,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @return
- * @throws JMSException
* @see javax.jms.Message#getJMSPriority()
*/
public int getJMSPriority() throws JMSException {
@@ -248,8 +241,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @return
- * @throws JMSException
* @see javax.jms.Message#getJMSRedelivered()
*/
public boolean getJMSRedelivered() throws JMSException {
@@ -257,8 +248,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @return
- * @throws JMSException
* @see javax.jms.Message#getJMSReplyTo()
*/
public Destination getJMSReplyTo() throws JMSException {
@@ -278,7 +267,6 @@ public class BlazeJmsMessage extends Bla
/**
* @return the message type
- * @throws JMSException
* @see javax.jms.Message#getJMSType()
*/
public String getJMSType() throws JMSException {
@@ -286,9 +274,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @return
- * @throws JMSException
* @see javax.jms.Message#getLongProperty(java.lang.String)
*/
public long getLongProperty(String name) throws JMSException {
@@ -300,9 +285,7 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
* @return the associated object
- *
* @see javax.jms.Message#getObjectProperty(java.lang.String)
*/
public Object getObjectProperty(String name) {
@@ -318,9 +301,7 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
* @return short property
- * @throws JMSException
* @see javax.jms.Message#getShortProperty(java.lang.String)
*/
public short getShortProperty(String name) throws JMSException {
@@ -332,9 +313,7 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
* @return String property
- * @throws JMSException
* @see javax.jms.Message#getStringProperty(java.lang.String)
*/
public String getStringProperty(String name) throws JMSException {
@@ -346,7 +325,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
* @return true if the property exists
* @see javax.jms.Message#propertyExists(java.lang.String)
*/
@@ -355,8 +333,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @param value
* @see javax.jms.Message#setBooleanProperty(java.lang.String, boolean)
*/
public void setBooleanProperty(String name, boolean value) {
@@ -364,8 +340,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @param value
* @see javax.jms.Message#setByteProperty(java.lang.String, byte)
*/
public void setByteProperty(String name, byte value) {
@@ -373,8 +347,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @param value
* @see javax.jms.Message#setDoubleProperty(java.lang.String, double)
*/
public void setDoubleProperty(String name, double value) {
@@ -382,8 +354,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @param value
* @see javax.jms.Message#setFloatProperty(java.lang.String, float)
*/
public void setFloatProperty(String name, float value) {
@@ -391,8 +361,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @param value
* @see javax.jms.Message#setIntProperty(java.lang.String, int)
*/
public void setIntProperty(String name, int value) {
@@ -400,7 +368,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param correlationID
* @see javax.jms.Message#setJMSCorrelationID(java.lang.String)
*/
public void setJMSCorrelationID(String correlationID) {
@@ -408,7 +375,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param correlationID
* @see javax.jms.Message#setJMSCorrelationIDAsBytes(byte[])
*/
public void setJMSCorrelationIDAsBytes(byte[] correlationID) {
@@ -416,7 +382,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param deliveryMode
* @see javax.jms.Message#setJMSDeliveryMode(int)
*/
public void setJMSDeliveryMode(int deliveryMode) {
@@ -425,8 +390,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param destination
- * @throws JMSException
* @see javax.jms.Message#setJMSDestination(javax.jms.Destination)
*/
public void setJMSDestination(javax.jms.Destination destination) throws JMSException {
@@ -434,7 +397,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param expiration
* @see javax.jms.Message#setJMSExpiration(long)
*/
public void setJMSExpiration(long expiration) {
@@ -442,15 +404,13 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param id
* @see javax.jms.Message#setJMSMessageID(java.lang.String)
*/
public void setJMSMessageID(String id) {
- setMessageId(id);
+ setId(id);
}
/**
- * @param priority
* @see javax.jms.Message#setJMSPriority(int)
*/
public void setJMSPriority(int priority) {
@@ -458,15 +418,12 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param redelivered
* @see javax.jms.Message#setJMSRedelivered(boolean)
*/
public void setJMSRedelivered(boolean redelivered) {
}
/**
- * @param replyTo
- * @throws JMSException
* @see javax.jms.Message#setJMSReplyTo(javax.jms.Destination)
*/
public void setJMSReplyTo(Destination replyTo) throws JMSException {
@@ -474,7 +431,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param timestamp
* @see javax.jms.Message#setJMSTimestamp(long)
*/
public void setJMSTimestamp(long timestamp) {
@@ -482,7 +438,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param type
* @see javax.jms.Message#setJMSType(java.lang.String)
*/
public void setJMSType(String type) {
@@ -490,8 +445,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @param value
* @see javax.jms.Message#setLongProperty(java.lang.String, long)
*/
public void setLongProperty(String name, long value) {
@@ -499,8 +452,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @param value
* @see javax.jms.Message#setObjectProperty(java.lang.String, java.lang.Object)
*/
public void setObjectProperty(String name, Object value) {
@@ -508,8 +459,6 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @param value
* @see javax.jms.Message#setShortProperty(java.lang.String, short)
*/
public void setShortProperty(String name, short value) {
@@ -517,15 +466,13 @@ public class BlazeJmsMessage extends Bla
}
/**
- * @param name
- * @param value
* @see javax.jms.Message#setStringProperty(java.lang.String, java.lang.String)
*/
public void setStringProperty(String name, String value) {
setStringValue(name, value);
}
- public void storeContent() {
+ protected void storeContent() throws IOException {
if (this.jmsDestination != null) {
super.setDestination(this.jmsDestination.getDestination());
}
@@ -534,6 +481,22 @@ public class BlazeJmsMessage extends Bla
}
super.storeContent();
}
-
-
+
+ public void read(BufferInputStream in) throws IOException {
+ super.read(in);
+ this.payload = in.readBuffer();
+ }
+
+ /**
+ * Write state to a Buffer
+ */
+ public void write(BufferOutputStream out) throws IOException {
+ super.write(out);
+ out.write(this.payload);
+ }
+
+ public String toString() {
+ return "[" + getMessageType() + "]" + getMessageId();
+ }
+
}
Propchange: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Copied: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessageTransformation.java (from r753178, activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsMessageTransformation.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessageTransformation.java?p2=activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessageTransformation.java&p1=activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsMessageTransformation.java&r1=753178&r2=1504961&rev=1504961&view=diff
==============================================================================
--- activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsMessageTransformation.java (original)
+++ activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessageTransformation.java Fri Jul 19 18:44:21 2013
@@ -14,9 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.activeblaze.jms.message;
+package org.apache.activeblaze.wire;
import java.util.Enumeration;
+
import javax.jms.BytesMessage;
import javax.jms.Destination;
import javax.jms.JMSException;
@@ -28,10 +29,11 @@ import javax.jms.StreamMessage;
import javax.jms.TextMessage;
import org.apache.activeblaze.BlazeMessage;
import org.apache.activeblaze.jms.BlazeJmsDestination;
+
/**
* A helper class for converting normal JMS interfaces into ActiveMQ specific
* ones.
- *
+ *
* @version $Revision: 1.1 $
*/
public final class BlazeJmsMessageTransformation {
@@ -39,18 +41,14 @@ public final class BlazeJmsMessageTransf
}
/**
- * @param dest
* @return a BlazeJmsDestination
- * @throws JMSException
*/
private static BlazeJmsDestination transformDestination(Destination dest) throws JMSException {
return BlazeJmsDestination.transform(dest);
}
/**
- * @param message
* @return a BlazeJmsMessage
- * @throws JMSException
*/
public static BlazeJmsMessage transformMessage(BlazeMessage message) throws JMSException {
BlazeJmsMessage result = null;
@@ -77,9 +75,7 @@ public final class BlazeJmsMessageTransf
}
/**
- * @param message
* @return a BlazeJmsDestination
- * @throws JMSException
*/
public static BlazeJmsMessage transformMessage(Message message) throws JMSException {
if (message instanceof BlazeJmsMessage) {
@@ -91,7 +87,7 @@ public final class BlazeJmsMessageTransf
bytesMsg.reset();
BlazeJmsBytesMessage msg = new BlazeJmsBytesMessage();
try {
- for (;;) {
+ for (; ; ) {
// Reads a byte from the message stream until the stream
// is empty
msg.writeByte(bytesMsg.readByte());
@@ -114,7 +110,14 @@ public final class BlazeJmsMessageTransf
ObjectMessage objMsg = (ObjectMessage) message;
BlazeJmsObjectMessage msg = new BlazeJmsObjectMessage();
msg.setObject(objMsg.getObject());
- msg.storeContent();
+ try {
+ msg.storeContent();
+ } catch (Exception e) {
+ JMSException ex = new JMSException(e.getMessage());
+ ex.initCause(e);
+ ex.setLinkedException(e);
+ throw ex;
+ }
transformedMessage = msg;
} else if (message instanceof StreamMessage) {
StreamMessage streamMessage = (StreamMessage) message;
@@ -145,12 +148,9 @@ public final class BlazeJmsMessageTransf
/**
* Copies the standard JMS and user defined properties from the givem
* message to the specified message
- *
- * @param fromMessage
- * the message to take the properties from
- * @param toMessage
- * the message to add the properties to
- * @throws JMSException
+ *
+ * @param fromMessage the message to take the properties from
+ * @param toMessage the message to add the properties to
*/
public static void copyProperties(Message fromMessage, Message toMessage) throws JMSException {
toMessage.setJMSMessageID(fromMessage.getJMSMessageID());
@@ -172,7 +172,6 @@ public final class BlazeJmsMessageTransf
}
/**
- * @param type
* @return a BlazeJmsMessage
*/
public static BlazeJmsMessage createMessage(int type) {
Propchange: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessageTransformation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsMessageTransformation.java
------------------------------------------------------------------------------
svn:executable = *
Copied: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsObjectMessage.java (from r755483, activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsObjectMessage.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsObjectMessage.java?p2=activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsObjectMessage.java&p1=activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsObjectMessage.java&r1=755483&r2=1504961&rev=1504961&view=diff
==============================================================================
--- activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/jms/message/BlazeJmsObjectMessage.java (original)
+++ activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsObjectMessage.java Fri Jul 19 18:44:21 2013
@@ -14,40 +14,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.activeblaze.jms.message;
+package org.apache.activeblaze.wire;
-import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import javax.jms.JMSException;
import javax.jms.ObjectMessage;
-
import org.apache.activeblaze.BlazeException;
import org.apache.activeblaze.BlazeRuntimeException;
-import org.apache.activeblaze.jms.BlazeJmsExceptionSupport;
-import org.apache.activeblaze.util.BufferOutputStream;
-import org.apache.activeblaze.util.ClassLoadingAwareObjectInputStream;
-import org.apache.activeblaze.wire.BlazeData.BlazeDataBean;
-import org.apache.activemq.protobuf.Buffer;
-import org.apache.activemq.protobuf.BufferInputStream;
-
/**
- * An <CODE>ObjectMessage</CODE> object is used to send a message that contains a serializable object in the Java
- * programming language ("Java object"). It inherits from the <CODE>Message</CODE> interface and adds a body
- * containing a single reference to an object. Only <CODE>Serializable</CODE> Java objects can be used. <p/>
- * <P>
- * If a collection of Java objects must be sent, one of the <CODE>Collection</CODE> classes provided since JDK 1.2 can
- * be used. <p/>
- * <P>
- * When a client receives an <CODE>ObjectMessage</CODE>, it is in read-only mode. If a client attempts to write to
- * the message at this point, a <CODE>MessageNotWriteableException</CODE> is thrown. If <CODE>clearBody</CODE> is
- * called, the message can now be both read from and written to.
- *
+ * An <CODE>ObjectMessage</CODE> object is used to send a message that contains
+ * a serializable object in the Java programming language ("Java object"). It
+ * inherits from the <CODE>Message</CODE> interface and adds a body containing a
+ * single reference to an object. Only <CODE>Serializable</CODE> Java objects
+ * can be used.
+ * <p/>
+ * <p/>
+ * If a collection of Java objects must be sent, one of the
+ * <CODE>Collection</CODE> classes provided since JDK 1.2 can be used.
+ * <p/>
+ * <p/>
+ * When a client receives an <CODE>ObjectMessage</CODE>, it is in read-only
+ * mode. If a client attempts to write to the message at this point, a
+ * <CODE>MessageNotWriteableException</CODE> is thrown. If
+ * <CODE>clearBody</CODE> is called, the message can now be both read from and
+ * written to.
+ *
* @see javax.jms.Session#createObjectMessage()
* @see javax.jms.Session#createObjectMessage(Serializable)
* @see javax.jms.BytesMessage
@@ -60,11 +56,15 @@ public class BlazeJmsObjectMessage exten
static final ClassLoader JMS_OBJECT_CLASS_LOADER = BlazeJmsObjectMessage.class.getClassLoader();
protected transient Serializable object;
+ public int getPacketType() {
+ return PacketType.JMS_OBJECT.getNumber();
+ }
+
public BlazeJmsObjectMessage clone() {
BlazeJmsObjectMessage copy = new BlazeJmsObjectMessage();
try {
copy(copy);
- } catch (BlazeException e) {
+ } catch (Exception e) {
throw new BlazeRuntimeException(e);
}
return copy;
@@ -74,49 +74,45 @@ public class BlazeJmsObjectMessage exten
* @param copy
* @throws BlazeException
*/
- protected void copy(BlazeJmsObjectMessage copy) throws BlazeException {
+ protected void copy(BlazeJmsObjectMessage copy) throws IOException {
storeContent();
super.copy(copy);
copy.object = null;
}
-
- /**
+
+ /**
* @return the type
* @see org.apache.activeblaze.BlazeMessage#getType()
*/
- public int getType(){
+ public int getType() {
return JmsMessageType.OBJECT.ordinal();
}
- public void storeContent() {
+ public void storeContent() throws IOException {
super.storeContent();
- Buffer payload = getContent().getPayload();
- if (payload == null && this.object != null) {
- try {
- BufferOutputStream os = new BufferOutputStream(128);
- DataOutputStream dataOut = new DataOutputStream(os);
- ObjectOutputStream objOut = new ObjectOutputStream(dataOut);
- objOut.writeObject(this.object);
- objOut.flush();
- objOut.reset();
- objOut.close();
- payload = os.toBuffer();
- BlazeDataBean data = (BlazeDataBean) getContent();
- data.setPayload(payload);
- } catch (IOException ioe) {
- throw new RuntimeException(ioe.getMessage(), ioe);
- }
+ if (this.payload == null && this.object != null) {
+ BufferOutputStream os = new BufferOutputStream(128);
+ DataOutputStream dataOut = new DataOutputStream(os);
+ ObjectOutputStream objOut = new ObjectOutputStream(dataOut);
+ objOut.writeObject(this.object);
+ objOut.flush();
+ objOut.reset();
+ objOut.close();
+ this.payload = os.toBuffer();
}
}
/**
- * Clears out the message body. Clearing a message's body does not clear its header values or property entries. <p/>
- * <P>
- * If this message body was read-only, calling this method leaves the message body in the same state as an empty
- * body in a newly created message.
- *
- * @throws JMSException
- * if the JMS provider fails to clear the message body due to some internal error.
+ * Clears out the message body. Clearing a message's body does not clear its
+ * header values or property entries.
+ * <p/>
+ * <p/>
+ * If this message body was read-only, calling this method leaves the
+ * message body in the same state as an empty body in a newly created
+ * message.
+ *
+ * @throws JMSException if the JMS provider fails to clear the message body due to
+ * some internal error.
*/
public void clearBody() throws JMSException {
super.clearBody();
@@ -124,40 +120,39 @@ public class BlazeJmsObjectMessage exten
}
/**
- * Sets the serializable object containing this message's data. It is important to note that an
- * <CODE>ObjectMessage</CODE> contains a snapshot of the object at the time <CODE>setObject()</CODE> is called;
- * subsequent modifications of the object will have no effect on the <CODE>ObjectMessage</CODE> body.
- *
- * @param newObject
- *
+ * Sets the serializable object containing this message's data. It is
+ * important to note that an <CODE>ObjectMessage</CODE> contains a snapshot
+ * of the object at the time <CODE>setObject()</CODE> is called; subsequent
+ * modifications of the object will have no effect on the
+ * <CODE>ObjectMessage</CODE> body.
*/
- public void setObject(Serializable newObject) {
+ public void setObject(Serializable newObject) throws JMSException {
this.object = newObject;
setContent(null);
- storeContent();
+ try {
+ storeContent();
+ } catch (Exception e) {
+ JMSException ex = new JMSException(e.getMessage());
+ ex.initCause(e);
+ ex.setLinkedException(ex);
+ throw ex;
+ }
}
/**
- * Gets the serializable object containing this message's data. The default value is null.
- *
+ * Gets the serializable object containing this message's data. The default
+ * value is null.
+ *
* @return the serializable object containing this message's data
- * @throws JMSException
*/
public Serializable getObject() throws JMSException {
- if (this.object == null && getContent() != null && getContent().getPayload() != null) {
+ if (this.object == null && this.payload != null) {
try {
- Buffer payload = getContent().getPayload();
- InputStream is = new BufferInputStream(payload);
- DataInputStream dataIn = new DataInputStream(is);
- ClassLoadingAwareObjectInputStream objIn = new ClassLoadingAwareObjectInputStream(dataIn);
- try {
- this.object = (Serializable) objIn.readObject();
- } catch (ClassNotFoundException ce) {
- throw new IOException(ce.getMessage());
- }
- dataIn.close();
+ this.object = (Serializable) IOUtils.readObject(new BufferInputStream(this.payload));
} catch (IOException e) {
- throw BlazeJmsExceptionSupport.create("Failed to build body from bytes. Reason: " + e, e);
+ JMSException ex = new JMSException(e.getMessage());
+ ex.initCause(e);
+ ex.setLinkedException(ex);
}
}
return this.object;
Propchange: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsObjectMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/activemq-blaze/trunk/src/main/java/org/apache/activeblaze/wire/BlazeJmsObjectMessage.java
------------------------------------------------------------------------------
svn:executable = *