Generics for o.a.c.tribes.io
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 24 Dec 2008 17:49:57 +0000 (17:49 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 24 Dec 2008 17:49:57 +0000 (17:49 +0000)
Fix various Eclipse warnings (unused code etc)

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@729341 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/tribes/io/BufferPool.java
java/org/apache/catalina/tribes/io/BufferPool15Impl.java
java/org/apache/catalina/tribes/io/ReplicationStream.java
java/org/apache/catalina/tribes/io/XByteBuffer.java

index db9a1cb..1efbe01 100644 (file)
@@ -59,7 +59,7 @@ public class BufferPool {
             synchronized (BufferPool.class) {
                 if ( instance == null ) {
                    BufferPoolAPI pool = null;
-                   Class clazz = null;
+                   Class<?> clazz = null;
                    try {
                        clazz = Class.forName("org.apache.catalina.tribes.io.BufferPool15Impl");
                        pool = (BufferPoolAPI)clazz.newInstance();
index a1d32d4..3cc2b15 100644 (file)
@@ -27,7 +27,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 class BufferPool15Impl implements BufferPool.BufferPoolAPI {
     protected int maxSize;
     protected AtomicInteger size = new AtomicInteger(0);
-    protected ConcurrentLinkedQueue queue = new ConcurrentLinkedQueue();
+    protected ConcurrentLinkedQueue<XByteBuffer> queue = new ConcurrentLinkedQueue<XByteBuffer>();
 
     public void setMaxSize(int bytes) {
         this.maxSize = bytes;
@@ -35,7 +35,7 @@ class BufferPool15Impl implements BufferPool.BufferPoolAPI {
 
 
     public XByteBuffer getBuffer(int minSize, boolean discard) {
-        XByteBuffer buffer = (XByteBuffer)queue.poll();
+        XByteBuffer buffer = queue.poll();
         if ( buffer != null ) size.addAndGet(-buffer.getCapacity());
         if ( buffer == null ) buffer = new XByteBuffer(minSize,discard);
         else if ( buffer.getCapacity() <= minSize ) buffer.expand(minSize);
index ff3bea8..db94ab3 100644 (file)
@@ -69,7 +69,7 @@ public final class ReplicationStream extends ObjectInputStream {
      * @exception ClassNotFoundException if this class cannot be found
      * @exception IOException if an input/output error occurs
      */
-    public Class resolveClass(ObjectStreamClass classDesc)
+    public Class<?> resolveClass(ObjectStreamClass classDesc)
         throws ClassNotFoundException, IOException {
         String name = classDesc.getName();
         try {
@@ -79,7 +79,7 @@ public final class ReplicationStream extends ObjectInputStream {
         }
     }
     
-    public Class resolveClass(String name)
+    public Class<?> resolveClass(String name)
         throws ClassNotFoundException, IOException {
 
         boolean tryRepFirst = name.startsWith("org.apache.catalina.tribes");
@@ -109,9 +109,9 @@ public final class ReplicationStream extends ObjectInputStream {
         boolean hasNonPublicInterface = false;
 
         // define proxy in class loader of non-public interface(s), if any
-        Class[] classObjs = new Class[interfaces.length];
+        Class<?>[] classObjs = new Class[interfaces.length];
         for (int i = 0; i < interfaces.length; i++) {
-            Class cl = this.resolveClass(interfaces[i]);
+            Class<?> cl = this.resolveClass(interfaces[i]);
             if (latestLoader==null) latestLoader = cl.getClassLoader();
             if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
                 if (hasNonPublicInterface) {
@@ -135,17 +135,17 @@ public final class ReplicationStream extends ObjectInputStream {
     }
 
     
-    public Class findReplicationClass(String name)
+    public Class<?> findReplicationClass(String name)
         throws ClassNotFoundException, IOException {
-        Class clazz = Class.forName(name, false, getClass().getClassLoader());
+        Class<?> clazz = Class.forName(name, false, getClass().getClassLoader());
         return clazz;
     }
 
-    public Class findExternalClass(String name) throws ClassNotFoundException  {
+    public Class<?> findExternalClass(String name) throws ClassNotFoundException  {
         ClassNotFoundException cnfe = null;
         for (int i=0; i<classLoaders.length; i++ ) {
             try {
-                Class clazz = Class.forName(name, false, classLoaders[i]);
+                Class<?> clazz = Class.forName(name, false, classLoaders[i]);
                 return clazz;
             } catch ( ClassNotFoundException x ) {
                 cnfe = x;
index 4c103f4..4544bdf 100644 (file)
@@ -62,16 +62,6 @@ public class XByteBuffer
     public static final byte[] END_DATA = {84,76,70,50,48,48,51};
  
     /**
-     * Default size on the initial byte buffer
-     */
-    private static final int DEF_SIZE = 2048;
-    /**
-     * Default size to extend the buffer with
-     */
-    private static final int DEF_EXT  = 1024;
-    
-    /**
      * Variable to hold the data
      */
     protected byte[] buf = null;
@@ -407,10 +397,10 @@ public class XByteBuffer
      * @exception java.lang.ArrayIndexOutOfBoundsException
      */
     public static int toInt(byte[] b,int off){
-        return ( ( (int) b[off+3]) & 0xFF) +
-            ( ( ( (int) b[off+2]) & 0xFF) << 8) +
-            ( ( ( (int) b[off+1]) & 0xFF) << 16) +
-            ( ( ( (int) b[off+0]) & 0xFF) << 24);
+        return ( ( b[off+3]) & 0xFF) +
+            ( ( ( b[off+2]) & 0xFF) << 8) +
+            ( ( ( b[off+1]) & 0xFF) << 16) +
+            ( ( ( b[off+0]) & 0xFF) << 24);
     }
 
     /**