[jboss-remoting-commits] JBoss Remoting SVN: r4595 - in remoting3/trunk: util/src/main/java/org/jboss/remoting/util and 1 other directory.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Mon Oct 6 23:06:01 EDT 2008


Author: david.lloyd at jboss.com
Date: 2008-10-06 23:06:01 -0400 (Mon, 06 Oct 2008)
New Revision: 4595

Modified:
   remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicHandler.java
   remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/RemotingChannelConfiguration.java
   remoting3/trunk/util/src/main/java/org/jboss/remoting/util/ConcurrentIntegerMap.java
   remoting3/trunk/util/src/main/java/org/jboss/remoting/util/EmulatedConcurrentIntegerHashMap.java
Log:
Factor out classloaders; simplify concurrent integer map

Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicHandler.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicHandler.java	2008-10-07 00:08:21 UTC (rev 4594)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/BasicHandler.java	2008-10-07 03:06:01 UTC (rev 4595)
@@ -65,10 +65,9 @@
 
     //--== Connection configuration items ==--
     private final MarshallerFactory marshallerFactory;
-    private final Configuration configuration;
+    private final Configuration marshallingConfiguration;
     private final int linkMetric;
     private final Executor executor;
-    private final ClassLoader classLoader;
     // buffer allocator for outbound message assembly
     private final BufferAllocator<ByteBuffer> allocator;
 
@@ -102,9 +101,8 @@
     public BasicHandler(final RemotingChannelConfiguration configuration) {
         allocator = configuration.getAllocator();
         executor = configuration.getExecutor();
-        classLoader = configuration.getClassLoader();
         marshallerFactory = configuration.getMarshallerFactory();
-        this.configuration = new Configuration();
+        marshallingConfiguration = configuration.getMarshallingConfiguration();
         linkMetric = configuration.getLinkMetric();
     }
 
