User: lqd
Date: 01/12/13 07:58:19
Modified: src/main/org/jboss/mq/pm/file Tag: Branch_2_4
MessageLog.java
Log:
Use SpyMessage.writeMessage() and SpyMessage.readMessage() methods to
store / restore files written to disk.
Revision Changes Path
No revision
No revision
1.2.2.2 +10 -52 jbossmq/src/main/org/jboss/mq/pm/file/MessageLog.java
Index: MessageLog.java
===================================================================
RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/pm/file/MessageLog.java,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- MessageLog.java 2001/08/23 03:57:11 1.2.2.1
+++ MessageLog.java 2001/12/13 15:58:18 1.2.2.2
@@ -5,6 +5,7 @@
* See terms of license at gnu.org.
*/
package org.jboss.mq.pm.file;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -16,7 +17,8 @@
import javax.jms.JMSException;
-import org.jboss.mq.*;
+import org.jboss.mq.SpyMessage;
+import org.jboss.mq.SpyJMSException;
/**
* This is used to keep SpyMessages on the disk and is used reconstruct the
@@ -24,7 +26,7 @@
*
* @created August 16, 2001
* @author: Paul Kendall ([EMAIL PROTECTED])
- * @version $Revision: 1.2.2.1 $
+ * @version $Revision: 1.2.2.2 $
*/
public class MessageLog {
@@ -36,13 +38,6 @@
/////////////////////////////////////////////////////////////////////
// Constants
/////////////////////////////////////////////////////////////////////
- protected final static byte OBJECT_MESS = 3;
- protected final static byte BYTES_MESS = 4;
- protected final static byte MAP_MESS = 5;
- protected final static byte TEXT_MESS = 6;
- protected final static byte STREAM_MESS = 7;
- protected final static byte ENCAP_MESS = 8;
- protected final static byte SPY_MESS = 9;
/////////////////////////////////////////////////////////////////////
// Constructor
@@ -180,58 +175,21 @@
}
protected void writeMessageToFile( SpyMessage message, File file )
- throws IOException {
+ throws IOException
+ {
ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream( file )
);
out.writeLong( message.messageId );
- if ( message instanceof SpyEncapsulatedMessage ) {
- out.writeByte( ENCAP_MESS );
- } else if ( message instanceof SpyObjectMessage ) {
- out.writeByte( OBJECT_MESS );
- } else if ( message instanceof SpyBytesMessage ) {
- out.writeByte( BYTES_MESS );
- } else if ( message instanceof SpyMapMessage ) {
- out.writeByte( MAP_MESS );
- } else if ( message instanceof SpyTextMessage ) {
- out.writeByte( TEXT_MESS );
- } else if ( message instanceof SpyStreamMessage ) {
- out.writeByte( STREAM_MESS );
- } else {
- out.writeByte( SPY_MESS );
- }
- message.writeExternal( out );
+ SpyMessage.writeMessage( message, out );
out.flush();
out.close();
}
protected void restoreMessageFromFile( java.util.TreeMap store, File file )
- throws Exception {
+ throws Exception
+ {
ObjectInputStream in = new ObjectInputStream( new FileInputStream( file ) );
long msgId = in.readLong();
- SpyMessage message = null;
- byte type = in.readByte();
- switch ( type ) {
- case OBJECT_MESS:
- message = new SpyObjectMessage();
- break;
- case BYTES_MESS:
- message = new SpyBytesMessage();
- break;
- case MAP_MESS:
- message = new SpyMapMessage();
- break;
- case STREAM_MESS:
- message = new SpyStreamMessage();
- break;
- case TEXT_MESS:
- message = new SpyTextMessage();
- break;
- case ENCAP_MESS:
- message = new SpyEncapsulatedMessage();
- break;
- default:
- message = new SpyMessage();
- }
- message.readExternal( in );
+ SpyMessage message = SpyMessage.readMessage( in );
in.close();
message.messageId = msgId;
message.persistData = file;
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development