geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r576637 - /geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
Date Tue, 18 Sep 2007 00:45:50 GMT
Author: jdillon
Date: Mon Sep 17 17:45:50 2007
New Revision: 576637

URL: http://svn.apache.org/viewvc?rev=576637&view=rev
Log:
Custom UUID marshalling

Modified:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java?rev=576637&r1=576636&r2=576637&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java
Mon Sep 17 17:45:50 2007
@@ -121,14 +121,43 @@
     // MarshalAware
     //
 
+    private void writeUuid(final ByteBuffer buff, final UUID uuid) throws Exception {
+        assert buff != null;
+
+        if (uuid == null) {
+            buff.put((byte)0);
+        }
+        else {
+            buff.put((byte)1);
+
+            buff.putLong(uuid.getMostSignificantBits());
+            buff.putLong(uuid.getLeastSignificantBits());
+        }
+    }
+
+    private UUID readUuid(final ByteBuffer buff) throws Exception {
+        assert buff != null;
+
+        byte isnull = buff.get();
+
+        if (isnull == 1) { // not null
+            long msb = buff.getLong();
+            long lsb = buff.getLong();
+            return new UUID(msb, lsb);
+        }
+        else {
+            return null;
+        }
+    }
+
     public void readExternal(final ByteBuffer buff) throws Exception {
         assert buff != null;
 
         type = buff.getEnum(MessageType.class);
-        
-        id = (UUID) buff.getObject();
 
-        correlationId = (UUID) buff.getObject();
+        id = readUuid(buff);
+
+        correlationId = readUuid(buff);
 
         timestamp = buff.getLong();
     }
@@ -138,9 +167,9 @@
 
         buff.putEnum(type);
 
-        buff.putObject(id);
+        writeUuid(buff, id);
 
-        buff.putObject(correlationId);
+        writeUuid(buff, correlationId);
 
         buff.putLong(timestamp);
     }



Mime
View raw message