@@ -151,7 +149,7 @@
                     }
                     final Object payload;
                     try {
-                        final Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
+                        final Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(marshallingConfiguration);
                         try {
                             unmarshaller.start(createByteInput(buffer, true));
                             try {
@@ -186,7 +184,7 @@
                     final int requestId = buffer.getInt();
                     final Object payload;
                     try {
-                        final Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
+                        final Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(marshallingConfiguration);
                         try {
                             unmarshaller.start(createByteInput(buffer, true));
                             try {
@@ -218,7 +216,7 @@
                     }
                     final Object payload;
                     try {
-                        final Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
+                        final Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(marshallingConfiguration);
                         try {
                             unmarshaller.start(createByteInput(buffer, true));
                             try {
@@ -277,7 +275,7 @@
                     }
                     final Throwable cause;
                     try {
-                        final Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(configuration);
+                        final Unmarshaller unmarshaller = marshallerFactory.createUnmarshaller(marshallingConfiguration);
                         try {
                             unmarshaller.start(createByteInput(buffer, true));
                             try {
@@ -442,7 +440,7 @@
             buffer.put((byte) MessageType.REPLY.getId());
             buffer.putInt(requestId);
             try {
-                final org.jboss.marshalling.Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
+                final org.jboss.marshalling.Marshaller marshaller = marshallerFactory.createMarshaller(marshallingConfiguration);
                 try {
                     final List<ByteBuffer> bufferList = new ArrayList<ByteBuffer>();
                     final ByteOutput output = createByteOutput(allocator, bufferList);
@@ -471,7 +469,7 @@
             buffer.put((byte) MessageType.REQUEST_FAILED.getId());
             buffer.putInt(requestId);
             try {
-                final org.jboss.marshalling.Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
+                final org.jboss.marshalling.Marshaller marshaller = marshallerFactory.createMarshaller(marshallingConfiguration);
                 try {
                     final List<ByteBuffer> bufferList = new ArrayList<ByteBuffer>();
                     final ByteOutput output = createByteOutput(allocator, bufferList);
@@ -612,7 +610,7 @@
             log.trace("Sending outbound one-way request of type %s", request == null ? "null" : request.getClass());
             try {
                 final List<ByteBuffer> bufferList;
-                final Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
+                final Marshaller marshaller = marshallerFactory.createMarshaller(marshallingConfiguration);
                 try {
                     bufferList = new ArrayList<ByteBuffer>();
                     final ByteOutput output = createByteOutput(allocator, bufferList);
@@ -646,7 +644,7 @@
             log.trace("Sending outbound request of type %s", request == null ? "null" : request.getClass());
             try {
                 final List<ByteBuffer> bufferList;
-                final Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
+                final Marshaller marshaller = marshallerFactory.createMarshaller(marshallingConfiguration);
                 try {
                     bufferList = new ArrayList<ByteBuffer>();
                     final ByteOutput output = createByteOutput(allocator, bufferList);

Modified: remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/RemotingChannelConfiguration.java
===================================================================
--- remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/RemotingChannelConfiguration.java	2008-10-07 00:08:21 UTC (rev 4594)
+++ remoting3/trunk/protocol/basic/src/main/java/org/jboss/remoting/protocol/basic/RemotingChannelConfiguration.java	2008-10-07 03:06:01 UTC (rev 4595)
@@ -26,15 +26,16 @@
 import java.nio.ByteBuffer;
 import org.jboss.xnio.BufferAllocator;
 import org.jboss.marshalling.MarshallerFactory;
+import org.jboss.marshalling.Configuration;
 
 /**
  *
  */
 public final class RemotingChannelConfiguration {
     private MarshallerFactory marshallerFactory;
+    private Configuration marshallingConfiguration;
     private int linkMetric;
     private Executor executor;
-    private ClassLoader classLoader;
     private BufferAllocator<ByteBuffer> allocator;
 
     public RemotingChannelConfiguration() {
@@ -48,6 +49,14 @@
         this.marshallerFactory = marshallerFactory;
     }
 
+    public Configuration getMarshallingConfiguration() {
+        return marshallingConfiguration;
+    }
+
+    public void setMarshallingConfiguration(final Configuration marshallingConfiguration) {
+        this.marshallingConfiguration = marshallingConfiguration;
+    }
+
     public int getLinkMetric() {
         return linkMetric;
     }
@@ -64,14 +73,6 @@
         this.executor = executor;
     }
 
-    public ClassLoader getClassLoader() {
-        return classLoader;
-    }
-
-    public void setClassLoader(final ClassLoader classLoader) {
-        this.classLoader = classLoader;
-    }
-
     public BufferAllocator<ByteBuffer> getAllocator() {
         return allocator;
     }

Modified: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/ConcurrentIntegerMap.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/ConcurrentIntegerMap.java	2008-10-07 00:08:21 UTC (rev 4594)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/ConcurrentIntegerMap.java	2008-10-07 03:06:01 UTC (rev 4595)
@@ -22,25 +22,17 @@
 
 package org.jboss.remoting.util;
 
-import java.util.Set;
-import java.util.Collection;
-
 /**
- *
+ * A concurrent map that is keyed by integer.
  */
 public interface ConcurrentIntegerMap<V> {
-    boolean containsKey(int key);
 
-    boolean containsValue(Object value);
-
     V get(int key);
 
     V put(int key, V value);
 
     V putIfAbsent(int key, V value);
 
-    void putAll(ConcurrentIntegerMap<? extends V> m);
-
     V remove(int key);
 
     boolean remove(int key, Object oldValue);
@@ -51,27 +43,9 @@
 
     void clear();
 
-    int size();
-
     boolean isEmpty();
 
-    Set<Entry<V>> entrySet();
-
-    Collection<V> values();
-
     boolean equals(Object other);
 
     int hashCode();
-
-    interface Entry<V> {
-        int getKey();
-
-        V getValue();
-
-        V setValue(V value);
-
-        int hashCode();
-
-        boolean equals(Object other);
-    }
 }

Modified: remoting3/trunk/util/src/main/java/org/jboss/remoting/util/EmulatedConcurrentIntegerHashMap.java
===================================================================
--- remoting3/trunk/util/src/main/java/org/jboss/remoting/util/EmulatedConcurrentIntegerHashMap.java	2008-10-07 00:08:21 UTC (rev 4594)
+++ remoting3/trunk/util/src/main/java/org/jboss/remoting/util/EmulatedConcurrentIntegerHashMap.java	2008-10-07 03:06:01 UTC (rev 4595)
@@ -22,10 +22,6 @@
 
 package org.jboss.remoting.util;
 
-import java.util.Set;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Iterator;
 import java.util.concurrent.ConcurrentMap;
 
 /**
@@ -39,14 +35,6 @@
         this.delegate = delegate;
     }
 
-    public boolean containsKey(final int key) {
-        return delegate.containsKey(Integer.valueOf(key));
-    }
-
-    public boolean containsValue(final Object value) {
-        return delegate.containsValue(value);
-    }
-
     public V get(final int key) {
         return delegate.get(Integer.valueOf(key));
     }
@@ -59,10 +47,6 @@
         return delegate.putIfAbsent(Integer.valueOf(key), value);
     }
 
-    public void putAll(final ConcurrentIntegerMap<? extends V> m) {
-        throw new UnsupportedOperationException("maybe later");
-    }
-
     public V remove(final int key) {
         return delegate.remove(Integer.valueOf(key));
     }
@@ -83,22 +67,10 @@
         delegate.clear();
     }
 
-    public int size() {
-        return delegate.size();
-    }
-
     public boolean isEmpty() {
         return delegate.isEmpty();
     }
 
-    public Set<Entry<V>> entrySet() {
-        return new EmulatedEntrySet<V>(delegate.entrySet());
-    }
-
-    public Collection<V> values() {
-        return delegate.values();
-    }
-
     public boolean equals(final Object obj) {
         return super.equals(obj);
     }
@@ -106,92 +78,4 @@
     public int hashCode() {
         return super.hashCode();
     }
-
-    private static class EmulatedEntrySet<V> implements Set<Entry<V>> {
-
-        private final Set<Map.Entry<Integer, V>> delegate;
-
-        public EmulatedEntrySet(final Set<Map.Entry<Integer,V>> delegate) {
-            this.delegate = delegate;
-        }
-
-        public int size() {
-            return delegate.size();
-        }
-
-        public boolean isEmpty() {
-            return delegate.isEmpty();
-        }
-
-        public boolean contains(final Object o) {
-            // todo
-            return false;
-        }
-
-        public Iterator<Entry<V>> iterator() {
-            final Iterator<Map.Entry<Integer, V>> i = delegate.iterator();
-            return new Iterator<Entry<V>>() {
-                public boolean hasNext() {
-                    return i.hasNext();
-                }
-
-                public Entry<V> next() {
-                    final Map.Entry<Integer, V> n = i.next();
-                    return new Entry<V>() {
-                        public int getKey() {
-                            return n.getKey().intValue();
-                        }
-
-                        public V getValue() {
-                            return n.getValue();
-                        }
-
-                        public V setValue(final V value) {
-                            return n.setValue(value);
-                        }
-                    };
-                }
-
-                public void remove() {
-                    i.remove();
-                }
-            };
-        }
-
-        public Object[] toArray() {
-            throw new UnsupportedOperationException("maybe later");
-        }
-
-        public <T> T[] toArray(final T[] a) {
-            throw new UnsupportedOperationException("maybe later");
-        }
-
-        public boolean add(final Entry<V> o) {
-            throw new UnsupportedOperationException("add() not supported");
-        }
-
-        public boolean remove(final Object o) {
-            throw new UnsupportedOperationException("maybe later");
-        }
-
-        public boolean containsAll(final Collection<?> c) {
-            throw new UnsupportedOperationException("maybe later");
-        }
-
-        public boolean addAll(final Collection<? extends Entry<V>> c) {
-            throw new UnsupportedOperationException("addAll() not supported");
-        }
-
-        public boolean retainAll(final Collection<?> c) {
-            throw new UnsupportedOperationException("maybe later");
-        }
-
-        public boolean removeAll(final Collection<?> c) {
-            throw new UnsupportedOperationException("maybe later");
-        }
-
-        public void clear() {
-            delegate.clear();
-        }
-    }
 }




More information about the jboss-remoting-commits mailing list