geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r578445 - in /geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message: LongMessageID.java Message.java MessageHandler.java MessageSupport.java UuidMessageID.java
Date Sat, 22 Sep 2007 14:22:57 GMT
Author: jdillon
Date: Sat Sep 22 07:22:56 2007
New Revision: 578445

URL: http://svn.apache.org/viewvc?rev=578445&view=rev
Log:
Moved the ID support bits out of MessageSupport, change the default ID to UUID for some testing

Added:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LongMessageID.java
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java
  (with props)
Modified:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageHandler.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageSupport.java

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LongMessageID.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/LongMessageID.java?rev=578445&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LongMessageID.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LongMessageID.java
Sat Sep 22 07:22:56 2007
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.remote.message;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * Provides {@link Message.ID} instances based on long integers.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LongMessageID
+    implements Message.ID
+{
+    private Long value;
+
+    public LongMessageID(final long value) {
+        this.value = value;
+    }
+
+    public int hashCode() {
+        return value.hashCode();
+    }
+
+    public boolean equals(final Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        else if (obj == null) {
+            return false;
+        }
+        else if (!(obj instanceof LongMessageID)) {
+            return false;
+        }
+
+        return value.equals(((LongMessageID)obj).value);
+    }
+
+    public String toString() {
+        return String.valueOf(value);
+    }
+
+    public void writeExternal(final ByteBuffer out) throws Exception {
+        out.putLong(value);
+    }
+
+    public void readExternal(final ByteBuffer in) throws Exception {
+        value = in.getLong();
+    }
+
+    /**
+     * Factory to create {@link LongMessageID} instances.
+     */
+    public static class Generator
+        implements Message.IDGenerator
+    {
+        private static final AtomicLong ID_COUNTER = new AtomicLong(0);
+
+        public Message.ID generate() {
+            return new LongMessageID(ID_COUNTER.getAndIncrement());
+        }
+    }
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LongMessageID.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LongMessageID.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LongMessageID.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.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/Message.java?rev=578445&r1=578444&r2=578445&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/Message.java
Sat Sep 22 07:22:56 2007
@@ -58,23 +58,11 @@
 
     WriteFuture reply(Message msg);
 
-    //
-    // ID
-    //
-
-    //
-    // HACK: Make these serializable for now... need to figure out how to do the generic
encode/decode of MarshalAware instances
-    //
-    
     interface ID
         extends MarshalAware, Serializable
     {
         // Marker
     }
-
-    //
-    // ID Generator
-    //
 
     interface IDGenerator
     {

Modified: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageHandler.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/MessageHandler.java?rev=578445&r1=578444&r2=578445&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageHandler.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/MessageHandler.java
Sat Sep 22 07:22:56 2007
@@ -80,6 +80,10 @@
         if (obj instanceof Message) {
             Message msg = (Message)obj;
 
+            //
+            // TODO: Change the visit* methods to take a session and a visitor to avoid needing
to attach to the message
+            //
+            
             // Attach the session to the context
             msg.setSession(session);
             msg.freeze();

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=578445&r1=578444&r2=578445&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
Sat Sep 22 07:22:56 2007
@@ -20,7 +20,6 @@
 package org.apache.geronimo.gshell.remote.message;
 
 import java.io.IOException;
-import java.util.UUID;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.geronimo.gshell.common.tostring.ReflectionToStringBuilder;
@@ -38,7 +37,7 @@
 public class MessageSupport
     implements Message
 {
-    private static final IDGenerator ID_GENERATOR = new LongIDGenerator();
+    private static final IDGenerator ID_GENERATOR = new UuidMessageID.Generator(); // new
LongMessageID.Generator();
 
     private static final AtomicLong SEQUENCE_COUNTER = new AtomicLong(0);
 
@@ -46,7 +45,7 @@
 
     private ID id;
 
-    private ID correlationId;
+    private ID cid;
 
     private Long sequence;
 
@@ -79,7 +78,7 @@
     }
     
     public ID getCorrelationId() {
-        return correlationId;
+        return cid;
     }
 
     public void setCorrelationId(final ID id) {
@@ -87,7 +86,7 @@
 
         assert id != null;
 
-        this.correlationId = id;
+        this.cid = id;
     }
 
     public long getTimestamp() {
@@ -148,9 +147,9 @@
     public void readExternal(final ByteBuffer in) throws Exception {
         assert in != null;
 
-        id = (ID) Marshaller.readObject(in);
+        id = (ID) Marshaller.unmarshal(in);
 
-        correlationId = (ID) Marshaller.readObject(in);
+        cid = (ID) Marshaller.unmarshal(in);
 
         timestamp = in.getLong();
 
@@ -160,134 +159,14 @@
     public void writeExternal(final ByteBuffer out) throws Exception {
         assert out != null;
 
-        Marshaller.writeObject(out, id);
+        Marshaller.marshal(out, id);
 
-        Marshaller.writeObject(out, correlationId);
+        Marshaller.marshal(out, cid);
 
         out.putLong(timestamp);
 
         sequence = SEQUENCE_COUNTER.getAndIncrement();
         
         out.putLong(sequence);
-    }
-
-    //
-    // LongID Generator
-    //
-
-    private static class LongIDGenerator
-        implements IDGenerator
-    {
-        private static final AtomicLong ID_COUNTER = new AtomicLong(0);
-
-        public ID generate() {
-            return new LongID(ID_COUNTER.getAndIncrement());
-        }
-    }
-
-    //
-    // Long ID
-    //
-
-    private static class LongID
-        implements ID
-    {
-        private Long value;
-
-        public LongID(final long value) {
-            this.value = value;
-        }
-
-        public int hashCode() {
-            return value.hashCode();
-        }
-
-        public boolean equals(final Object obj) {
-            if (obj == this) {
-                return true;
-            }
-            else if (obj == null) {
-                return false;
-            }
-            else if (!(obj instanceof LongID)) {
-                return false;
-            }
-
-            return value.equals(((LongID)obj).value);
-        }
-
-        public String toString() {
-            return String.valueOf(value);
-        }
-
-        public void writeExternal(final ByteBuffer out) throws Exception {
-            out.putLong(value);
-
-        }
-
-        public void readExternal(final ByteBuffer in) throws Exception {
-            value = in.getLong();
-        }
-    }
-
-    //
-    // UUID Generator
-    //
-
-    private static class UUIDGenerator
-        implements IDGenerator
-    {
-        public ID generate() {
-            return new UUIDAdapter();
-        }
-    }
-
-    //
-    // UUID Adapter
-    //
-
-    private static class UUIDAdapter
-        implements ID
-    {
-        private UUID value;
-
-        public UUIDAdapter(final UUID value) {
-            this.value = value;
-        }
-
-        public UUIDAdapter() {
-            this(UUID.randomUUID());
-        }
-
-        public int hashCode() {
-            return value.hashCode();
-        }
-
-        public boolean equals(final Object obj) {
-            if (obj == this) {
-                return true;
-            }
-            else if (obj == null) {
-                return false;
-            }
-            else if (!(obj instanceof UUIDAdapter)) {
-                return false;
-            }
-
-            return value.equals(((UUIDAdapter)obj).value);
-        }
-
-        public String toString() {
-            return String.valueOf(value);
-        }
-
-        public void writeExternal(final ByteBuffer out) throws Exception {
-            Marshaller.writeUuid(out, value);
-
-        }
-
-        public void readExternal(final ByteBuffer in) throws Exception {
-            value = Marshaller.readUuid(in);
-        }
     }
 }

Added: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.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/UuidMessageID.java?rev=578445&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java
Sat Sep 22 07:22:56 2007
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.remote.message;
+
+import java.util.UUID;
+
+import org.apache.geronimo.gshell.remote.marshall.Marshaller;
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * Provides {@link Message.ID} instances based on {@link UUID} objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UuidMessageID
+    implements Message.ID
+{
+    private UUID value;
+
+    public UuidMessageID(final UUID value) {
+        this.value = value;
+    }
+
+    public UuidMessageID() {
+        this(UUID.randomUUID());
+    }
+
+    public int hashCode() {
+        return value.hashCode();
+    }
+
+    public boolean equals(final Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        else if (obj == null) {
+            return false;
+        }
+        else if (!(obj instanceof UuidMessageID)) {
+            return false;
+        }
+
+        return value.equals(((UuidMessageID)obj).value);
+    }
+
+    public String toString() {
+        return String.valueOf(value);
+    }
+
+    public void writeExternal(final ByteBuffer out) throws Exception {
+        Marshaller.writeUuid(out, value);
+    }
+
+    public void readExternal(final ByteBuffer in) throws Exception {
+        value = Marshaller.readUuid(in);
+    }
+
+    /**
+     * Factory to create {@link UuidMessageID} instances.
+     */
+    public static class Generator
+        implements Message.IDGenerator
+    {
+        public Message.ID generate() {
+            return new UuidMessageID();
+        }
+    }
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/UuidMessageID.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message