activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r563982 [27/32] - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/ main/java/org/apache/activemq/advisory/ main/java/org/apache/activemq/blob/ main/java/org/apache/activemq/broker/ main/java/org/apache/activemq/broker/jm...
Date Wed, 08 Aug 2007 18:58:13 GMT
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/LRUCache.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/LRUCache.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/LRUCache.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/LRUCache.java Wed Aug  8 11:56:59 2007
@@ -18,71 +18,68 @@
 
 import java.util.LinkedHashMap;
 import java.util.Map;
+
 /**
  * A Simple LRU Cache
  * 
  * @version $Revision$
- * @param <K> 
- * @param <V> 
+ * @param <K>
+ * @param <V>
  */
 
 public class LRUCache<K, V> extends LinkedHashMap<K, V> {
-    private static final long serialVersionUID=-342098639681884413L;
-    protected int maxCacheSize=10000;
+    private static final long serialVersionUID = -342098639681884413L;
+    protected int maxCacheSize = 10000;
 
-    
     /**
-     * Default constructorfor an LRU Cache
-     * The default capacity is 10000
-     * 
+     * Default constructorfor an LRU Cache The default capacity is 10000
      */
-    public LRUCache(){
-        super(1000,0.75f,true);
+    public LRUCache() {
+        super(1000, 0.75f, true);
     }
-    
+
     /**
      * Constructs a LRUCache with a maximum capacity
+     * 
      * @param maximumCacheSize
      */
     public LRUCache(int maximumCacheSize) {
-        this(maximumCacheSize,maximumCacheSize,0.75f,true);
+        this(maximumCacheSize, maximumCacheSize, 0.75f, true);
     }
+
     /**
-     * Constructs an empty <tt>LRUCache</tt> instance with the
-     * specified initial capacity, maximumCacheSize,load factor and ordering mode.
-     *
-     * @param  initialCapacity the initial capacity.
-     * @param maximumCacheSize 
-     * @param  loadFactor      the load factor.
-     * @param  accessOrder     the ordering mode - <tt>true</tt> for
-     *         access-order, <tt>false</tt> for insertion-order.
-     * @throws IllegalArgumentException if the initial capacity is negative
-     *         or the load factor is nonpositive.
+     * Constructs an empty <tt>LRUCache</tt> instance with the specified
+     * initial capacity, maximumCacheSize,load factor and ordering mode.
+     * 
+     * @param initialCapacity the initial capacity.
+     * @param maximumCacheSize
+     * @param loadFactor the load factor.
+     * @param accessOrder the ordering mode - <tt>true</tt> for access-order,
+     *                <tt>false</tt> for insertion-order.
+     * @throws IllegalArgumentException if the initial capacity is negative or
+     *                 the load factor is nonpositive.
      */
-    
-    public LRUCache(int initialCapacity,int maximumCacheSize,float loadFactor, boolean accessOrder) {
-        super(initialCapacity,loadFactor,accessOrder);
+
+    public LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder) {
+        super(initialCapacity, loadFactor, accessOrder);
         this.maxCacheSize = maximumCacheSize;
     }
 
-    
-
     /**
      * @return Returns the maxCacheSize.
      */
-    public int getMaxCacheSize(){
+    public int getMaxCacheSize() {
         return maxCacheSize;
     }
 
     /**
-     * @param maxCacheSize
-     *            The maxCacheSize to set.
+     * @param maxCacheSize The maxCacheSize to set.
      */
-    public void setMaxCacheSize(int maxCacheSize){
-        this.maxCacheSize=maxCacheSize;
+    public void setMaxCacheSize(int maxCacheSize) {
+        this.maxCacheSize = maxCacheSize;
     }
-    
-    protected boolean removeEldestEntry(Map.Entry entry){
+
+    protected boolean removeEldestEntry(Map.Entry entry) {
         return size() > maxCacheSize;
     }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/LinkedNode.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/LinkedNode.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/LinkedNode.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/LinkedNode.java Wed Aug  8 11:56:59 2007
@@ -17,140 +17,137 @@
 package org.apache.activemq.util;
 
 /**
- * Provides a base class for you to extend when you want object to maintain
- * a doubly linked list to other objects without using a collection class. 
+ * Provides a base class for you to extend when you want object to maintain a
+ * doubly linked list to other objects without using a collection class.
  * 
  * @author chirino
  */
 public class LinkedNode {
-	
-	protected LinkedNode next=this;
-	protected LinkedNode prev=this;
-	protected boolean tail=true; 
-	
-
-	public LinkedNode getHeadNode() {
-		if( isHeadNode() ) {
-			return this;
-		}
-		if( isTailNode() ) {
-			return next;
-		}
-		LinkedNode rc = prev;
-		while(!rc.isHeadNode()) {
-			rc = rc.prev;
-		}
-		return rc;
-	}
-	
-	public LinkedNode getTailNode() {
-		if( isTailNode() ) {
-			return this;
-		}
-		if( isHeadNode() ) {
-			return prev;
-		}
-		LinkedNode rc = next;
-		while(!rc.isTailNode()) {
-			rc = rc.next;
-		}
-		return rc;
-	}
-
-	public LinkedNode getNext() {
-		return tail ? null : next;
-	}
-
-	public LinkedNode getPrevious() {
-		return prev.tail ? null : prev;
-	}
-
-	public boolean isHeadNode() {
-		return prev.isTailNode();
-	}
-	
-	public boolean isTailNode() {
-		return tail;
-	}
-
-	/**
-	 * @param rightHead the node to link after this node.
-	 * @return this
-	 */
-	public LinkedNode linkAfter(LinkedNode rightHead) {
-		
-		if( rightHead == this ) {
-			throw new IllegalArgumentException("You cannot link to yourself");
-		}
-		if( !rightHead.isHeadNode() ) {
-			throw new IllegalArgumentException("You only insert nodes that are the first in a list");
-		}
-
-		LinkedNode rightTail = rightHead.prev;
-
-		if( tail ) {
-			tail = false;
-		} else {
-			rightTail.tail=false;
-		}
-				
-		rightHead.prev = this; // link the head of the right side.
-		rightTail.next = next; // link the tail of the right side
-		next.prev = rightTail; // link the head of the left side 		
-		next = rightHead;	   // link the tail of the left side.
-		
-		return this;
-	}
-
-	
-	/**
-	 * @param leftHead the node to link after this node.
-	 * @return 
-	 * @return this
-	 */
-	public LinkedNode linkBefore(LinkedNode leftHead) {
-		
-		
-		if( leftHead == this ) {
-			throw new IllegalArgumentException("You cannot link to yourself");
-		}
-		if( !leftHead.isHeadNode() ) {
-			throw new IllegalArgumentException("You only insert nodes that are the first in a list");
-		}
-
-		// The left side is no longer going to be a tail..
-		LinkedNode leftTail = leftHead.prev;
-		leftTail.tail = false;
-		
-		leftTail.next = this; // link the tail of the left side.		
-		leftHead.prev = prev; // link the head of the left side.
-		prev.next = leftHead; // link the tail of the right side.
-		prev = leftTail;      // link the head of the right side.
-		
-		return leftHead;
-	}
-
-	/**
-	 * Removes this node out of the linked list it is chained in.  
-	 */
-	public void unlink() {
-		// If we are allready unlinked...
-		if( prev==this ) {
-			return;
-		}
-		
-		if( tail ) {
-			prev.tail = true;
-		}
-		
-		// Update the peers links..
-		next.prev = prev;
-		prev.next = next;
-		
-		// Update our links..
-		next = this;
-		prev = this;
-		tail=true;
-	}
-	
+
+    protected LinkedNode next = this;
+    protected LinkedNode prev = this;
+    protected boolean tail = true;
+
+    public LinkedNode getHeadNode() {
+        if (isHeadNode()) {
+            return this;
+        }
+        if (isTailNode()) {
+            return next;
+        }
+        LinkedNode rc = prev;
+        while (!rc.isHeadNode()) {
+            rc = rc.prev;
+        }
+        return rc;
+    }
+
+    public LinkedNode getTailNode() {
+        if (isTailNode()) {
+            return this;
+        }
+        if (isHeadNode()) {
+            return prev;
+        }
+        LinkedNode rc = next;
+        while (!rc.isTailNode()) {
+            rc = rc.next;
+        }
+        return rc;
+    }
+
+    public LinkedNode getNext() {
+        return tail ? null : next;
+    }
+
+    public LinkedNode getPrevious() {
+        return prev.tail ? null : prev;
+    }
+
+    public boolean isHeadNode() {
+        return prev.isTailNode();
+    }
+
+    public boolean isTailNode() {
+        return tail;
+    }
+
+    /**
+     * @param rightHead the node to link after this node.
+     * @return this
+     */
+    public LinkedNode linkAfter(LinkedNode rightHead) {
+
+        if (rightHead == this) {
+            throw new IllegalArgumentException("You cannot link to yourself");
+        }
+        if (!rightHead.isHeadNode()) {
+            throw new IllegalArgumentException("You only insert nodes that are the first in a list");
+        }
+
+        LinkedNode rightTail = rightHead.prev;
+
+        if (tail) {
+            tail = false;
+        } else {
+            rightTail.tail = false;
+        }
+
+        rightHead.prev = this; // link the head of the right side.
+        rightTail.next = next; // link the tail of the right side
+        next.prev = rightTail; // link the head of the left side
+        next = rightHead; // link the tail of the left side.
+
+        return this;
+    }
+
+    /**
+     * @param leftHead the node to link after this node.
+     * @return
+     * @return this
+     */
+    public LinkedNode linkBefore(LinkedNode leftHead) {
+
+        if (leftHead == this) {
+            throw new IllegalArgumentException("You cannot link to yourself");
+        }
+        if (!leftHead.isHeadNode()) {
+            throw new IllegalArgumentException("You only insert nodes that are the first in a list");
+        }
+
+        // The left side is no longer going to be a tail..
+        LinkedNode leftTail = leftHead.prev;
+        leftTail.tail = false;
+
+        leftTail.next = this; // link the tail of the left side.
+        leftHead.prev = prev; // link the head of the left side.
+        prev.next = leftHead; // link the tail of the right side.
+        prev = leftTail; // link the head of the right side.
+
+        return leftHead;
+    }
+
+    /**
+     * Removes this node out of the linked list it is chained in.
+     */
+    public void unlink() {
+        // If we are allready unlinked...
+        if (prev == this) {
+            return;
+        }
+
+        if (tail) {
+            prev.tail = true;
+        }
+
+        // Update the peers links..
+        next.prev = prev;
+        prev.next = next;
+
+        // Update our links..
+        next = this;
+        prev = this;
+        tail = true;
+    }
+
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MarshallingSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MarshallingSupport.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MarshallingSupport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MarshallingSupport.java Wed Aug  8 11:56:59 2007
@@ -32,37 +32,35 @@
 import java.util.Properties;
 
 /**
- * 
- * 
- * The fixed version of the UTF8 encoding function.  Some older JVM's UTF8 encoding function
- * breaks when handling large strings. 
+ * The fixed version of the UTF8 encoding function. Some older JVM's UTF8
+ * encoding function breaks when handling large strings.
  * 
  * @version $Revision$
  */
 public class MarshallingSupport {
-   
-    public static final byte NULL                    = 0;
-    public static final byte BOOLEAN_TYPE            = 1;
-    public static final byte BYTE_TYPE               = 2;
-    public static final byte CHAR_TYPE               = 3;
-    public static final byte SHORT_TYPE              = 4;
-    public static final byte INTEGER_TYPE            = 5;
-    public static final byte LONG_TYPE               = 6;
-    public static final byte DOUBLE_TYPE             = 7;
-    public static final byte FLOAT_TYPE              = 8;
-    public static final byte STRING_TYPE             = 9;
-    public static final byte BYTE_ARRAY_TYPE         = 10;
-    public static final byte MAP_TYPE                = 11;
-    public static final byte LIST_TYPE               = 12;
-    public static final byte BIG_STRING_TYPE         = 13;
 
-    static  public void marshalPrimitiveMap(Map map, DataOutputStream out) throws IOException {
-        if( map == null ) {
+    public static final byte NULL = 0;
+    public static final byte BOOLEAN_TYPE = 1;
+    public static final byte BYTE_TYPE = 2;
+    public static final byte CHAR_TYPE = 3;
+    public static final byte SHORT_TYPE = 4;
+    public static final byte INTEGER_TYPE = 5;
+    public static final byte LONG_TYPE = 6;
+    public static final byte DOUBLE_TYPE = 7;
+    public static final byte FLOAT_TYPE = 8;
+    public static final byte STRING_TYPE = 9;
+    public static final byte BYTE_ARRAY_TYPE = 10;
+    public static final byte MAP_TYPE = 11;
+    public static final byte LIST_TYPE = 12;
+    public static final byte BIG_STRING_TYPE = 13;
+
+    static public void marshalPrimitiveMap(Map map, DataOutputStream out) throws IOException {
+        if (map == null) {
             out.writeInt(-1);
         } else {
             out.writeInt(map.size());
             for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
-                String name = (String) iter.next();
+                String name = (String)iter.next();
                 out.writeUTF(name);
                 Object value = map.get(name);
                 marshalPrimitive(out, value);
@@ -71,37 +69,37 @@
     }
 
     static public Map unmarshalPrimitiveMap(DataInputStream in) throws IOException {
-		return unmarshalPrimitiveMap(in, Integer.MAX_VALUE);
-	}
+        return unmarshalPrimitiveMap(in, Integer.MAX_VALUE);
+    }
 
     /**
      * @param in
      * @return
-     * @throws IOException 
+     * @throws IOException
      * @throws IOException
      */
-	public static Map unmarshalPrimitiveMap(DataInputStream in, int max_property_size) throws IOException {
+    public static Map unmarshalPrimitiveMap(DataInputStream in, int max_property_size) throws IOException {
         int size = in.readInt();
-        if( size > max_property_size ) {
-        	throw new IOException("Primitive map is larger than the allowed size: "+size);
+        if (size > max_property_size) {
+            throw new IOException("Primitive map is larger than the allowed size: " + size);
         }
-        if( size < 0 ) {
+        if (size < 0) {
             return null;
         } else {
             HashMap rc = new HashMap(size);
-            for(int i=0; i < size; i++) {
+            for (int i = 0; i < size; i++) {
                 String name = in.readUTF();
                 rc.put(name, unmarshalPrimitive(in));
             }
             return rc;
         }
-        
+
     }
 
     public static void marshalPrimitiveList(List list, DataOutputStream out) throws IOException {
         out.writeInt(list.size());
         for (Iterator iter = list.iterator(); iter.hasNext();) {
-            Object element = (Object) iter.next();
+            Object element = (Object)iter.next();
             marshalPrimitive(out, element);
         }
     }
@@ -116,43 +114,42 @@
     }
 
     static public void marshalPrimitive(DataOutputStream out, Object value) throws IOException {
-        if( value == null ) {
+        if (value == null) {
             marshalNull(out);
-        } else if( value.getClass() == Boolean.class ) {
+        } else if (value.getClass() == Boolean.class) {
             marshalBoolean(out, ((Boolean)value).booleanValue());
-        } else if( value.getClass() == Byte.class ) {
+        } else if (value.getClass() == Byte.class) {
             marshalByte(out, ((Byte)value).byteValue());
-        } else if( value.getClass() == Character.class ) {
+        } else if (value.getClass() == Character.class) {
             marshalChar(out, ((Character)value).charValue());
-        } else if( value.getClass() == Short.class ) {
+        } else if (value.getClass() == Short.class) {
             marshalShort(out, ((Short)value).shortValue());
-        } else if( value.getClass() == Integer.class ) {
+        } else if (value.getClass() == Integer.class) {
             marshalInt(out, ((Integer)value).intValue());
-        } else if( value.getClass() == Long.class ) {
+        } else if (value.getClass() == Long.class) {
             marshalLong(out, ((Long)value).longValue());
-        } else if( value.getClass() == Float.class ) {
+        } else if (value.getClass() == Float.class) {
             marshalFloat(out, ((Float)value).floatValue());
-        } else if( value.getClass() == Double.class ) {
+        } else if (value.getClass() == Double.class) {
             marshalDouble(out, ((Double)value).doubleValue());
-        } else if( value.getClass() == byte[].class ) {
+        } else if (value.getClass() == byte[].class) {
             marshalByteArray(out, ((byte[])value));
-        } else if( value.getClass() == String.class ) {
+        } else if (value.getClass() == String.class) {
             marshalString(out, (String)value);
-        } else if( value instanceof Map) {
+        } else if (value instanceof Map) {
             out.writeByte(MAP_TYPE);
-            marshalPrimitiveMap((Map) value, out);
-        } else if( value instanceof List) {
+            marshalPrimitiveMap((Map)value, out);
+        } else if (value instanceof List) {
             out.writeByte(LIST_TYPE);
-            marshalPrimitiveList((List) value, out);
+            marshalPrimitiveList((List)value, out);
         } else {
-            throw new IOException("Object is not a primitive: "+value);
+            throw new IOException("Object is not a primitive: " + value);
         }
     }
 
-
     static public Object unmarshalPrimitive(DataInputStream in) throws IOException {
-        Object value=null;
-        switch( in.readByte() ) {
+        Object value = null;
+        switch (in.readByte()) {
         case BYTE_TYPE:
             value = Byte.valueOf(in.readByte());
             break;
@@ -251,10 +248,9 @@
         out.write(value, offset, length);
     }
 
-
     public static void marshalString(DataOutputStream out, String s) throws IOException {
         // If it's too big, out.writeUTF may not able able to write it out.
-        if( s.length() < Short.MAX_VALUE/4 ) {
+        if (s.length() < Short.MAX_VALUE / 4) {
             out.writeByte(STRING_TYPE);
             out.writeUTF(s);
         } else {
@@ -282,23 +278,25 @@
                     utflen += 2;
                 }
             }
-            //TODO diff: Sun code - removed
-            byte[] bytearr = new byte[utflen + 4]; //TODO diff: Sun code
-            bytearr[count++] = (byte) ((utflen >>> 24) & 0xFF); //TODO diff: Sun code
-            bytearr[count++] = (byte) ((utflen >>> 16) & 0xFF); //TODO diff: Sun code
-            bytearr[count++] = (byte) ((utflen >>> 8) & 0xFF);
-            bytearr[count++] = (byte) ((utflen >>> 0) & 0xFF);
+            // TODO diff: Sun code - removed
+            byte[] bytearr = new byte[utflen + 4]; // TODO diff: Sun code
+            bytearr[count++] = (byte)((utflen >>> 24) & 0xFF); // TODO diff:
+                                                                // Sun code
+            bytearr[count++] = (byte)((utflen >>> 16) & 0xFF); // TODO diff:
+                                                                // Sun code
+            bytearr[count++] = (byte)((utflen >>> 8) & 0xFF);
+            bytearr[count++] = (byte)((utflen >>> 0) & 0xFF);
             for (int i = 0; i < strlen; i++) {
                 c = charr[i];
                 if ((c >= 0x0001) && (c <= 0x007F)) {
-                    bytearr[count++] = (byte) c;
+                    bytearr[count++] = (byte)c;
                 } else if (c > 0x07FF) {
-                    bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
-                    bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
-                    bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+                    bytearr[count++] = (byte)(0xE0 | ((c >> 12) & 0x0F));
+                    bytearr[count++] = (byte)(0x80 | ((c >> 6) & 0x3F));
+                    bytearr[count++] = (byte)(0x80 | ((c >> 0) & 0x3F));
                 } else {
-                    bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
-                    bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+                    bytearr[count++] = (byte)(0xC0 | ((c >> 6) & 0x1F));
+                    bytearr[count++] = (byte)(0x80 | ((c >> 0) & 0x3F));
                 }
             }
             dataOut.write(bytearr);
@@ -309,7 +307,7 @@
     }
 
     static public String readUTF8(DataInput dataIn) throws IOException {
-        int utflen = dataIn.readInt(); //TODO diff: Sun code
+        int utflen = dataIn.readInt(); // TODO diff: Sun code
         if (utflen > -1) {
             StringBuffer str = new StringBuffer(utflen);
             byte bytearr[] = new byte[utflen];
@@ -321,47 +319,47 @@
             while (count < utflen) {
                 c = bytearr[count] & 0xff;
                 switch (c >> 4) {
-                    case 0:
-                    case 1:
-                    case 2:
-                    case 3:
-                    case 4:
-                    case 5:
-                    case 6:
-                    case 7:
-                        /* 0xxxxxxx */
-                        count++;
-                        str.append((char) c);
-                        break;
-                    case 12:
-                    case 13:
-                        /* 110x xxxx 10xx xxxx */
-                        count += 2;
-                        if (count > utflen) {
-                            throw new UTFDataFormatException();
-                        }
-                        char2 = bytearr[count - 1];
-                        if ((char2 & 0xC0) != 0x80) {
-                            throw new UTFDataFormatException();
-                        }
-                        str.append((char) (((c & 0x1F) << 6) | (char2 & 0x3F)));
-                        break;
-                    case 14:
-                        /* 1110 xxxx 10xx xxxx 10xx xxxx */
-                        count += 3;
-                        if (count > utflen) {
-                            throw new UTFDataFormatException();
-                        }
-                        char2 = bytearr[count - 2]; //TODO diff: Sun code
-                        char3 = bytearr[count - 1]; //TODO diff: Sun code
-                        if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) {
-                            throw new UTFDataFormatException();
-                        }
-                        str.append((char) (((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)));
-                        break;
-                    default :
-                        /* 10xx xxxx, 1111 xxxx */
+                case 0:
+                case 1:
+                case 2:
+                case 3:
+                case 4:
+                case 5:
+                case 6:
+                case 7:
+                    /* 0xxxxxxx */
+                    count++;
+                    str.append((char)c);
+                    break;
+                case 12:
+                case 13:
+                    /* 110x xxxx 10xx xxxx */
+                    count += 2;
+                    if (count > utflen) {
+                        throw new UTFDataFormatException();
+                    }
+                    char2 = bytearr[count - 1];
+                    if ((char2 & 0xC0) != 0x80) {
+                        throw new UTFDataFormatException();
+                    }
+                    str.append((char)(((c & 0x1F) << 6) | (char2 & 0x3F)));
+                    break;
+                case 14:
+                    /* 1110 xxxx 10xx xxxx 10xx xxxx */
+                    count += 3;
+                    if (count > utflen) {
+                        throw new UTFDataFormatException();
+                    }
+                    char2 = bytearr[count - 2]; // TODO diff: Sun code
+                    char3 = bytearr[count - 1]; // TODO diff: Sun code
+                    if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)) {
                         throw new UTFDataFormatException();
+                    }
+                    str.append((char)(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)));
+                    break;
+                default:
+                    /* 10xx xxxx, 1111 xxxx */
+                    throw new UTFDataFormatException();
                 }
             }
             // The number of chars produced may be less than utflen
@@ -370,27 +368,26 @@
             return null;
         }
     }
-    
-    public static String propertiesToString(Properties props) throws IOException{
-        String result="";
-        if(props!=null){
-            DataByteArrayOutputStream dataOut=new DataByteArrayOutputStream();
-            props.store(dataOut,"");
-            result=new String(dataOut.getData(),0,dataOut.size());
+
+    public static String propertiesToString(Properties props) throws IOException {
+        String result = "";
+        if (props != null) {
+            DataByteArrayOutputStream dataOut = new DataByteArrayOutputStream();
+            props.store(dataOut, "");
+            result = new String(dataOut.getData(), 0, dataOut.size());
             dataOut.close();
         }
         return result;
     }
-    
+
     public static Properties stringToProperties(String str) throws IOException {
         Properties result = new Properties();
-        if (str != null && str.length() > 0 ) {
+        if (str != null && str.length() > 0) {
             DataByteArrayInputStream dataIn = new DataByteArrayInputStream(str.getBytes());
             result.load(dataIn);
             dataIn.close();
         }
         return result;
     }
-
 
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MemoryIntPropertyEditor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MemoryIntPropertyEditor.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MemoryIntPropertyEditor.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MemoryIntPropertyEditor.java Wed Aug  8 11:56:59 2007
@@ -20,49 +20,47 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-/** 
- * Converts string values like "20 Mb", "1024kb", and "1g"
- * to int values in bytes.
- * 
+/**
+ * Converts string values like "20 Mb", "1024kb", and "1g" to int values in
+ * bytes.
  */
 public class MemoryIntPropertyEditor extends PropertyEditorSupport {
-	public void setAsText(String text) throws IllegalArgumentException {
+    public void setAsText(String text) throws IllegalArgumentException {
 
-		Pattern p = Pattern.compile("^\\s*(\\d+)\\s*(b)?\\s*$",Pattern.CASE_INSENSITIVE);
-		Matcher m = p.matcher(text);
-		if (m.matches()) {
-			setValue(Integer.valueOf(Integer.parseInt(m.group(1))));
-			return;
-		}
-
-		p = Pattern.compile("^\\s*(\\d+)\\s*k(b)?\\s*$",Pattern.CASE_INSENSITIVE);
-		m = p.matcher(text);
-		if (m.matches()) {
-			setValue(Integer.valueOf(Integer.parseInt(m.group(1)) * 1024));
-			return;
-		}
-
-		p = Pattern.compile("^\\s*(\\d+)\\s*m(b)?\\s*$", Pattern.CASE_INSENSITIVE);
-		m = p.matcher(text);
-		if (m.matches()) {
-			setValue(Integer.valueOf(Integer.parseInt(m.group(1)) * 1024 * 1024 ));
-			return;
-		}
-
-		p = Pattern.compile("^\\s*(\\d+)\\s*g(b)?\\s*$", Pattern.CASE_INSENSITIVE);
-		m = p.matcher(text);
-		if (m.matches()) {
-			setValue(Integer.valueOf(Integer.parseInt(m.group(1)) * 1024 * 1024 * 1024 ));
-			return;
-		}
-
-		throw new IllegalArgumentException(
-				"Could convert not to a memory size: " + text);
-	}
-
-	public String getAsText() {
-		Integer value = (Integer) getValue();
-		return (value != null ? value.toString() : "");
-	}
+        Pattern p = Pattern.compile("^\\s*(\\d+)\\s*(b)?\\s*$", Pattern.CASE_INSENSITIVE);
+        Matcher m = p.matcher(text);
+        if (m.matches()) {
+            setValue(Integer.valueOf(Integer.parseInt(m.group(1))));
+            return;
+        }
+
+        p = Pattern.compile("^\\s*(\\d+)\\s*k(b)?\\s*$", Pattern.CASE_INSENSITIVE);
+        m = p.matcher(text);
+        if (m.matches()) {
+            setValue(Integer.valueOf(Integer.parseInt(m.group(1)) * 1024));
+            return;
+        }
+
+        p = Pattern.compile("^\\s*(\\d+)\\s*m(b)?\\s*$", Pattern.CASE_INSENSITIVE);
+        m = p.matcher(text);
+        if (m.matches()) {
+            setValue(Integer.valueOf(Integer.parseInt(m.group(1)) * 1024 * 1024));
+            return;
+        }
+
+        p = Pattern.compile("^\\s*(\\d+)\\s*g(b)?\\s*$", Pattern.CASE_INSENSITIVE);
+        m = p.matcher(text);
+        if (m.matches()) {
+            setValue(Integer.valueOf(Integer.parseInt(m.group(1)) * 1024 * 1024 * 1024));
+            return;
+        }
+
+        throw new IllegalArgumentException("Could convert not to a memory size: " + text);
+    }
+
+    public String getAsText() {
+        Integer value = (Integer)getValue();
+        return (value != null ? value.toString() : "");
+    }
 
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MemoryPropertyEditor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MemoryPropertyEditor.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MemoryPropertyEditor.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/MemoryPropertyEditor.java Wed Aug  8 11:56:59 2007
@@ -20,49 +20,47 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-/** 
- * Converts string values like "20 Mb", "1024kb", and "1g"
- * to long values in bytes.
- * 
+/**
+ * Converts string values like "20 Mb", "1024kb", and "1g" to long values in
+ * bytes.
  */
 public class MemoryPropertyEditor extends PropertyEditorSupport {
-	public void setAsText(String text) throws IllegalArgumentException {
+    public void setAsText(String text) throws IllegalArgumentException {
 
-		Pattern p = Pattern.compile("^\\s*(\\d+)\\s*(b)?\\s*$",Pattern.CASE_INSENSITIVE);
-		Matcher m = p.matcher(text);
-		if (m.matches()) {
-			setValue(Long.valueOf(Long.parseLong(m.group(1))));
-			return;
-		}
-
-		p = Pattern.compile("^\\s*(\\d+)\\s*k(b)?\\s*$",Pattern.CASE_INSENSITIVE);
-		m = p.matcher(text);
-		if (m.matches()) {
-			setValue(Long.valueOf(Long.parseLong(m.group(1)) * 1024));
-			return;
-		}
-
-		p = Pattern.compile("^\\s*(\\d+)\\s*m(b)?\\s*$", Pattern.CASE_INSENSITIVE);
-		m = p.matcher(text);
-		if (m.matches()) {
-			setValue(Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024 ));
-			return;
-		}
-
-		p = Pattern.compile("^\\s*(\\d+)\\s*g(b)?\\s*$", Pattern.CASE_INSENSITIVE);
-		m = p.matcher(text);
-		if (m.matches()) {
-			setValue(Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024 * 1024 ));
-			return;
-		}
-
-		throw new IllegalArgumentException(
-				"Could convert not to a memory size: " + text);
-	}
-
-	public String getAsText() {
-		Long value = (Long) getValue();
-		return (value != null ? value.toString() : "");
-	}
+        Pattern p = Pattern.compile("^\\s*(\\d+)\\s*(b)?\\s*$", Pattern.CASE_INSENSITIVE);
+        Matcher m = p.matcher(text);
+        if (m.matches()) {
+            setValue(Long.valueOf(Long.parseLong(m.group(1))));
+            return;
+        }
+
+        p = Pattern.compile("^\\s*(\\d+)\\s*k(b)?\\s*$", Pattern.CASE_INSENSITIVE);
+        m = p.matcher(text);
+        if (m.matches()) {
+            setValue(Long.valueOf(Long.parseLong(m.group(1)) * 1024));
+            return;
+        }
+
+        p = Pattern.compile("^\\s*(\\d+)\\s*m(b)?\\s*$", Pattern.CASE_INSENSITIVE);
+        m = p.matcher(text);
+        if (m.matches()) {
+            setValue(Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024));
+            return;
+        }
+
+        p = Pattern.compile("^\\s*(\\d+)\\s*g(b)?\\s*$", Pattern.CASE_INSENSITIVE);
+        m = p.matcher(text);
+        if (m.matches()) {
+            setValue(Long.valueOf(Long.parseLong(m.group(1)) * 1024 * 1024 * 1024));
+            return;
+        }
+
+        throw new IllegalArgumentException("Could convert not to a memory size: " + text);
+    }
+
+    public String getAsText() {
+        Long value = (Long)getValue();
+        return (value != null ? value.toString() : "");
+    }
 
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ServiceStopper.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ServiceStopper.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ServiceStopper.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ServiceStopper.java Wed Aug  8 11:56:59 2007
@@ -37,11 +37,10 @@
      */
     public void stop(Service service) {
         try {
-            if( service!=null ) {
+            if (service != null) {
                 service.stop();
             }
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
             onException(service, e);
         }
     }
@@ -53,8 +52,7 @@
     public void run(Callback stopClosure) {
         try {
             stopClosure.execute();
-        }
-        catch (Throwable e) {
+        } catch (Throwable e) {
             onException(stopClosure, e);
         }
     }
@@ -64,7 +62,7 @@
      */
     public void stopServices(List services) {
         for (Iterator iter = services.iterator(); iter.hasNext();) {
-            Service service = (Service) iter.next();
+            Service service = (Service)iter.next();
             stop(service);
         }
     }
@@ -82,14 +80,12 @@
     public void throwFirstException() throws Exception {
         if (firstException != null) {
             if (firstException instanceof Exception) {
-                Exception e = (Exception) firstException;
+                Exception e = (Exception)firstException;
                 throw e;
-            }
-            else if (firstException instanceof RuntimeException) {
-                RuntimeException e = (RuntimeException) firstException;
+            } else if (firstException instanceof RuntimeException) {
+                RuntimeException e = (RuntimeException)firstException;
                 throw e;
-            }
-            else {
+            } else {
                 throw new RuntimeException("Unknown type of exception: " + firstException, firstException);
             }
         }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/SubscriptionKey.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/SubscriptionKey.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/SubscriptionKey.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/SubscriptionKey.java Wed Aug  8 11:56:59 2007
@@ -19,38 +19,36 @@
 import org.apache.activemq.command.SubscriptionInfo;
 
 public class SubscriptionKey {
-    
+
     public final String clientId;
     public final String subscriptionName;
     private final int hashValue;
 
-
     public SubscriptionKey(SubscriptionInfo info) {
         this(info.getClientId(), info.getSubscriptionName());
     }
 
     public SubscriptionKey(String clientId, String subscriptionName) {
         this.clientId = clientId;
-        this.subscriptionName = subscriptionName != null? subscriptionName : "NOT_SET";
-        hashValue = clientId.hashCode()^this.subscriptionName.hashCode();
+        this.subscriptionName = subscriptionName != null ? subscriptionName : "NOT_SET";
+        hashValue = clientId.hashCode() ^ this.subscriptionName.hashCode();
     }
 
-
     public int hashCode() {
         return hashValue;
     }
-    
+
     public boolean equals(Object o) {
         try {
-            SubscriptionKey key = (SubscriptionKey) o;
+            SubscriptionKey key = (SubscriptionKey)o;
             return key.clientId.equals(clientId) && key.subscriptionName.equals(subscriptionName);
         } catch (Throwable e) {
             return false;
         }
     }
-    
+
     public String toString() {
-        return clientId+":"+subscriptionName;
+        return clientId + ":" + subscriptionName;
     }
 
     public String getClientId() {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/TransactionTemplate.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/TransactionTemplate.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/TransactionTemplate.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/TransactionTemplate.java Wed Aug  8 11:56:59 2007
@@ -23,19 +23,18 @@
 import org.apache.commons.logging.LogFactory;
 
 /**
- * A helper class for running code with a PersistenceAdapter
- * in a transaction.
- *
+ * A helper class for running code with a PersistenceAdapter in a transaction.
+ * 
  * @version $Revision: 1.2 $
  */
 public class TransactionTemplate {
-    static private final Log log=LogFactory.getLog(TransactionTemplate.class);
+    static private final Log LOG = LogFactory.getLog(TransactionTemplate.class);
     private PersistenceAdapter persistenceAdapter;
     private ConnectionContext context;
 
     public TransactionTemplate(PersistenceAdapter persistenceAdapter, ConnectionContext context) {
         this.persistenceAdapter = persistenceAdapter;
-        this.context=context;
+        this.context = context;
     }
 
     public void run(Callback task) throws IOException {
@@ -43,26 +42,22 @@
         Throwable throwable = null;
         try {
             task.execute();
-        }
-        catch (IOException t) {
+        } catch (IOException t) {
             throwable = t;
             throw t;
-        }
-        catch (RuntimeException t) {
+        } catch (RuntimeException t) {
             throwable = t;
             throw t;
-        }
-        catch (Throwable t) {
+        } catch (Throwable t) {
             throwable = t;
-            throw IOExceptionSupport.create("Persistence task failed: "+t, t);
+            throw IOExceptionSupport.create("Persistence task failed: " + t, t);
         } finally {
             if (throwable == null) {
                 persistenceAdapter.commitTransaction(context);
-            }
-            else {
-                log.error("Having to Rollback - caught an exception: " + throwable);
+            } else {
+                LOG.error("Having to Rollback - caught an exception: " + throwable);
                 persistenceAdapter.rollbackTransaction(context);
-            }            
+            }
         }
     }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java Wed Aug  8 11:56:59 2007
@@ -31,7 +31,7 @@
  * @version $Revision$
  */
 public class URISupport {
-    
+
     public static class CompositeData {
         String scheme;
         String path;
@@ -39,54 +39,59 @@
         Map parameters;
         String fragment;
         public String host;
-        
+
         public URI[] getComponents() {
             return components;
         }
+
         public String getFragment() {
             return fragment;
         }
+
         public Map getParameters() {
             return parameters;
         }
+
         public String getScheme() {
             return scheme;
         }
+
         public String getPath() {
             return path;
         }
+
         public String getHost() {
             return host;
         }
-        
+
         public URI toURI() throws URISyntaxException {
             StringBuffer sb = new StringBuffer();
-            if( scheme!=null ) {
+            if (scheme != null) {
                 sb.append(scheme);
                 sb.append(':');
             }
-            
-            if( host!=null && host.length()!=0 ) {
+
+            if (host != null && host.length() != 0) {
                 sb.append(host);
             } else {
                 sb.append('(');
                 for (int i = 0; i < components.length; i++) {
-                    if( i!=0 )
+                    if (i != 0)
                         sb.append(',');
                     sb.append(components[i].toString());
                 }
                 sb.append(')');
             }
-            
-            if( path !=null ) {
+
+            if (path != null) {
                 sb.append('/');
                 sb.append(path);
             }
-            if(!parameters.isEmpty()) {
+            if (!parameters.isEmpty()) {
                 sb.append("?");
                 sb.append(createQueryString(parameters));
             }
-            if( fragment!=null ) {
+            if (fragment != null) {
                 sb.append("#");
                 sb.append(fragment);
             }
@@ -94,30 +99,30 @@
         }
     }
 
-    public static Map parseQuery(String uri) throws URISyntaxException{
-        try{
-            Map rc=new HashMap();
-            if(uri!=null){
-                String[] parameters=uri.split("&");
-                for(int i=0;i<parameters.length;i++){
-                    int p=parameters[i].indexOf("=");
-                    if(p>=0){
-                        String name=URLDecoder.decode(parameters[i].substring(0,p),"UTF-8");
-                        String value=URLDecoder.decode(parameters[i].substring(p+1),"UTF-8");
-                        rc.put(name,value);
-                    }else{
-                        rc.put(parameters[i],null);
+    public static Map parseQuery(String uri) throws URISyntaxException {
+        try {
+            Map rc = new HashMap();
+            if (uri != null) {
+                String[] parameters = uri.split("&");
+                for (int i = 0; i < parameters.length; i++) {
+                    int p = parameters[i].indexOf("=");
+                    if (p >= 0) {
+                        String name = URLDecoder.decode(parameters[i].substring(0, p), "UTF-8");
+                        String value = URLDecoder.decode(parameters[i].substring(p + 1), "UTF-8");
+                        rc.put(name, value);
+                    } else {
+                        rc.put(parameters[i], null);
                     }
                 }
             }
             return rc;
-        }catch(UnsupportedEncodingException e){
-            throw (URISyntaxException) new URISyntaxException(e.toString(),"Invalid encoding").initCause(e);
+        } catch (UnsupportedEncodingException e) {
+            throw (URISyntaxException)new URISyntaxException(e.toString(), "Invalid encoding").initCause(e);
         }
     }
-    
+
     public static Map parseParamters(URI uri) throws URISyntaxException {
-        return uri.getQuery()==null ? Collections.EMPTY_MAP : parseQuery(stripPrefix(uri.getQuery(), "?"));
+        return uri.getQuery() == null ? Collections.EMPTY_MAP : parseQuery(stripPrefix(uri.getQuery(), "?"));
     }
 
     /**
@@ -133,15 +138,15 @@
     public static URI createURIWithQuery(URI uri, String query) throws URISyntaxException {
         return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), query, uri.getFragment());
     }
-    
+
     public static CompositeData parseComposite(URI uri) throws URISyntaxException {
-        
+
         CompositeData rc = new CompositeData();
         rc.scheme = uri.getScheme();
         String ssp = stripPrefix(uri.getSchemeSpecificPart().trim(), "//").trim();
 
         parseComposite(uri, rc, ssp);
-        
+
         rc.fragment = uri.getFragment();
         return rc;
     }
@@ -156,43 +161,43 @@
     private static void parseComposite(URI uri, CompositeData rc, String ssp) throws URISyntaxException {
         String componentString;
         String params;
-        
-        if(!checkParenthesis(ssp)){
+
+        if (!checkParenthesis(ssp)) {
             throw new URISyntaxException(uri.toString(), "Not a matching number of '(' and ')' parenthesis");
         }
-        
+
         int p;
         int intialParen = ssp.indexOf("(");
-        if( intialParen==0 ) {
+        if (intialParen == 0) {
             rc.host = ssp.substring(0, intialParen);
             p = rc.host.indexOf("/");
-            if( p >= 0 ) {
+            if (p >= 0) {
                 rc.path = rc.host.substring(p);
-                rc.host = rc.host.substring(0,p);
+                rc.host = rc.host.substring(0, p);
             }
             p = ssp.lastIndexOf(")");
-            componentString = ssp.substring(intialParen+1,p);
-            params = ssp.substring(p+1).trim();
-            
+            componentString = ssp.substring(intialParen + 1, p);
+            params = ssp.substring(p + 1).trim();
+
         } else {
             componentString = ssp;
-            params="";
+            params = "";
         }
 
         String components[] = splitComponents(componentString);
-        rc.components=new URI[components.length];
+        rc.components = new URI[components.length];
         for (int i = 0; i < components.length; i++) {
             rc.components[i] = new URI(components[i].trim());
         }
-        
+
         p = params.indexOf("?");
-        if( p >= 0 ) {
-            if( p > 0) {
+        if (p >= 0) {
+            if (p > 0) {
                 rc.path = stripPrefix(params.substring(0, p), "/");
             }
-            rc.parameters = parseQuery(params.substring(p+1));
+            rc.parameters = parseQuery(params.substring(p + 1));
         } else {
-            if( params.length() > 0 )
+            if (params.length() > 0)
                 rc.path = stripPrefix(params, "/");
             rc.parameters = Collections.EMPTY_MAP;
         }
@@ -204,12 +209,12 @@
      */
     private static String[] splitComponents(String str) {
         ArrayList l = new ArrayList();
-        
-        int last=0;
+
+        int last = 0;
         int depth = 0;
         char chars[] = str.toCharArray();
-        for( int i=0; i < chars.length; i ++ ) {
-            switch( chars[i] ) {
+        for (int i = 0; i < chars.length; i++) {
+            switch (chars[i]) {
             case '(':
                 depth++;
                 break;
@@ -217,45 +222,45 @@
                 depth--;
                 break;
             case ',':
-                if( depth == 0 ) {
+                if (depth == 0) {
                     String s = str.substring(last, i);
                     l.add(s);
-                    last=i+1;
+                    last = i + 1;
                 }
             }
         }
-        
+
         String s = str.substring(last);
-        if( s.length() !=0 )
-            l.add(s);        
-        
+        if (s.length() != 0)
+            l.add(s);
+
         String rc[] = new String[l.size()];
         l.toArray(rc);
         return rc;
     }
-    
+
     public static String stripPrefix(String value, String prefix) {
-        if( value.startsWith(prefix) )
+        if (value.startsWith(prefix))
             return value.substring(prefix.length());
         return value;
     }
-    
+
     public static URI stripScheme(URI uri) throws URISyntaxException {
-        return new URI(stripPrefix(uri.getSchemeSpecificPart().trim(), "//")); 
+        return new URI(stripPrefix(uri.getSchemeSpecificPart().trim(), "//"));
     }
 
     public static String createQueryString(Map options) throws URISyntaxException {
         try {
-            if(options.size()>0) {
+            if (options.size() > 0) {
                 StringBuffer rc = new StringBuffer();
-                boolean first=true;
+                boolean first = true;
                 for (Iterator iter = options.keySet().iterator(); iter.hasNext();) {
-                    if( first )
-                        first=false;
+                    if (first)
+                        first = false;
                     else
                         rc.append("&");
-                                    
-                    String key = (String) iter.next();
+
+                    String key = (String)iter.next();
                     String value = (String)options.get(key);
                     rc.append(URLEncoder.encode(key, "UTF-8"));
                     rc.append("=");
@@ -272,11 +277,12 @@
 
     /**
      * Creates a URI from the original URI and the remaining paramaters
-     * @throws URISyntaxException 
+     * 
+     * @throws URISyntaxException
      */
     public static URI createRemainingURI(URI originalURI, Map params) throws URISyntaxException {
         String s = createQueryString(params);
-        if( s.length()==0 )
+        if (s.length() == 0)
             s = null;
         return createURIWithQuery(originalURI, s);
     }
@@ -284,20 +290,20 @@
     static public URI changeScheme(URI bindAddr, String scheme) throws URISyntaxException {
         return new URI(scheme, bindAddr.getUserInfo(), bindAddr.getHost(), bindAddr.getPort(), bindAddr.getPath(), bindAddr.getQuery(), bindAddr.getFragment());
     }
-    
-    public static boolean checkParenthesis(String str){
-        boolean result=true;
-        if(str!=null){
-            int open=0;
-            int closed=0;
-            
-            int i=0;
-            while((i=str.indexOf('(',i)) >=0 ){
+
+    public static boolean checkParenthesis(String str) {
+        boolean result = true;
+        if (str != null) {
+            int open = 0;
+            int closed = 0;
+
+            int i = 0;
+            while ((i = str.indexOf('(', i)) >= 0) {
                 i++;
                 open++;
             }
-            i=0;
-            while((i=str.indexOf(')',i)) >=0 ){
+            i = 0;
+            while ((i = str.indexOf(')', i)) >= 0) {
                 i++;
                 closed++;
             }
@@ -305,10 +311,10 @@
         }
         return result;
     }
-    
-    public int indexOfParenthesisMatch(String str){
+
+    public int indexOfParenthesisMatch(String str) {
         int result = -1;
-        
+
         return result;
     }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/wireformat/ObjectStreamWireFormat.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/wireformat/ObjectStreamWireFormat.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/wireformat/ObjectStreamWireFormat.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/wireformat/ObjectStreamWireFormat.java Wed Aug  8 11:56:59 2007
@@ -32,13 +32,13 @@
 
 /**
  * A simple implementation which uses Object Stream serialization.
- *
+ * 
  * @version $Revision: 1.1 $
  */
 public class ObjectStreamWireFormat implements WireFormat {
 
     public ByteSequence marshal(Object command) throws IOException {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();        
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
         DataOutputStream ds = new DataOutputStream(baos);
         marshal(command, ds);
         ds.close();
@@ -64,7 +64,7 @@
             in.close();
             return command;
         } catch (ClassNotFoundException e) {
-            throw (IOException)new IOException("unmarshal failed: "+e).initCause(e);
+            throw (IOException)new IOException("unmarshal failed: " + e).initCause(e);
         }
     }
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/PooledBrokerFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/PooledBrokerFactoryBean.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/PooledBrokerFactoryBean.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/PooledBrokerFactoryBean.java Wed Aug  8 11:56:59 2007
@@ -25,29 +25,29 @@
 import org.springframework.core.io.Resource;
 
 /**
- * Used to share a single broker even if you have multiple broker bean definitions.
- * 
- * A use case is where you have multiple web applications that want to start an embedded broker
- * but only the first one to deploy should actually start it.
+ * Used to share a single broker even if you have multiple broker bean
+ * definitions. A use case is where you have multiple web applications that want
+ * to start an embedded broker but only the first one to deploy should actually
+ * start it.
  * 
  * @version $Revision$
  */
 public class PooledBrokerFactoryBean implements FactoryBean, InitializingBean, DisposableBean {
 
     static final HashMap sharedBrokerMap = new HashMap();
-    
+
     private boolean start;
     private Resource config;
-    
+
     static class SharedBroker {
         BrokerFactoryBean factory;
         int refCount;
     }
-    
+
     public void afterPropertiesSet() throws Exception {
-        synchronized( sharedBrokerMap ) {
-            SharedBroker sharedBroker = (SharedBroker) sharedBrokerMap.get(config.getFilename());
-            if( sharedBroker == null ) {
+        synchronized (sharedBrokerMap) {
+            SharedBroker sharedBroker = (SharedBroker)sharedBrokerMap.get(config.getFilename());
+            if (sharedBroker == null) {
                 sharedBroker = new SharedBroker();
                 sharedBroker.factory = new BrokerFactoryBean();
                 sharedBroker.factory.setConfig(config);
@@ -60,11 +60,11 @@
     }
 
     public void destroy() throws Exception {
-        synchronized( sharedBrokerMap ) {
-            SharedBroker sharedBroker = (SharedBroker) sharedBrokerMap.get(config.getFilename());
-            if( sharedBroker != null ) {
+        synchronized (sharedBrokerMap) {
+            SharedBroker sharedBroker = (SharedBroker)sharedBrokerMap.get(config.getFilename());
+            if (sharedBroker != null) {
                 sharedBroker.refCount--;
-                if( sharedBroker.refCount==0 ) {
+                if (sharedBroker.refCount == 0) {
                     sharedBroker.factory.destroy();
                     sharedBrokerMap.remove(config.getFilename());
                 }
@@ -77,9 +77,9 @@
     }
 
     public Object getObject() throws Exception {
-        synchronized( sharedBrokerMap ) {
-            SharedBroker sharedBroker = (SharedBroker) sharedBrokerMap.get(config.getFilename());
-            if( sharedBroker != null ) {
+        synchronized (sharedBrokerMap) {
+            SharedBroker sharedBroker = (SharedBroker)sharedBrokerMap.get(config.getFilename());
+            if (sharedBroker != null) {
                 return sharedBroker.factory.getObject();
             }
         }
@@ -103,7 +103,7 @@
     }
 
     public void setStart(boolean start) {
-        this.start=start;
+        this.start = start;
     }
-    
+
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/AMQDeadlockTest3.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/AMQDeadlockTest3.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/AMQDeadlockTest3.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/AMQDeadlockTest3.java Wed Aug  8 11:56:59 2007
@@ -34,405 +34,383 @@
 import org.springframework.jms.core.MessageCreator;
 import org.springframework.jms.listener.DefaultMessageListenerContainer;
 
-
 public class AMQDeadlockTest3 extends TestCase {
     private static final transient Log log = LogFactory.getLog(AMQDeadlockTest3.class);
 
     private static final String URL1 = "tcp://localhost:61616";
 
-	private static final String URL2 = "tcp://localhost:61617";
+    private static final String URL2 = "tcp://localhost:61617";
+
+    private static final String QUEUE1_NAME = "test.queue.1";
+
+    private static final String QUEUE2_NAME = "test.queue.2";
+
+    private static final int MAX_CONSUMERS = 1;
+
+    private static final int MAX_PRODUCERS = 1;
+
+    private static final int NUM_MESSAGE_TO_SEND = 10;
+
+    private AtomicInteger messageCount = new AtomicInteger();
+    private CountDownLatch doneLatch;
+
+    public void setUp() throws Exception {
+    }
+
+    public void tearDown() throws Exception {
+    }
+
+    // This should fail with incubator-activemq-fuse-4.1.0.5
+    public void testQueueLimitsWithOneBrokerSameConnection() throws Exception {
+
+        BrokerService brokerService1 = null;
+        ActiveMQConnectionFactory acf = null;
+        PooledConnectionFactory pcf = null;
+        DefaultMessageListenerContainer container1 = null;
+
+        try {
+            brokerService1 = createBrokerService("broker1", URL1, null);
+            brokerService1.start();
+
+            acf = createConnectionFactory(URL1);
+            pcf = new PooledConnectionFactory(acf);
+
+            // Only listen on the first queue.. let the 2nd queue fill up.
+            doneLatch = new CountDownLatch(NUM_MESSAGE_TO_SEND);
+            container1 = createDefaultMessageListenerContainer(acf, new TestMessageListener1(500), QUEUE1_NAME);
+            container1.afterPropertiesSet();
+
+            Thread.sleep(2000);
+
+            final ExecutorService executor = Executors.newCachedThreadPool();
+            for (int i = 0; i < MAX_PRODUCERS; i++) {
+                executor.submit(new PooledProducerTask(pcf, QUEUE2_NAME));
+                Thread.sleep(1000);
+                executor.submit(new PooledProducerTask(pcf, QUEUE1_NAME));
+            }
+
+            // Wait for all message to arrive.
+            assertTrue(doneLatch.await(20, TimeUnit.SECONDS));
+            executor.shutdownNow();
+
+            Assert.assertEquals(NUM_MESSAGE_TO_SEND, messageCount.get());
+
+        } finally {
+
+            container1.stop();
+            container1.destroy();
+            container1 = null;
+            brokerService1.stop();
+            brokerService1 = null;
+
+        }
+
+    }
+
+    // This should fail with incubator-activemq-fuse-4.1.0.5
+    public void testQueueLimitsWithTwoBrokerProduceandConsumeonDifferentBrokersWithOneConnectionForProducing() throws Exception {
+
+        BrokerService brokerService1 = null;
+        BrokerService brokerService2 = null;
+        ActiveMQConnectionFactory acf1 = null;
+        ActiveMQConnectionFactory acf2 = null;
+        PooledConnectionFactory pcf = null;
+        DefaultMessageListenerContainer container1 = null;
+
+        try {
+            brokerService1 = createBrokerService("broker1", URL1, URL2);
+            brokerService1.start();
+            brokerService2 = createBrokerService("broker2", URL2, URL1);
+            brokerService2.start();
+
+            acf1 = createConnectionFactory(URL1);
+            acf2 = createConnectionFactory(URL2);
+
+            pcf = new PooledConnectionFactory(acf1);
+
+            Thread.sleep(1000);
+
+            doneLatch = new CountDownLatch(MAX_PRODUCERS * NUM_MESSAGE_TO_SEND);
+            container1 = createDefaultMessageListenerContainer(acf2, new TestMessageListener1(500), QUEUE1_NAME);
+            container1.afterPropertiesSet();
+
+            final ExecutorService executor = Executors.newCachedThreadPool();
+            for (int i = 0; i < MAX_PRODUCERS; i++) {
+                executor.submit(new PooledProducerTask(pcf, QUEUE2_NAME));
+                Thread.sleep(1000);
+                executor.submit(new PooledProducerTask(pcf, QUEUE1_NAME));
+            }
+
+            assertTrue(doneLatch.await(20, TimeUnit.SECONDS));
+            executor.shutdownNow();
+
+            Assert.assertEquals(MAX_PRODUCERS * NUM_MESSAGE_TO_SEND, messageCount.get());
+        } finally {
+
+            container1.stop();
+            container1.destroy();
+            container1 = null;
+
+            brokerService1.stop();
+            brokerService1 = null;
+            brokerService2.stop();
+            brokerService2 = null;
+        }
+    }
+
+    // This should fail with incubator-activemq-fuse-4.1.0.5
+    public void testQueueLimitsWithTwoBrokerProduceandConsumeonDifferentBrokersWithSeperateConnectionsForProducing() throws Exception {
+
+        BrokerService brokerService1 = null;
+        BrokerService brokerService2 = null;
+        ActiveMQConnectionFactory acf1 = null;
+        ActiveMQConnectionFactory acf2 = null;
+        DefaultMessageListenerContainer container1 = null;
+        DefaultMessageListenerContainer container2 = null;
+
+        try {
+            brokerService1 = createBrokerService("broker1", URL1, URL2);
+            brokerService1.start();
+            brokerService2 = createBrokerService("broker2", URL2, URL1);
+            brokerService2.start();
+
+            acf1 = createConnectionFactory(URL1);
+            acf2 = createConnectionFactory(URL2);
+
+            Thread.sleep(1000);
+
+            doneLatch = new CountDownLatch(NUM_MESSAGE_TO_SEND * MAX_PRODUCERS);
+
+            container1 = createDefaultMessageListenerContainer(acf2, new TestMessageListener1(500), QUEUE1_NAME);
+            container1.afterPropertiesSet();
+            container2 = createDefaultMessageListenerContainer(acf2, new TestMessageListener1(30000), QUEUE2_NAME);
+            container2.afterPropertiesSet();
+
+            final ExecutorService executor = Executors.newCachedThreadPool();
+            for (int i = 0; i < MAX_PRODUCERS; i++) {
+                executor.submit(new NonPooledProducerTask(acf1, QUEUE2_NAME));
+                Thread.sleep(1000);
+                executor.submit(new NonPooledProducerTask(acf1, QUEUE1_NAME));
+            }
+
+            assertTrue(doneLatch.await(20, TimeUnit.SECONDS));
+            executor.shutdownNow();
+
+            Assert.assertEquals(MAX_PRODUCERS * NUM_MESSAGE_TO_SEND, messageCount.get());
+        } finally {
+
+            container1.stop();
+            container1.destroy();
+            container1 = null;
+
+            container2.stop();
+            container2.destroy();
+            container2 = null;
+
+            brokerService1.stop();
+            brokerService1 = null;
+            brokerService2.stop();
+            brokerService2 = null;
+        }
+    }
+
+    private BrokerService createBrokerService(final String brokerName, final String uri1, final String uri2) throws Exception {
+        final BrokerService brokerService = new BrokerService();
+
+        brokerService.setBrokerName(brokerName);
+        brokerService.setPersistent(false);
+        brokerService.setUseJmx(true);
+
+        final UsageManager memoryManager = new UsageManager();
+        memoryManager.setLimit(5000000);
+        brokerService.setMemoryManager(memoryManager);
+
+        final ArrayList policyEntries = new ArrayList();
+
+        final PolicyEntry entry = new PolicyEntry();
+        entry.setQueue(">");
+        // entry.setQueue(QUEUE1_NAME);
+        entry.setMemoryLimit(1000);
+        policyEntries.add(entry);
+
+        final PolicyMap policyMap = new PolicyMap();
+        policyMap.setPolicyEntries(policyEntries);
+        brokerService.setDestinationPolicy(policyMap);
+
+        final TransportConnector tConnector = new TransportConnector();
+        tConnector.setUri(new URI(uri1));
+        tConnector.setBrokerName(brokerName);
+        tConnector.setName(brokerName + ".transportConnector");
+        brokerService.addConnector(tConnector);
+
+        if (uri2 != null) {
+            final NetworkConnector nc = new DiscoveryNetworkConnector(new URI("static:" + uri2));
+            nc.setBridgeTempDestinations(true);
+            nc.setBrokerName(brokerName);
+            brokerService.addNetworkConnector(nc);
+        }
+
+        return brokerService;
+
+    }
+
+    public DefaultMessageListenerContainer createDefaultMessageListenerContainer(final ConnectionFactory acf, final MessageListener listener, final String queue) {
+        final DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
+        container.setConnectionFactory(acf);
+        container.setDestinationName(queue);
+        container.setMessageListener(listener);
+        container.setSessionTransacted(false);
+        container.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
+        container.setConcurrentConsumers(MAX_CONSUMERS);
+        return container;
+    }
+
+    public ActiveMQConnectionFactory createConnectionFactory(final String url) {
+        final ActiveMQConnectionFactory acf = new ActiveMQConnectionFactory(url);
+        acf.setCopyMessageOnSend(false);
+        acf.setUseAsyncSend(false);
+        acf.setDispatchAsync(true);
+        acf.setUseCompression(false);
+        acf.setOptimizeAcknowledge(false);
+        acf.setOptimizedMessageDispatch(true);
+        acf.setAlwaysSyncSend(true);
+        return acf;
+    }
+
+    private class TestMessageListener1 implements MessageListener {
+
+        private final long waitTime;
+
+        public TestMessageListener1(long waitTime) {
+            this.waitTime = waitTime;
+
+        }
+
+        public void onMessage(Message msg) {
+
+            try {
+                log.info("Listener1 Consumed message " + msg.getIntProperty("count"));
+
+                messageCount.incrementAndGet();
+                doneLatch.countDown();
+
+                Thread.sleep(waitTime);
+            } catch (JMSException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            } catch (InterruptedException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+
+        }
+    }
+
+    private static class PooledProducerTask implements Runnable {
+
+        private final String queueName;
+
+        private final PooledConnectionFactory pcf;
+
+        public PooledProducerTask(final PooledConnectionFactory pcf, final String queueName) {
+            this.pcf = pcf;
+            this.queueName = queueName;
+        }
+
+        public void run() {
+
+            try {
+
+                final JmsTemplate jmsTemplate = new JmsTemplate(pcf);
+                jmsTemplate.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+                jmsTemplate.setExplicitQosEnabled(true);
+                jmsTemplate.setMessageIdEnabled(false);
+                jmsTemplate.setMessageTimestampEnabled(false);
+                jmsTemplate.afterPropertiesSet();
+
+                final byte[] bytes = new byte[2048];
+                final Random r = new Random();
+                r.nextBytes(bytes);
+
+                Thread.sleep(2000);
+
+                final AtomicInteger count = new AtomicInteger();
+                for (int i = 0; i < NUM_MESSAGE_TO_SEND; i++) {
+                    jmsTemplate.send(queueName, new MessageCreator() {
+
+                        public Message createMessage(Session session) throws JMSException {
+
+                            final BytesMessage message = session.createBytesMessage();
+
+                            message.writeBytes(bytes);
+                            message.setIntProperty("count", count.incrementAndGet());
+                            message.setStringProperty("producer", "pooled");
+                            return message;
+                        }
+                    });
+
+                    log.info("PooledProducer sent message: " + count.get());
+                    // Thread.sleep(1000);
+                }
+
+            } catch (final Throwable e) {
+                log.error("Producer 1 is exiting", e);
+            }
+        }
+    }
+
+    private static class NonPooledProducerTask implements Runnable {
+
+        private final String queueName;
+
+        private final ConnectionFactory cf;
+
+        public NonPooledProducerTask(final ConnectionFactory cf, final String queueName) {
+            this.cf = cf;
+            this.queueName = queueName;
+        }
+
+        public void run() {
+
+            try {
+
+                final JmsTemplate jmsTemplate = new JmsTemplate(cf);
+                jmsTemplate.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+                jmsTemplate.setExplicitQosEnabled(true);
+                jmsTemplate.setMessageIdEnabled(false);
+                jmsTemplate.setMessageTimestampEnabled(false);
+                jmsTemplate.afterPropertiesSet();
+
+                final byte[] bytes = new byte[2048];
+                final Random r = new Random();
+                r.nextBytes(bytes);
+
+                Thread.sleep(2000);
+
+                final AtomicInteger count = new AtomicInteger();
+                for (int i = 0; i < NUM_MESSAGE_TO_SEND; i++) {
+                    jmsTemplate.send(queueName, new MessageCreator() {
+
+                        public Message createMessage(Session session) throws JMSException {
+
+                            final BytesMessage message = session.createBytesMessage();
 
-	private static final String QUEUE1_NAME = "test.queue.1";
+                            message.writeBytes(bytes);
+                            message.setIntProperty("count", count.incrementAndGet());
+                            message.setStringProperty("producer", "non-pooled");
+                            return message;
+                        }
+                    });
 
-	private static final String QUEUE2_NAME = "test.queue.2";
+                    log.info("Non-PooledProducer sent message: " + count.get());
 
-	private static final int MAX_CONSUMERS = 1;
+                    // Thread.sleep(1000);
+                }
 
-	private static final int MAX_PRODUCERS = 1;
-
-	private static final int NUM_MESSAGE_TO_SEND = 10;
-
-	private AtomicInteger messageCount = new AtomicInteger();
-	private CountDownLatch doneLatch;
-
-	public void setUp() throws Exception {
-	}
-
-	public void tearDown() throws Exception {
-	}
-
-	// This should fail with incubator-activemq-fuse-4.1.0.5
-	public void testQueueLimitsWithOneBrokerSameConnection() throws Exception {
-
-		BrokerService brokerService1 = null;
-		ActiveMQConnectionFactory acf = null;
-		PooledConnectionFactory pcf = null;
-		DefaultMessageListenerContainer container1 = null;
-
-		try {
-			brokerService1 = createBrokerService("broker1", URL1, null);
-			brokerService1.start();
-
-			acf = createConnectionFactory(URL1);
-			pcf = new PooledConnectionFactory(acf);
-
-			// Only listen on the first queue.. let the 2nd queue fill up.
-			doneLatch = new CountDownLatch(NUM_MESSAGE_TO_SEND);
-			container1 = createDefaultMessageListenerContainer(acf,	new TestMessageListener1(500), QUEUE1_NAME);
-			container1.afterPropertiesSet();
-
-			Thread.sleep(2000);
-
-			final ExecutorService executor = Executors.newCachedThreadPool();
-			for (int i = 0; i < MAX_PRODUCERS; i++) {
-				executor.submit(new PooledProducerTask(pcf, QUEUE2_NAME));
-				Thread.sleep(1000);
-				executor.submit(new PooledProducerTask(pcf, QUEUE1_NAME));
-			}
-			
-			// Wait for all message to arrive.
-			assertTrue(doneLatch.await(20, TimeUnit.SECONDS));			
-			executor.shutdownNow();
-
-			Assert.assertEquals(NUM_MESSAGE_TO_SEND, messageCount.get());
-
-		} finally {
-
-			container1.stop();
-			container1.destroy();
-			container1 = null;
-			brokerService1.stop();
-			brokerService1 = null;
-
-		}
-
-	}
-	
-
-
-	
-	// This should fail with incubator-activemq-fuse-4.1.0.5
-	public void testQueueLimitsWithTwoBrokerProduceandConsumeonDifferentBrokersWithOneConnectionForProducing()
-			throws Exception {
-
-		BrokerService brokerService1 = null;
-		BrokerService brokerService2 = null;
-		ActiveMQConnectionFactory acf1 = null;
-		ActiveMQConnectionFactory acf2 = null;
-		PooledConnectionFactory pcf = null;
-		DefaultMessageListenerContainer container1 = null;
-
-		try {
-			brokerService1 = createBrokerService("broker1", URL1, URL2);
-			brokerService1.start();
-			brokerService2 = createBrokerService("broker2", URL2, URL1);
-			brokerService2.start();
-
-			acf1 = createConnectionFactory(URL1);
-			acf2 = createConnectionFactory(URL2);
-
-			pcf = new PooledConnectionFactory(acf1);
-
-			Thread.sleep(1000);
-
-			doneLatch = new CountDownLatch(MAX_PRODUCERS * NUM_MESSAGE_TO_SEND);
-			container1 = createDefaultMessageListenerContainer(acf2, new TestMessageListener1(500), QUEUE1_NAME);
-			container1.afterPropertiesSet();
-
-			final ExecutorService executor = Executors.newCachedThreadPool();
-			for (int i = 0; i < MAX_PRODUCERS; i++) {
-				executor.submit(new PooledProducerTask(pcf, QUEUE2_NAME));
-				Thread.sleep(1000);
-				executor.submit(new PooledProducerTask(pcf, QUEUE1_NAME));
-			}
-
-			assertTrue(doneLatch.await(20, TimeUnit.SECONDS));			
-			executor.shutdownNow();
-
-			Assert.assertEquals(MAX_PRODUCERS * NUM_MESSAGE_TO_SEND,
-					messageCount.get());
-		} finally {
-
-			container1.stop();
-			container1.destroy();
-			container1 = null;
-
-			brokerService1.stop();
-			brokerService1 = null;
-			brokerService2.stop();
-			brokerService2 = null;
-		}
-	}
-	
-	
-	// This should fail with incubator-activemq-fuse-4.1.0.5
-	public void testQueueLimitsWithTwoBrokerProduceandConsumeonDifferentBrokersWithSeperateConnectionsForProducing()
-			throws Exception {
-
-		BrokerService brokerService1 = null;
-		BrokerService brokerService2 = null;
-		ActiveMQConnectionFactory acf1 = null;
-		ActiveMQConnectionFactory acf2 = null;
-		DefaultMessageListenerContainer container1 = null;
-		DefaultMessageListenerContainer container2 = null;
-		
-		try {
-			brokerService1 = createBrokerService("broker1", URL1, URL2);
-			brokerService1.start();
-			brokerService2 = createBrokerService("broker2", URL2, URL1);
-			brokerService2.start();
-
-			acf1 = createConnectionFactory(URL1);
-			acf2 = createConnectionFactory(URL2);
-
-			Thread.sleep(1000);
-
-			doneLatch = new CountDownLatch(NUM_MESSAGE_TO_SEND*MAX_PRODUCERS);
-
-			container1 = createDefaultMessageListenerContainer(acf2, new TestMessageListener1(500), QUEUE1_NAME);
-			container1.afterPropertiesSet();
-			container2 = createDefaultMessageListenerContainer(acf2, new TestMessageListener1(30000), QUEUE2_NAME);
-			container2.afterPropertiesSet();
-
-			final ExecutorService executor = Executors.newCachedThreadPool();
-			for (int i = 0; i < MAX_PRODUCERS; i++) {
-				executor.submit(new NonPooledProducerTask(acf1, QUEUE2_NAME));
-				Thread.sleep(1000);
-				executor.submit(new NonPooledProducerTask(acf1, QUEUE1_NAME));
-			}
-
-			assertTrue(doneLatch.await(20, TimeUnit.SECONDS));			
-			executor.shutdownNow();
-
-			Assert.assertEquals(MAX_PRODUCERS * NUM_MESSAGE_TO_SEND, messageCount.get());
-		} finally {
-
-			container1.stop();
-			container1.destroy();
-			container1 = null;
-			
-			container2.stop();
-			container2.destroy();
-			container2 = null;
-
-			brokerService1.stop();
-			brokerService1 = null;
-			brokerService2.stop();
-			brokerService2 = null;
-		}
-	}
-
-
-
-
-	private BrokerService createBrokerService(final String brokerName,
-			final String uri1, final String uri2) throws Exception {
-		final BrokerService brokerService = new BrokerService();
-
-		brokerService.setBrokerName(brokerName);
-		brokerService.setPersistent(false);
-		brokerService.setUseJmx(true);
-
-		final UsageManager memoryManager = new UsageManager();
-		memoryManager.setLimit(5000000);
-		brokerService.setMemoryManager(memoryManager);
-
-		final ArrayList policyEntries = new ArrayList();
-
-		final PolicyEntry entry = new PolicyEntry();
-		entry.setQueue(">");
-		// entry.setQueue(QUEUE1_NAME);
-		entry.setMemoryLimit(1000);
-		policyEntries.add(entry);
-
-		final PolicyMap policyMap = new PolicyMap();
-		policyMap.setPolicyEntries(policyEntries);
-		brokerService.setDestinationPolicy(policyMap);
-
-		final TransportConnector tConnector = new TransportConnector();
-		tConnector.setUri(new URI(uri1));
-		tConnector.setBrokerName(brokerName);
-		tConnector.setName(brokerName + ".transportConnector");
-		brokerService.addConnector(tConnector);
-
-		if (uri2 != null) {
-			final NetworkConnector nc = new DiscoveryNetworkConnector(new URI("static:" + uri2));
-			nc.setBridgeTempDestinations(true);
-			nc.setBrokerName(brokerName);
-			brokerService.addNetworkConnector(nc);
-		}
-
-		return brokerService;
-
-	}
-
-	public DefaultMessageListenerContainer createDefaultMessageListenerContainer(
-			final ConnectionFactory acf, final MessageListener listener,
-			final String queue) {
-		final DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
-		container.setConnectionFactory(acf);
-		container.setDestinationName(queue);
-		container.setMessageListener(listener);
-		container.setSessionTransacted(false);
-		container.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
-		container.setConcurrentConsumers(MAX_CONSUMERS);
-		return container;
-	}
-
-	public ActiveMQConnectionFactory createConnectionFactory(final String url) {
-		final ActiveMQConnectionFactory acf = new ActiveMQConnectionFactory(url);
-		acf.setCopyMessageOnSend(false);
-		acf.setUseAsyncSend(false);
-		acf.setDispatchAsync(true);
-		acf.setUseCompression(false);
-		acf.setOptimizeAcknowledge(false);
-		acf.setOptimizedMessageDispatch(true);
-		acf.setAlwaysSyncSend(true);
-		return acf;
-	}
-
-	private class TestMessageListener1 implements MessageListener {
-
-		private final long waitTime;
-
-		public TestMessageListener1(long waitTime) {
-			this.waitTime = waitTime;
-		
-		}
-
-		public void onMessage(Message msg) {
-
-			try {
-				log.info("Listener1 Consumed message "+ msg.getIntProperty("count"));
-
-				messageCount.incrementAndGet();
-				doneLatch.countDown();
-				
-				Thread.sleep(waitTime);
-			} catch (JMSException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			} catch (InterruptedException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-
-		}
-	}
-
-
-	private static class PooledProducerTask implements Runnable {
-
-		private final String queueName;
-
-		private final PooledConnectionFactory pcf;
-
-		public PooledProducerTask(final PooledConnectionFactory pcf,
-				final String queueName) {
-			this.pcf = pcf;
-			this.queueName = queueName;
-		}
-
-		public void run() {
-
-			try {
-
-				final JmsTemplate jmsTemplate = new JmsTemplate(pcf);
-				jmsTemplate.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-				jmsTemplate.setExplicitQosEnabled(true);
-				jmsTemplate.setMessageIdEnabled(false);
-				jmsTemplate.setMessageTimestampEnabled(false);
-				jmsTemplate.afterPropertiesSet();
-
-				final byte[] bytes = new byte[2048];
-				final Random r = new Random();
-				r.nextBytes(bytes);
-
-				Thread.sleep(2000);
-
-				final AtomicInteger count = new AtomicInteger();
-				for (int i = 0; i < NUM_MESSAGE_TO_SEND; i++) {
-					jmsTemplate.send(queueName, new MessageCreator() {
-
-						public Message createMessage(Session session)
-								throws JMSException {
-
-							final BytesMessage message = session.createBytesMessage();
-
-							message.writeBytes(bytes);
-							message.setIntProperty("count", count.incrementAndGet());
-							message.setStringProperty("producer", "pooled");
-							return message;
-						}
-					});
-
-					log.info("PooledProducer sent message: "+ count.get());
-					// Thread.sleep(1000);
-				}
-
-			} catch (final Throwable e) {
-				log.error("Producer 1 is exiting", e);
-			}
-		}
-	}
-	
-	
-	private static class NonPooledProducerTask implements Runnable {
-
-		private final String queueName;
-
-		private final ConnectionFactory cf;
-
-		public NonPooledProducerTask(final ConnectionFactory cf,
-				final String queueName) {
-			this.cf = cf;
-			this.queueName = queueName;
-		}
-
-		public void run() {
-
-			try {
-
-				final JmsTemplate jmsTemplate = new JmsTemplate(cf);
-				jmsTemplate.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-				jmsTemplate.setExplicitQosEnabled(true);
-				jmsTemplate.setMessageIdEnabled(false);
-				jmsTemplate.setMessageTimestampEnabled(false);
-				jmsTemplate.afterPropertiesSet();
-
-				final byte[] bytes = new byte[2048];
-				final Random r = new Random();
-				r.nextBytes(bytes);
-
-				Thread.sleep(2000);
-
-				final AtomicInteger count = new AtomicInteger();
-				for (int i = 0; i < NUM_MESSAGE_TO_SEND; i++) {
-					jmsTemplate.send(queueName, new MessageCreator() {
-
-						public Message createMessage(Session session)
-								throws JMSException {
-
-							final BytesMessage message = session
-									.createBytesMessage();
-
-							message.writeBytes(bytes);
-							message.setIntProperty("count", count
-									.incrementAndGet());
-							message.setStringProperty("producer", "non-pooled");
-							return message;
-						}
-					});
-
-					log.info("Non-PooledProducer sent message: " + count.get());
-
-					// Thread.sleep(1000);
-				}
-
-			} catch (final Throwable e) {
-				log.error("Producer 1 is exiting", e);
-			}
-		}
-	}
+            } catch (final Throwable e) {
+                log.error("Producer 1 is exiting", e);
+            }
+        }
+    }
 
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java Wed Aug  8 11:56:59 2007
@@ -28,16 +28,16 @@
  * 
  * @version $Revision: 1.1.1.1 $
  */
-public class ActiveMQMessageAuditTest extends TestCase{
+public class ActiveMQMessageAuditTest extends TestCase {
 
-    public static void main(String[] args){
+    public static void main(String[] args) {
     }
 
-    protected void setUp() throws Exception{
+    protected void setUp() throws Exception {
         super.setUp();
     }
 
-    protected void tearDown() throws Exception{
+    protected void tearDown() throws Exception {
         super.tearDown();
     }
 
@@ -46,48 +46,48 @@
      * 
      * @param arg0
      */
-    public ActiveMQMessageAuditTest(String arg0){
+    public ActiveMQMessageAuditTest(String arg0) {
         super(arg0);
     }
 
     /**
      * test case for isDuplicate
      */
-    public void testIsDuplicateString(){
-        int count=10000;
-        ActiveMQMessageAudit audit=new ActiveMQMessageAudit();
-        IdGenerator idGen=new IdGenerator();
+    public void testIsDuplicateString() {
+        int count = 10000;
+        ActiveMQMessageAudit audit = new ActiveMQMessageAudit();
+        IdGenerator idGen = new IdGenerator();
         // add to a list
-        List<String> list=new ArrayList<String>();
-        for(int i=0;i<count;i++){
-            String id=idGen.generateId();
+        List<String> list = new ArrayList<String>();
+        for (int i = 0; i < count; i++) {
+            String id = idGen.generateId();
             list.add(id);
-            assertTrue(audit.isDuplicate(id)==false);
+            assertTrue(audit.isDuplicate(id) == false);
         }
-        for(String id:list){
+        for (String id : list) {
             assertTrue(audit.isDuplicate(id));
         }
     }
 
-    public void testIsDuplicateMessageReference(){
-        int count=10000;
-        ActiveMQMessageAudit audit=new ActiveMQMessageAudit();
+    public void testIsDuplicateMessageReference() {
+        int count = 10000;
+        ActiveMQMessageAudit audit = new ActiveMQMessageAudit();
         // add to a list
-        List<MessageReference> list=new ArrayList<MessageReference>();
-        for(int i=0;i<count;i++){
-            ProducerId pid=new ProducerId();
+        List<MessageReference> list = new ArrayList<MessageReference>();
+        for (int i = 0; i < count; i++) {
+            ProducerId pid = new ProducerId();
             pid.setConnectionId("test");
             pid.setSessionId(0);
             pid.setValue(1);
-            MessageId id=new MessageId();
+            MessageId id = new MessageId();
             id.setProducerId(pid);
             id.setProducerSequenceId(i);
-            ActiveMQMessage msg=new ActiveMQMessage();
+            ActiveMQMessage msg = new ActiveMQMessage();
             msg.setMessageId(id);
             list.add(msg);
-            assertTrue(audit.isDuplicateMessageReference(msg)==false);
+            assertTrue(audit.isDuplicateMessageReference(msg) == false);
         }
-        for(MessageReference msg:list){
+        for (MessageReference msg : list) {
             assertTrue(audit.isDuplicateMessageReference(msg));
         }
     }



Mime
View raw message