User: hiram
Date: 01/02/21 14:49:36
Modified: src/main/org/jbossmq SpyObjectMessage.java
Log:
Bug fix: Could not send ObjectMessages to MDBs.
Fix provided by: Joel ([EMAIL PROTECTED])
Revision Changes Path
1.2 +22 -32 jbossmq/src/main/org/jbossmq/SpyObjectMessage.java
Index: SpyObjectMessage.java
===================================================================
RCS file: /products/cvs/ejboss/jbossmq/src/main/org/jbossmq/SpyObjectMessage.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SpyObjectMessage.java 2001/01/26 00:43:34 1.1
+++ SpyObjectMessage.java 2001/02/21 22:49:35 1.2
@@ -12,18 +12,20 @@
import javax.jms.MessageFormatException;
import java.io.Serializable;
import java.io.IOException;
-import java.io.OptionalDataException;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
+
+
+
+
+
+import java.rmi.MarshalledObject;
+
/**
* This class implements javax.jms.ObjectMessage
*
* @author Norbert Lataille ([EMAIL PROTECTED])
*
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class SpyObjectMessage
extends SpyMessage
@@ -32,7 +34,7 @@
// Attributes ----------------------------------------------------
- private byte[] content=null;
+ private MarshalledObject content = null;
// Public --------------------------------------------------------
@@ -40,37 +42,25 @@
{
if (msgReadOnly) throw new MessageNotWriteableException("setObject");
try {
- ByteArrayOutputStream ostream = new ByteArrayOutputStream();
- ObjectOutputStream p = new ObjectOutputStream(ostream);
-
- p.writeObject(object);
-
- p.flush();
- content=ostream.toByteArray();
- ostream.close();
+ content = new MarshalledObject(object);
} catch (IOException e) {
throw new MessageFormatException("Object cannot be
serialized");
}
}
-
- public Serializable getObject() throws JMSException
- {
- try {
- ByteArrayInputStream istream = new
ByteArrayInputStream(content);
- ObjectInputStream p = new ObjectInputStream(istream);
-
- Serializable object=(Serializable)p.readObject();
- istream.close();
+ public Serializable getObject() throws JMSException {
- return object;
- } catch (OptionalDataException e) {
- throw new MessageFormatException("OptionalDataException");
- } catch (ClassNotFoundException e) {
- throw new MessageFormatException("ClassNotFoundException");
- } catch (IOException e) {
- throw new MessageFormatException("IOException");
- }
+ Serializable retVal = null;
+ try {
+ if (null != content) {
+ retVal = (Serializable) content.get();
+ }
+ } catch (ClassNotFoundException e) {
+ throw new MessageFormatException("ClassNotFoundException");
+ } catch (IOException e) {
+ throw new MessageFormatException("IOException");
+ }
+ return retVal;
}
public void clearBody() throws JMSException