activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r563982 [26/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/transport/vm/VMTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java Wed Aug  8 11:56:59 2007
@@ -39,111 +39,114 @@
 import org.apache.commons.logging.LogFactory;
 import java.util.concurrent.ConcurrentHashMap;
 
-
-public class VMTransportFactory extends TransportFactory{
+public class VMTransportFactory extends TransportFactory {
     private static final Log log = LogFactory.getLog(VMTransportFactory.class);
-    final public static ConcurrentHashMap brokers=new ConcurrentHashMap();
-    final public static ConcurrentHashMap connectors=new ConcurrentHashMap();
-    final public static ConcurrentHashMap servers=new ConcurrentHashMap();
+    final public static ConcurrentHashMap brokers = new ConcurrentHashMap();
+    final public static ConcurrentHashMap connectors = new ConcurrentHashMap();
+    final public static ConcurrentHashMap servers = new ConcurrentHashMap();
     BrokerFactoryHandler brokerFactoryHandler;
 
-    public Transport doConnect(URI location) throws Exception{
+    public Transport doConnect(URI location) throws Exception {
         return VMTransportServer.configure(doCompositeConnect(location));
     }
 
-    public Transport doCompositeConnect(URI location) throws Exception{
+    public Transport doCompositeConnect(URI location) throws Exception {
         URI brokerURI;
         String host;
         Map options;
-        boolean create=true;
-        CompositeData data=URISupport.parseComposite(location);
-        if(data.getComponents().length==1&&"broker".equals(data.getComponents()[0].getScheme())){
-            brokerURI=data.getComponents()[0];
-            CompositeData brokerData=URISupport.parseComposite(brokerURI);
-            host=(String) brokerData.getParameters().get("brokerName");
-            if(host==null)
-                host="localhost";
-            if(brokerData.getPath()!=null)
-                host=data.getPath();
-            options=data.getParameters();
-            location=new URI("vm://"+host);
-        }else{
-            // If using the less complex vm://localhost?broker.persistent=true form
-            try{
-                host=location.getHost();
-                options=URISupport.parseParamters(location);
-                String config=(String) options.remove("brokerConfig");
-                if(config!=null){
-                    brokerURI=new URI(config);
-                }else{
-                    Map brokerOptions=IntrospectionSupport.extractProperties(options,"broker.");
-                    brokerURI=new URI("broker://()/"+host+"?"+URISupport.createQueryString(brokerOptions));
+        boolean create = true;
+        CompositeData data = URISupport.parseComposite(location);
+        if (data.getComponents().length == 1 && "broker".equals(data.getComponents()[0].getScheme())) {
+            brokerURI = data.getComponents()[0];
+            CompositeData brokerData = URISupport.parseComposite(brokerURI);
+            host = (String)brokerData.getParameters().get("brokerName");
+            if (host == null)
+                host = "localhost";
+            if (brokerData.getPath() != null)
+                host = data.getPath();
+            options = data.getParameters();
+            location = new URI("vm://" + host);
+        } else {
+            // If using the less complex vm://localhost?broker.persistent=true
+            // form
+            try {
+                host = location.getHost();
+                options = URISupport.parseParamters(location);
+                String config = (String)options.remove("brokerConfig");
+                if (config != null) {
+                    brokerURI = new URI(config);
+                } else {
+                    Map brokerOptions = IntrospectionSupport.extractProperties(options, "broker.");
+                    brokerURI = new URI("broker://()/" + host + "?"
+                                        + URISupport.createQueryString(brokerOptions));
                 }
-                if( "false".equals(options.remove("create")) ) {
-                	create=false;
+                if ("false".equals(options.remove("create"))) {
+                    create = false;
                 }
-            }catch(URISyntaxException e1){
+            } catch (URISyntaxException e1) {
                 throw IOExceptionSupport.create(e1);
             }
-            location=new URI("vm://"+host);
+            location = new URI("vm://" + host);
         }
         if (host == null) {
             host = "localhost";
         }
-        VMTransportServer server=(VMTransportServer) servers.get(host);
+        VMTransportServer server = (VMTransportServer)servers.get(host);
         // validate the broker is still active
-        if(!validateBroker(host)||server==null){
-            BrokerService broker=null;
-            // Synchronize on the registry so that multiple concurrent threads 
-            // doing this do not think that the broker has not been created and cause multiple
+        if (!validateBroker(host) || server == null) {
+            BrokerService broker = null;
+            // Synchronize on the registry so that multiple concurrent threads
+            // doing this do not think that the broker has not been created and
+            // cause multiple
             // brokers to be started.
-            synchronized( BrokerRegistry.getInstance().getRegistryMutext() ) {
-                broker=BrokerRegistry.getInstance().lookup(host);
-                if(broker==null){
-                	if( !create ) {
-                		throw new IOException("Broker named '"+host+"' does not exist.");
-                	}
-                    try{
-                        if(brokerFactoryHandler!=null){
-                            broker=brokerFactoryHandler.createBroker(brokerURI);
-                        }else{
-                            broker=BrokerFactory.createBroker(brokerURI);
+            synchronized (BrokerRegistry.getInstance().getRegistryMutext()) {
+                broker = BrokerRegistry.getInstance().lookup(host);
+                if (broker == null) {
+                    if (!create) {
+                        throw new IOException("Broker named '" + host + "' does not exist.");
+                    }
+                    try {
+                        if (brokerFactoryHandler != null) {
+                            broker = brokerFactoryHandler.createBroker(brokerURI);
+                        } else {
+                            broker = BrokerFactory.createBroker(brokerURI);
                         }
                         broker.start();
-                    }catch(URISyntaxException e){
+                    } catch (URISyntaxException e) {
                         throw IOExceptionSupport.create(e);
                     }
-                    brokers.put(host,broker);
+                    brokers.put(host, broker);
                 }
-                
-                server=(VMTransportServer) servers.get(host);
-                if(server==null){
-                    server=(VMTransportServer) bind(location,true);
-                    TransportConnector connector=new TransportConnector(broker.getBroker(),server);
+
+                server = (VMTransportServer)servers.get(host);
+                if (server == null) {
+                    server = (VMTransportServer)bind(location, true);
+                    TransportConnector connector = new TransportConnector(broker.getBroker(), server);
                     connector.setUri(location);
-                    connector.setTaskRunnerFactory( broker.getTaskRunnerFactory() );
+                    connector.setTaskRunnerFactory(broker.getTaskRunnerFactory());
                     connector.start();
-                    connectors.put(host,connector);
+                    connectors.put(host, connector);
                 }
-                
+
             }
         }
-        
-        VMTransport vmtransport=server.connect();
-        IntrospectionSupport.setProperties(vmtransport,options);
-        Transport transport=vmtransport;
-        if(vmtransport.isMarshal()){
-            HashMap optionsCopy=new HashMap(options);
-            transport=new MarshallingTransportFilter(transport,createWireFormat(options),createWireFormat(optionsCopy));
+
+        VMTransport vmtransport = server.connect();
+        IntrospectionSupport.setProperties(vmtransport, options);
+        Transport transport = vmtransport;
+        if (vmtransport.isMarshal()) {
+            HashMap optionsCopy = new HashMap(options);
+            transport = new MarshallingTransportFilter(transport, createWireFormat(options),
+                                                       createWireFormat(optionsCopy));
         }
-        if(!options.isEmpty()){
-            throw new IllegalArgumentException("Invalid connect parameters: "+options);
+        if (!options.isEmpty()) {
+            throw new IllegalArgumentException("Invalid connect parameters: " + options);
         }
         return transport;
     }
 
-    public TransportServer doBind(String brokerId,URI location) throws IOException{
-        return bind(location,false);
+    public TransportServer doBind(String brokerId, URI location) throws IOException {
+        return bind(location, false);
     }
 
     /**
@@ -151,66 +154,67 @@
      * @return the TransportServer
      * @throws IOException
      */
-    private TransportServer bind(URI location,boolean dispose) throws IOException{
-        String host=location.getHost();
+    private TransportServer bind(URI location, boolean dispose) throws IOException {
+        String host = location.getHost();
         log.debug("binding to broker: " + host);
-        VMTransportServer server=new VMTransportServer(location,dispose);
-        Object currentBoundValue=servers.get(host);
-        if(currentBoundValue!=null){
-            throw new IOException("VMTransportServer already bound at: "+location);
+        VMTransportServer server = new VMTransportServer(location, dispose);
+        Object currentBoundValue = servers.get(host);
+        if (currentBoundValue != null) {
+            throw new IOException("VMTransportServer already bound at: " + location);
         }
-        servers.put(host,server);
+        servers.put(host, server);
         return server;
     }
 
-    public static void stopped(VMTransportServer server){
-        String host=server.getBindURI().getHost();
+    public static void stopped(VMTransportServer server) {
+        String host = server.getBindURI().getHost();
         servers.remove(host);
-        TransportConnector connector=(TransportConnector) connectors.remove(host);
-        if(connector!=null){
-            log.debug("Shutting down VM connectors for broker: "  +host);
+        TransportConnector connector = (TransportConnector)connectors.remove(host);
+        if (connector != null) {
+            log.debug("Shutting down VM connectors for broker: " + host);
             ServiceSupport.dispose(connector);
-            BrokerService broker=(BrokerService) brokers.remove(host);
-            if(broker!=null){
+            BrokerService broker = (BrokerService)brokers.remove(host);
+            if (broker != null) {
                 ServiceSupport.dispose(broker);
             }
         }
     }
 
-    public static void stopped(String host){
+    public static void stopped(String host) {
         servers.remove(host);
-        TransportConnector connector=(TransportConnector) connectors.remove(host);
-        if(connector!=null){
-            log.debug("Shutting down VM connectors for broker: "  +host);
+        TransportConnector connector = (TransportConnector)connectors.remove(host);
+        if (connector != null) {
+            log.debug("Shutting down VM connectors for broker: " + host);
             ServiceSupport.dispose(connector);
-            BrokerService broker=(BrokerService) brokers.remove(host);
-            if(broker!=null){
+            BrokerService broker = (BrokerService)brokers.remove(host);
+            if (broker != null) {
                 ServiceSupport.dispose(broker);
             }
         }
     }
 
-    public BrokerFactoryHandler getBrokerFactoryHandler(){
+    public BrokerFactoryHandler getBrokerFactoryHandler() {
         return brokerFactoryHandler;
     }
 
-    public void setBrokerFactoryHandler(BrokerFactoryHandler brokerFactoryHandler){
-        this.brokerFactoryHandler=brokerFactoryHandler;
+    public void setBrokerFactoryHandler(BrokerFactoryHandler brokerFactoryHandler) {
+        this.brokerFactoryHandler = brokerFactoryHandler;
     }
 
-    private boolean validateBroker(String host){
-        boolean result=true;
-        if(brokers.containsKey(host)||servers.containsKey(host)||connectors.containsKey(host)){
+    private boolean validateBroker(String host) {
+        boolean result = true;
+        if (brokers.containsKey(host) || servers.containsKey(host) || connectors.containsKey(host)) {
             // check the broker is still in the BrokerRegistry
-            TransportConnector connector=(TransportConnector) connectors.get(host);
-            if(BrokerRegistry.getInstance().lookup(host)==null||(connector!=null&&connector.getBroker().isStopped())){
-                result=false;
+            TransportConnector connector = (TransportConnector)connectors.get(host);
+            if (BrokerRegistry.getInstance().lookup(host) == null
+                || (connector != null && connector.getBroker().isStopped())) {
+                result = false;
                 // clean-up
                 brokers.remove(host);
                 servers.remove(host);
-                if(connector!=null){
+                if (connector != null) {
                     connectors.remove(host);
-                    if(connector!=null){
+                    if (connector != null) {
                         ServiceSupport.dispose(connector);
                     }
                 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportServer.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportServer.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportServer.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportServer.java Wed Aug  8 11:56:59 2007
@@ -31,33 +31,32 @@
 
 /**
  * Broker side of the VMTransport
- *
  */
 public class VMTransportServer implements TransportServer {
 
     private TransportAcceptListener acceptListener;
     private final URI location;
     private boolean disposed;
-    
+
     private final AtomicInteger connectionCount = new AtomicInteger(0);
     private final boolean disposeOnDisconnect;
 
     /**
      * @param location
-     * @param disposeOnDisconnect 
+     * @param disposeOnDisconnect
      */
     public VMTransportServer(URI location, boolean disposeOnDisconnect) {
         this.location = location;
-        this.disposeOnDisconnect=disposeOnDisconnect;
+        this.disposeOnDisconnect = disposeOnDisconnect;
     }
-    
+
     /**
-     *@return a pretty print of this
+     * @return a pretty print of this
      */
-    public String toString(){
-        return "VMTransportServer(" + location +")";
+    public String toString() {
+        return "VMTransportServer(" + location + ")";
     }
-    
+
     /**
      * @return new VMTransport
      * @throws IOException
@@ -65,34 +64,35 @@
     public VMTransport connect() throws IOException {
         TransportAcceptListener al;
         synchronized (this) {
-            if( disposed )
+            if (disposed)
                 throw new IOException("Server has been disposed.");
             al = acceptListener;
         }
-        if( al == null)
+        if (al == null)
             throw new IOException("Server TransportAcceptListener is null.");
-            
+
         connectionCount.incrementAndGet();
         VMTransport client = new VMTransport(location) {
             public void stop() throws Exception {
-                if( disposed )
+                if (disposed)
                     return;
                 super.stop();
-                if( connectionCount.decrementAndGet()==0 && disposeOnDisconnect ) {
+                if (connectionCount.decrementAndGet() == 0 && disposeOnDisconnect) {
                     VMTransportServer.this.stop();
                 }
             };
         };
-        
+
         VMTransport server = new VMTransport(location);
         client.setPeer(server);
         server.setPeer(client);
         al.onAccept(configure(server));
         return client;
     }
-    
+
     /**
      * Configure transport
+     * 
      * @param transport
      * @return the Transport
      */
@@ -102,14 +102,13 @@
         return transport;
     }
 
-
     /**
      * Set the Transport accept listener for new Connections
-     * @param acceptListener 
      * 
+     * @param acceptListener
      */
     synchronized public void setAcceptListener(TransportAcceptListener acceptListener) {
-        this.acceptListener = acceptListener;        
+        this.acceptListener = acceptListener;
     }
 
     public void start() throws IOException {
@@ -122,7 +121,7 @@
     public URI getConnectURI() {
         return location;
     }
-    
+
     public URI getBindURI() {
         return location;
     }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BitArray.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BitArray.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BitArray.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BitArray.java Wed Aug  8 11:56:59 2007
@@ -21,8 +21,8 @@
 import java.io.IOException;
 
 /**
- * Simple BitArray to enable setting multiple boolean values efficently Used instead of BitSet because BitSet does not
- * allow for efficent serialization.
+ * Simple BitArray to enable setting multiple boolean values efficently Used
+ * instead of BitSet because BitSet does not allow for efficent serialization.
  * Will store up to 64 boolean values
  * 
  * @version $Revision: 1.1.1.1 $
@@ -33,18 +33,26 @@
     static final int SHORT_SIZE = 16;
     static final int BYTE_SIZE = 8;
     private static final long[] BIT_VALUES = {0x0000000000000001L, 0x0000000000000002L, 0x0000000000000004L,
-                                              0x0000000000000008L, 0x0000000000000010L, 0x0000000000000020L, 0x0000000000000040L, 0x0000000000000080L,
-                                              0x0000000000000100L, 0x0000000000000200L, 0x0000000000000400L, 0x0000000000000800L, 0x0000000000001000L,
-                                              0x0000000000002000L, 0x0000000000004000L, 0x0000000000008000L, 0x0000000000010000L, 0x0000000000020000L,
-                                              0x0000000000040000L, 0x0000000000080000L, 0x0000000000100000L, 0x0000000000200000L, 0x0000000000400000L,
-                                              0x0000000000800000L, 0x0000000001000000L, 0x0000000002000000L, 0x0000000004000000L, 0x0000000008000000L,
-                                              0x0000000010000000L, 0x0000000020000000L, 0x0000000040000000L, 0x0000000080000000L, 0x0000000100000000L,
-                                              0x0000000200000000L, 0x0000000400000000L, 0x0000000800000000L, 0x0000001000000000L, 0x0000002000000000L,
-                                              0x0000004000000000L, 0x0000008000000000L, 0x0000010000000000L, 0x0000020000000000L, 0x0000040000000000L,
-                                              0x0000080000000000L, 0x0000100000000000L, 0x0000200000000000L, 0x0000400000000000L, 0x0000800000000000L,
-                                              0x0001000000000000L, 0x0002000000000000L, 0x0004000000000000L, 0x0008000000000000L, 0x0010000000000000L,
-                                              0x0020000000000000L, 0x0040000000000000L, 0x0080000000000000L, 0x0100000000000000L, 0x0200000000000000L,
-                                              0x0400000000000000L, 0x0800000000000000L, 0x1000000000000000L, 0x2000000000000000L, 0x4000000000000000L,
+                                              0x0000000000000008L, 0x0000000000000010L, 0x0000000000000020L,
+                                              0x0000000000000040L, 0x0000000000000080L, 0x0000000000000100L,
+                                              0x0000000000000200L, 0x0000000000000400L, 0x0000000000000800L,
+                                              0x0000000000001000L, 0x0000000000002000L, 0x0000000000004000L,
+                                              0x0000000000008000L, 0x0000000000010000L, 0x0000000000020000L,
+                                              0x0000000000040000L, 0x0000000000080000L, 0x0000000000100000L,
+                                              0x0000000000200000L, 0x0000000000400000L, 0x0000000000800000L,
+                                              0x0000000001000000L, 0x0000000002000000L, 0x0000000004000000L,
+                                              0x0000000008000000L, 0x0000000010000000L, 0x0000000020000000L,
+                                              0x0000000040000000L, 0x0000000080000000L, 0x0000000100000000L,
+                                              0x0000000200000000L, 0x0000000400000000L, 0x0000000800000000L,
+                                              0x0000001000000000L, 0x0000002000000000L, 0x0000004000000000L,
+                                              0x0000008000000000L, 0x0000010000000000L, 0x0000020000000000L,
+                                              0x0000040000000000L, 0x0000080000000000L, 0x0000100000000000L,
+                                              0x0000200000000000L, 0x0000400000000000L, 0x0000800000000000L,
+                                              0x0001000000000000L, 0x0002000000000000L, 0x0004000000000000L,
+                                              0x0008000000000000L, 0x0010000000000000L, 0x0020000000000000L,
+                                              0x0040000000000000L, 0x0080000000000000L, 0x0100000000000000L,
+                                              0x0200000000000000L, 0x0400000000000000L, 0x0800000000000000L,
+                                              0x1000000000000000L, 0x2000000000000000L, 0x4000000000000000L,
                                               0x8000000000000000L};
     private long bits;
     private int length;
@@ -65,7 +73,7 @@
 
     /**
      * set the boolean value at the index
-     *
+     * 
      * @param index
      * @param flag
      * @return the old value held at this index
@@ -75,8 +83,7 @@
         boolean oldValue = (bits & BIT_VALUES[index]) != 0;
         if (flag) {
             bits |= BIT_VALUES[index];
-        }
-        else if (oldValue) {
+        } else if (oldValue) {
             bits &= ~(BIT_VALUES[index]);
         }
         return oldValue;
@@ -89,47 +96,45 @@
     public boolean get(int index) {
         return (bits & BIT_VALUES[index]) != 0;
     }
-    
+
     /**
      * reset all the bit values to false
      */
-    public void reset(){
+    public void reset() {
         bits = 0;
     }
-    
+
     /**
      * reset all the bits to the value supplied
+     * 
      * @param bits
      */
-    public void reset(long bits){
+    public void reset(long bits) {
         this.bits = bits;
     }
 
     /**
      * write the bits to an output stream
-     *
+     * 
      * @param dataOut
      * @throws IOException
      */
     public void writeToStream(DataOutput dataOut) throws IOException {
         dataOut.writeByte(length);
         if (length <= BYTE_SIZE) {
-            dataOut.writeByte((int) bits);
-        }
-        else if (length <= SHORT_SIZE) {
-            dataOut.writeShort((short) bits);
-        }
-        else if (length <= INT_SIZE) {
-            dataOut.writeInt((int) bits);
-        }
-        else {
+            dataOut.writeByte((int)bits);
+        } else if (length <= SHORT_SIZE) {
+            dataOut.writeShort((short)bits);
+        } else if (length <= INT_SIZE) {
+            dataOut.writeInt((int)bits);
+        } else {
             dataOut.writeLong(bits);
         }
     }
 
     /**
      * read the bits from an input stream
-     *
+     * 
      * @param dataIn
      * @throws IOException
      */
@@ -137,15 +142,12 @@
         length = dataIn.readByte();
         if (length <= BYTE_SIZE) {
             bits = dataIn.readByte();
-        }
-        else if (length <= SHORT_SIZE) {
+        } else if (length <= SHORT_SIZE) {
             bits = dataIn.readShort();
-        }
-        else if (length <= INT_SIZE) {
-            bits=dataIn.readInt();
-        }
-        else {
+        } else if (length <= INT_SIZE) {
+            bits = dataIn.readInt();
+        } else {
             bits = dataIn.readLong();
         }
     }
-}
\ No newline at end of file
+}

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BitArrayBin.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BitArrayBin.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BitArrayBin.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BitArrayBin.java Wed Aug  8 11:56:59 2007
@@ -21,23 +21,24 @@
  * 
  * @version $Revision: 1.1.1.1 $
  */
-public class BitArrayBin{
+public class BitArrayBin {
 
     private LinkedList<BitArray> list;
     private int maxNumberOfArrays;
-    private int firstIndex=-1;
-    private int firstBin=-1;
+    private int firstIndex = -1;
+    private int firstBin = -1;
 
     /**
-     * Create a BitArrayBin to a certain window size (number of messages to keep)
+     * Create a BitArrayBin to a certain window size (number of messages to
+     * keep)
      * 
      * @param windowSize
      */
-    public BitArrayBin(int windowSize){
-        maxNumberOfArrays=((windowSize+1)/BitArray.LONG_SIZE)+1;
-        maxNumberOfArrays=Math.max(maxNumberOfArrays,1);
-        list=new LinkedList<BitArray>();
-        for(int i=0;i<maxNumberOfArrays;i++){
+    public BitArrayBin(int windowSize) {
+        maxNumberOfArrays = ((windowSize + 1) / BitArray.LONG_SIZE) + 1;
+        maxNumberOfArrays = Math.max(maxNumberOfArrays, 1);
+        list = new LinkedList<BitArray>();
+        for (int i = 0; i < maxNumberOfArrays; i++) {
             list.add(new BitArray());
         }
     }
@@ -49,13 +50,13 @@
      * @param value
      * @return true if set
      */
-    public boolean setBit(long index,boolean value){
-        boolean answer=true;
-        BitArray ba=getBitArray(index);
-        if(ba!=null){
-            int offset=getOffset(index);
-            if(offset>=0){
-                answer=ba.set(offset,value);
+    public boolean setBit(long index, boolean value) {
+        boolean answer = true;
+        BitArray ba = getBitArray(index);
+        if (ba != null) {
+            int offset = getOffset(index);
+            if (offset >= 0) {
+                answer = ba.set(offset, value);
             }
         }
         return answer;
@@ -67,18 +68,18 @@
      * @param index
      * @return true/false
      */
-    public boolean getBit(long index){
-        boolean answer=index>=firstIndex;
-        BitArray ba=getBitArray(index);
-        if(ba!=null){
-            int offset=getOffset(index);
-            if(offset>=0){
-                answer=ba.get(offset);
+    public boolean getBit(long index) {
+        boolean answer = index >= firstIndex;
+        BitArray ba = getBitArray(index);
+        if (ba != null) {
+            int offset = getOffset(index);
+            if (offset >= 0) {
+                answer = ba.get(offset);
                 return answer;
             }
-        }else{
+        } else {
             // gone passed range for previous bins so assume set
-            answer=true;
+            answer = true;
         }
         return answer;
     }
@@ -89,20 +90,20 @@
      * @param index
      * @return BitArray
      */
-    private BitArray getBitArray(long index){
-        int bin=getBin(index);
-        BitArray answer=null;
-        if(bin>=0){
-            if(firstIndex<0){
-                firstIndex=0;
+    private BitArray getBitArray(long index) {
+        int bin = getBin(index);
+        BitArray answer = null;
+        if (bin >= 0) {
+            if (firstIndex < 0) {
+                firstIndex = 0;
             }
-            if(bin>=list.size()){
+            if (bin >= list.size()) {
                 list.removeFirst();
-                firstIndex+=BitArray.LONG_SIZE;
+                firstIndex += BitArray.LONG_SIZE;
                 list.add(new BitArray());
-                bin=list.size()-1;
+                bin = list.size() - 1;
             }
-            answer=list.get(bin);
+            answer = list.get(bin);
         }
         return answer;
     }
@@ -113,12 +114,12 @@
      * @param index
      * @return the index of the bin
      */
-    private int getBin(long index){
-        int answer=0;
-        if(firstBin<0){
-            firstBin=0;
-        }else if(firstIndex>=0){
-            answer=(int)((index-firstIndex)/BitArray.LONG_SIZE);
+    private int getBin(long index) {
+        int answer = 0;
+        if (firstBin < 0) {
+            firstBin = 0;
+        } else if (firstIndex >= 0) {
+            answer = (int)((index - firstIndex) / BitArray.LONG_SIZE);
         }
         return answer;
     }
@@ -129,11 +130,11 @@
      * @param index
      * @return the relative offset into a bin
      */
-    private int getOffset(long index){
-        int answer=0;
-        if(firstIndex>=0){
-            answer=(int)((index-firstIndex)-(BitArray.LONG_SIZE*getBin(index)));
+    private int getOffset(long index) {
+        int answer = 0;
+        if (firstIndex >= 0) {
+            answer = (int)((index - firstIndex) - (BitArray.LONG_SIZE * getBin(index)));
         }
         return answer;
     }
-}
\ No newline at end of file
+}

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BrokerSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BrokerSupport.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BrokerSupport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/BrokerSupport.java Wed Aug  8 11:56:59 2007
@@ -24,7 +24,7 @@
 import org.apache.activemq.state.ProducerState;
 
 public class BrokerSupport {
-    
+
     /**
      * @param context
      * @param message
@@ -32,14 +32,16 @@
      * @throws Exception
      */
     static public void resend(final ConnectionContext context, Message message, ActiveMQDestination deadLetterDestination) throws Exception {
-        if(message.getOriginalDestination()!=null)
+        if (message.getOriginalDestination() != null) {
             message.setOriginalDestination(message.getDestination());
-        if(message.getOriginalTransactionId()!=null)
-            message.setOriginalTransactionId(message.getTransactionId());                            
+        }
+        if (message.getOriginalTransactionId() != null) {
+            message.setOriginalTransactionId(message.getTransactionId());
+        }
         message.setDestination(deadLetterDestination);
         message.setTransactionId(null);
-        boolean originalFlowControl=context.isProducerFlowControl();
-        try{
+        boolean originalFlowControl = context.isProducerFlowControl();
+        try {
             context.setProducerFlowControl(false);
             ProducerInfo info = new ProducerInfo();
             ProducerState state = new ProducerState(info);
@@ -47,8 +49,8 @@
             producerExchange.setProducerState(state);
             producerExchange.setMutable(true);
             producerExchange.setConnectionContext(context);
-            context.getBroker().send(producerExchange,message);
-        }finally{
+            context.getBroker().send(producerExchange, message);
+        } finally {
             context.setProducerFlowControl(originalFlowControl);
         }
     }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteArrayInputStream.java Wed Aug  8 11:56:59 2007
@@ -19,10 +19,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 
-
 /**
- * Very similar to the java.io.ByteArrayInputStream but this version 
- * is not thread safe.
+ * Very similar to the java.io.ByteArrayInputStream but this version is not
+ * thread safe.
  */
 public class ByteArrayInputStream extends InputStream {
 
@@ -34,19 +33,19 @@
     public ByteArrayInputStream(byte data[]) {
         this(data, 0, data.length);
     }
-    
+
     public ByteArrayInputStream(ByteSequence sequence) {
         this(sequence.getData(), sequence.getOffset(), sequence.getLength());
     }
 
     public ByteArrayInputStream(byte data[], int offset, int size) {
         this.buffer = data;
-        this.mark= this.pos = offset;        
-        this.limit = offset+size;
+        this.mark = this.pos = offset;
+        this.limit = offset + size;
     }
-    
+
     public int read() throws IOException {
-        if( pos < limit )
+        if (pos < limit)
             return buffer[pos++] & 0xff;
         else
             return -1;
@@ -55,10 +54,10 @@
     public int read(byte[] b) throws IOException {
         return read(b, 0, b.length);
     }
-    
+
     public int read(byte b[], int off, int len) {
         if (pos < limit) {
-            len = Math.min(len, limit-pos);
+            len = Math.min(len, limit - pos);
             if (len > 0) {
                 System.arraycopy(buffer, pos, b, off, len);
                 pos += len;
@@ -71,7 +70,7 @@
 
     public long skip(long len) throws IOException {
         if (pos < limit) {
-            len = Math.min(len, limit-pos);
+            len = Math.min(len, limit - pos);
             if (len > 0) {
                 pos += len;
             }
@@ -80,7 +79,7 @@
             return -1;
         }
     }
-    
+
     public int available() {
         return limit - pos;
     }
@@ -88,11 +87,11 @@
     public boolean markSupported() {
         return true;
     }
-    
+
     public void mark(int markpos) {
         mark = pos;
     }
-    
+
     public void reset() {
         pos = mark;
     }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteSequence.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteSequence.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteSequence.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteSequence.java Wed Aug  8 11:56:59 2007
@@ -18,7 +18,7 @@
 package org.apache.activemq.util;
 
 public class ByteSequence {
-	
+
     public byte[] data;
     public int offset;
     public int length;
@@ -26,41 +26,46 @@
     public ByteSequence(byte data[]) {
         this.data = data;
         this.offset = 0;
-        this.length = data.length;            
+        this.length = data.length;
     }
 
     public ByteSequence(byte data[], int offset, int length) {
         this.data = data;
         this.offset = offset;
-        this.length = length;            
+        this.length = length;
     }
-    
+
     public byte[] getData() {
         return data;
     }
+
     public int getLength() {
         return length;
     }
+
     public int getOffset() {
         return offset;
     }
-	public void setData(byte[] data) {
-		this.data = data;
-	}
-	public void setLength(int length) {
-		this.length = length;
-	}
-	public void setOffset(int offset) {
-		this.offset = offset;
-	}
-	
-	public void compact() {
-		if( length != data.length ) {
-			byte t[] = new byte[length];
-			System.arraycopy(data, offset, t, 0, length);
-			data=t;
-			offset=0;
-		}
-	}
+
+    public void setData(byte[] data) {
+        this.data = data;
+    }
+
+    public void setLength(int length) {
+        this.length = length;
+    }
+
+    public void setOffset(int offset) {
+        this.offset = offset;
+    }
+
+    public void compact() {
+        if (length != data.length) {
+            byte t[] = new byte[length];
+            System.arraycopy(data, offset, t, 0, length);
+            data = t;
+            offset = 0;
+        }
+    }
 
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteSequenceData.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteSequenceData.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteSequenceData.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/ByteSequenceData.java Wed Aug  8 11:56:59 2007
@@ -18,41 +18,38 @@
 
 import java.io.IOException;
 
-
 /**
  * Used to write and read primitives to and from a ByteSequence.
  */
 final public class ByteSequenceData {
-	
-	
+
     public static byte[] toByteArray(ByteSequence packet) {
-    	if( packet.offset==0 && packet.length == packet.data.length )
-    		return packet.data;
-    	
-    	byte rc[] = new byte[packet.length];
+        if (packet.offset == 0 && packet.length == packet.data.length)
+            return packet.data;
+
+        byte rc[] = new byte[packet.length];
         System.arraycopy(packet.data, packet.offset, rc, 0, packet.length);
         return rc;
-	}
+    }
 
     private static void spaceNeeded(ByteSequence packet, int i) {
-		assert packet.offset+i <= packet.length;
-	}
-    
+        assert packet.offset + i <= packet.length;
+    }
+
     public static int remaining(ByteSequence packet) {
-		return packet.length - packet.offset;
-	}
-    
-	public static int read(ByteSequence packet) {
-		return packet.data[packet.offset++] & 0xff;
-	}
+        return packet.length - packet.offset;
+    }
 
+    public static int read(ByteSequence packet) {
+        return packet.data[packet.offset++] & 0xff;
+    }
 
     public static void readFully(ByteSequence packet, byte[] b) throws IOException {
         readFully(packet, b, 0, b.length);
     }
 
-    public static void readFully(ByteSequence packet, byte[] b, int off, int len) throws IOException {    	
-    	spaceNeeded(packet, len);        
+    public static void readFully(ByteSequence packet, byte[] b, int off, int len) throws IOException {
+        spaceNeeded(packet, len);
         System.arraycopy(packet.data, packet.offset, b, off, len);
         packet.offset += len;
     }
@@ -63,14 +60,14 @@
         return rc;
     }
 
-	public static boolean readBoolean(ByteSequence packet) throws IOException {
+    public static boolean readBoolean(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 1);
         return read(packet) != 0;
     }
 
-	public static byte readByte(ByteSequence packet) throws IOException {
+    public static byte readByte(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 1);
-        return (byte) read(packet);
+        return (byte)read(packet);
     }
 
     public static int readUnsignedByte(ByteSequence packet) throws IOException {
@@ -80,72 +77,60 @@
 
     public static short readShortBig(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 2);
-        return (short) ((read(packet) << 8) + (read(packet) << 0));
+        return (short)((read(packet) << 8) + (read(packet) << 0));
     }
+
     public static short readShortLittle(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 2);
-        return (short) ((read(packet) << 0) + (read(packet) << 8) );
+        return (short)((read(packet) << 0) + (read(packet) << 8));
     }
 
     public static int readUnsignedShortBig(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 2);
         return ((read(packet) << 8) + (read(packet) << 0));
     }
+
     public static int readUnsignedShortLittle(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 2);
-        return ((read(packet) << 0) + (read(packet) << 8) );
+        return ((read(packet) << 0) + (read(packet) << 8));
     }
 
     public static char readCharBig(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 2);
-        return (char) ((read(packet) << 8) + (read(packet) << 0));
+        return (char)((read(packet) << 8) + (read(packet) << 0));
     }
+
     public static char readCharLittle(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 2);
-        return (char) ((read(packet) << 0) + (read(packet) << 8) );
+        return (char)((read(packet) << 0) + (read(packet) << 8));
     }
 
     public static int readIntBig(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 4);
-        return ((read(packet) << 24) + 
-                (read(packet) << 16) + 
-                (read(packet) << 8) + 
-                (read(packet) << 0));
-    }    
+        return ((read(packet) << 24) + (read(packet) << 16) + (read(packet) << 8) + (read(packet) << 0));
+    }
+
     public static int readIntLittle(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 4);
-        return ((read(packet) << 0) +
-                (read(packet) << 8) + 
-                (read(packet) << 16) + 
-                (read(packet) << 24));
-    }    
-    
+        return ((read(packet) << 0) + (read(packet) << 8) + (read(packet) << 16) + (read(packet) << 24));
+    }
+
     public static long readLongBig(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 8);
-        return (((long) read(packet) << 56) + 
-                ((long) read(packet) << 48) + 
-                ((long) read(packet) << 40) + 
-                ((long) read(packet) << 32) + 
-                ((long) read(packet) << 24) + 
-                ((read(packet)) << 16) + 
-                ((read(packet)) << 8) + 
-                ((read(packet)) << 0));
+        return (((long)read(packet) << 56) + ((long)read(packet) << 48) + ((long)read(packet) << 40) + ((long)read(packet) << 32) + ((long)read(packet) << 24)
+                + ((read(packet)) << 16) + ((read(packet)) << 8) + ((read(packet)) << 0));
     }
+
     public static long readLongLittle(ByteSequence packet) throws IOException {
         spaceNeeded(packet, 8);
-        return ((read(packet) << 0) +
-                (read(packet) << 8) + 
-                (read(packet) << 16) + 
-                ((long) read(packet) << 24) +
-                ((long) read(packet) << 32) + 
-                ((long) read(packet) << 40) + 
-                ((long) read(packet) << 48) + 
-                ((long) read(packet) << 56));                  
+        return ((read(packet) << 0) + (read(packet) << 8) + (read(packet) << 16) + ((long)read(packet) << 24) + ((long)read(packet) << 32) + ((long)read(packet) << 40)
+                + ((long)read(packet) << 48) + ((long)read(packet) << 56));
     }
-    
+
     public static double readDoubleBig(ByteSequence packet) throws IOException {
         return Double.longBitsToDouble(readLongBig(packet));
     }
+
     public static double readDoubleLittle(ByteSequence packet) throws IOException {
         return Double.longBitsToDouble(readLongLittle(packet));
     }
@@ -153,91 +138,104 @@
     public static float readFloatBig(ByteSequence packet) throws IOException {
         return Float.intBitsToFloat(readIntBig(packet));
     }
+
     public static float readFloatLittle(ByteSequence packet) throws IOException {
         return Float.intBitsToFloat(readIntLittle(packet));
     }
 
     public static void write(ByteSequence packet, int b) throws IOException {
         spaceNeeded(packet, 1);
-		packet.data[packet.offset++] = (byte) b;		
+        packet.data[packet.offset++] = (byte)b;
     }
-    
+
     public static void write(ByteSequence packet, byte[] b) throws IOException {
         write(packet, b, 0, b.length);
     }
+
     public static void write(ByteSequence packet, byte[] b, int off, int len) throws IOException {
         spaceNeeded(packet, len);
         System.arraycopy(b, off, packet.data, packet.offset, len);
         packet.offset += len;
     }
+
     public static void writeBoolean(ByteSequence packet, boolean v) throws IOException {
         spaceNeeded(packet, 1);
-        write(packet,v ? 1 : 0);
+        write(packet, v ? 1 : 0);
     }
+
     public static void writeByte(ByteSequence packet, int v) throws IOException {
         spaceNeeded(packet, 1);
-        write(packet,v);
+        write(packet, v);
     }
+
     public static void writeShortBig(ByteSequence packet, int v) throws IOException {
         spaceNeeded(packet, 2);
-        write(packet,(v >>> 8) & 0xFF);
-        write(packet,(v >>> 0) & 0xFF);
+        write(packet, (v >>> 8) & 0xFF);
+        write(packet, (v >>> 0) & 0xFF);
     }
+
     public static void writeShortLittle(ByteSequence packet, int v) throws IOException {
         spaceNeeded(packet, 2);
-        write(packet,(v >>> 0) & 0xFF);
-        write(packet,(v >>> 8) & 0xFF);
+        write(packet, (v >>> 0) & 0xFF);
+        write(packet, (v >>> 8) & 0xFF);
     }
+
     public static void writeCharBig(ByteSequence packet, int v) throws IOException {
         spaceNeeded(packet, 2);
-        write(packet,(v >>> 8) & 0xFF);
-        write(packet,(v >>> 0) & 0xFF);
+        write(packet, (v >>> 8) & 0xFF);
+        write(packet, (v >>> 0) & 0xFF);
     }
+
     public static void writeCharLittle(ByteSequence packet, int v) throws IOException {
         spaceNeeded(packet, 2);
-        write(packet,(v >>> 0) & 0xFF);
-        write(packet,(v >>> 8) & 0xFF);
+        write(packet, (v >>> 0) & 0xFF);
+        write(packet, (v >>> 8) & 0xFF);
     }
+
     public static void writeIntBig(ByteSequence packet, int v) throws IOException {
         spaceNeeded(packet, 4);
-        write(packet,(v >>> 24) & 0xFF);
-        write(packet,(v >>> 16) & 0xFF);
-        write(packet,(v >>> 8) & 0xFF);
-        write(packet,(v >>> 0) & 0xFF);
+        write(packet, (v >>> 24) & 0xFF);
+        write(packet, (v >>> 16) & 0xFF);
+        write(packet, (v >>> 8) & 0xFF);
+        write(packet, (v >>> 0) & 0xFF);
     }
+
     public static void writeIntLittle(ByteSequence packet, int v) throws IOException {
         spaceNeeded(packet, 4);
-        write(packet,(v >>> 0) & 0xFF);
-        write(packet,(v >>> 8) & 0xFF);
-        write(packet,(v >>> 16) & 0xFF);
-        write(packet,(v >>> 24) & 0xFF);
+        write(packet, (v >>> 0) & 0xFF);
+        write(packet, (v >>> 8) & 0xFF);
+        write(packet, (v >>> 16) & 0xFF);
+        write(packet, (v >>> 24) & 0xFF);
     }
+
     public static void writeLongBig(ByteSequence packet, long v) throws IOException {
         spaceNeeded(packet, 8);
-        write(packet,(int) (v >>> 56) & 0xFF);
-        write(packet,(int) (v >>> 48) & 0xFF);
-        write(packet,(int) (v >>> 40) & 0xFF);
-        write(packet,(int) (v >>> 32) & 0xFF);
-        write(packet,(int) (v >>> 24) & 0xFF);
-        write(packet,(int) (v >>> 16) & 0xFF);
-        write(packet,(int) (v >>> 8) & 0xFF);
-        write(packet,(int) (v >>> 0) & 0xFF);
+        write(packet, (int)(v >>> 56) & 0xFF);
+        write(packet, (int)(v >>> 48) & 0xFF);
+        write(packet, (int)(v >>> 40) & 0xFF);
+        write(packet, (int)(v >>> 32) & 0xFF);
+        write(packet, (int)(v >>> 24) & 0xFF);
+        write(packet, (int)(v >>> 16) & 0xFF);
+        write(packet, (int)(v >>> 8) & 0xFF);
+        write(packet, (int)(v >>> 0) & 0xFF);
     }
+
     public static void writeLongLittle(ByteSequence packet, long v) throws IOException {
         spaceNeeded(packet, 8);
-        write(packet,(int) (v >>> 0) & 0xFF);
-        write(packet,(int) (v >>> 8) & 0xFF);
-        write(packet,(int) (v >>> 16) & 0xFF);
-        write(packet,(int) (v >>> 24) & 0xFF);
-        write(packet,(int) (v >>> 32) & 0xFF);
-        write(packet,(int) (v >>> 40) & 0xFF);
-        write(packet,(int) (v >>> 48) & 0xFF);
-        write(packet,(int) (v >>> 56) & 0xFF);
+        write(packet, (int)(v >>> 0) & 0xFF);
+        write(packet, (int)(v >>> 8) & 0xFF);
+        write(packet, (int)(v >>> 16) & 0xFF);
+        write(packet, (int)(v >>> 24) & 0xFF);
+        write(packet, (int)(v >>> 32) & 0xFF);
+        write(packet, (int)(v >>> 40) & 0xFF);
+        write(packet, (int)(v >>> 48) & 0xFF);
+        write(packet, (int)(v >>> 56) & 0xFF);
     }
-    
+
     public static void writeDoubleBig(ByteSequence packet, double v) throws IOException {
         writeLongBig(packet, Double.doubleToLongBits(v));
     }
+
     public static void writeDoubleLittle(ByteSequence packet, double v) throws IOException {
         writeLongLittle(packet, Double.doubleToLongBits(v));
     }
@@ -245,13 +243,15 @@
     public static void writeFloatBig(ByteSequence packet, float v) throws IOException {
         writeIntBig(packet, Float.floatToIntBits(v));
     }
+
     public static void writeFloatLittle(ByteSequence packet, float v) throws IOException {
         writeIntLittle(packet, Float.floatToIntBits(v));
     }
-    
+
     public static void writeRawDoubleBig(ByteSequence packet, double v) throws IOException {
         writeLongBig(packet, Double.doubleToRawLongBits(v));
     }
+
     public static void writeRawDoubleLittle(ByteSequence packet, double v) throws IOException {
         writeLongLittle(packet, Double.doubleToRawLongBits(v));
     }
@@ -259,6 +259,7 @@
     public static void writeRawFloatBig(ByteSequence packet, float v) throws IOException {
         writeIntBig(packet, Float.floatToRawIntBits(v));
     }
+
     public static void writeRawFloatLittle(ByteSequence packet, float v) throws IOException {
         writeIntLittle(packet, Float.floatToRawIntBits(v));
     }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/DataByteArrayInputStream.java Wed Aug  8 11:56:59 2007
@@ -21,12 +21,13 @@
 import java.io.InputStream;
 import java.io.UTFDataFormatException;
 import org.apache.activemq.util.ByteSequence;
+
 /**
  * Optimized ByteArrayInputStream that can be used more than once
  * 
  * @version $Revision: 1.1.1.1 $
  */
-public final class DataByteArrayInputStream extends InputStream implements DataInput{
+public final class DataByteArrayInputStream extends InputStream implements DataInput {
     private byte[] buf;
     private int pos;
     private int offset;
@@ -36,62 +37,64 @@
      * 
      * @param buf the input buffer.
      */
-    public DataByteArrayInputStream(byte buf[]){
-        this.buf=buf;
-        this.pos=0;
+    public DataByteArrayInputStream(byte buf[]) {
+        this.buf = buf;
+        this.pos = 0;
         this.offset = 0;
     }
-    
+
     /**
      * Creates a <code>StoreByteArrayInputStream</code>.
      * 
      * @param sequence the input buffer.
      */
-    public DataByteArrayInputStream(ByteSequence sequence){
-        this.buf=sequence.getData();
-        this.offset=this.pos=sequence.getOffset();
+    public DataByteArrayInputStream(ByteSequence sequence) {
+        this.buf = sequence.getData();
+        this.offset = this.pos = sequence.getOffset();
     }
 
     /**
-     * Creates <code>WireByteArrayInputStream</code> with a minmalist byte array
+     * Creates <code>WireByteArrayInputStream</code> with a minmalist byte
+     * array
      */
-    public DataByteArrayInputStream(){
+    public DataByteArrayInputStream() {
         this(new byte[0]);
     }
 
     /**
-     * 
      * @return the size
      */
-    public int size(){
-        return pos-offset;
+    public int size() {
+        return pos - offset;
     }
 
     /**
      * @return the underlying data array
      */
-    public byte[] getRawData(){
+    public byte[] getRawData() {
         return buf;
     }
 
     /**
-     * reset the <code>StoreByteArrayInputStream</code> to use an new byte array
+     * reset the <code>StoreByteArrayInputStream</code> to use an new byte
+     * array
      * 
      * @param newBuff
      */
-    public void restart(byte[] newBuff){
-        buf=newBuff;
-        pos=0;
-    }
-    
-    /**
-     * reset the <code>StoreByteArrayInputStream</code> to use an new ByteSequence
-     * @param sequence 
-     *  
-     */
-    public void restart(ByteSequence sequence){
-        this.buf=sequence.getData();
-        this.pos=sequence.getOffset();
+    public void restart(byte[] newBuff) {
+        buf = newBuff;
+        pos = 0;
+    }
+
+    /**
+     * reset the <code>StoreByteArrayInputStream</code> to use an new
+     * ByteSequence
+     * 
+     * @param sequence
+     */
+    public void restart(ByteSequence sequence) {
+        this.buf = sequence.getData();
+        this.pos = sequence.getOffset();
     }
 
     /**
@@ -99,165 +102,169 @@
      * 
      * @param size
      */
-    public void restart(int size){
-        if(buf==null||buf.length<size){
-            buf=new byte[size];
+    public void restart(int size) {
+        if (buf == null || buf.length < size) {
+            buf = new byte[size];
         }
         restart(buf);
     }
 
     /**
-     * Reads the next byte of data from this input stream. The value byte is returned as an <code>int</code> in the
-     * range <code>0</code> to <code>255</code>. If no byte is available because the end of the stream has been
-     * reached, the value <code>-1</code> is returned.
+     * Reads the next byte of data from this input stream. The value byte is
+     * returned as an <code>int</code> in the range <code>0</code> to
+     * <code>255</code>. If no byte is available because the end of the
+     * stream has been reached, the value <code>-1</code> is returned.
      * <p>
      * This <code>read</code> method cannot block.
      * 
-     * @return the next byte of data, or <code>-1</code> if the end of the stream has been reached.
+     * @return the next byte of data, or <code>-1</code> if the end of the
+     *         stream has been reached.
      */
-    public int read(){
-        return (pos<buf.length)?(buf[pos++]&0xff):-1;
+    public int read() {
+        return (pos < buf.length) ? (buf[pos++] & 0xff) : -1;
     }
 
     /**
-     * Reads up to <code>len</code> bytes of data into an array of bytes from this input stream.
+     * Reads up to <code>len</code> bytes of data into an array of bytes from
+     * this input stream.
      * 
      * @param b the buffer into which the data is read.
      * @param off the start offset of the data.
      * @param len the maximum number of bytes read.
-     * @return the total number of bytes read into the buffer, or <code>-1</code> if there is no more data because the
-     *         end of the stream has been reached.
+     * @return the total number of bytes read into the buffer, or
+     *         <code>-1</code> if there is no more data because the end of the
+     *         stream has been reached.
      */
-    public int read(byte b[],int off,int len){
-        if(b==null){
+    public int read(byte b[], int off, int len) {
+        if (b == null) {
             throw new NullPointerException();
         }
-        if(pos>=buf.length){
+        if (pos >= buf.length) {
             return -1;
         }
-        if(pos+len>buf.length){
-            len=buf.length-pos;
+        if (pos + len > buf.length) {
+            len = buf.length - pos;
         }
-        if(len<=0){
+        if (len <= 0) {
             return 0;
         }
-        System.arraycopy(buf,pos,b,off,len);
-        pos+=len;
+        System.arraycopy(buf, pos, b, off, len);
+        pos += len;
         return len;
     }
 
     /**
-     * @return the number of bytes that can be read from the input stream without blocking.
+     * @return the number of bytes that can be read from the input stream
+     *         without blocking.
      */
-    public int available(){
-        return buf.length-pos;
+    public int available() {
+        return buf.length - pos;
     }
 
-    public void readFully(byte[] b){
-        read(b,0,b.length);
+    public void readFully(byte[] b) {
+        read(b, 0, b.length);
     }
 
-    public void readFully(byte[] b,int off,int len){
-        read(b,off,len);
+    public void readFully(byte[] b, int off, int len) {
+        read(b, off, len);
     }
 
-    public int skipBytes(int n){
-        if(pos+n>buf.length){
-            n=buf.length-pos;
+    public int skipBytes(int n) {
+        if (pos + n > buf.length) {
+            n = buf.length - pos;
         }
-        if(n<0){
+        if (n < 0) {
             return 0;
         }
-        pos+=n;
+        pos += n;
         return n;
     }
 
-    public boolean readBoolean(){
-        return read()!=0;
+    public boolean readBoolean() {
+        return read() != 0;
     }
 
-    public byte readByte(){
-        return (byte) read();
+    public byte readByte() {
+        return (byte)read();
     }
 
-    public int readUnsignedByte(){
+    public int readUnsignedByte() {
         return read();
     }
 
-    public short readShort(){
-        int ch1=read();
-        int ch2=read();
-        return (short) ((ch1<<8)+(ch2<<0));
+    public short readShort() {
+        int ch1 = read();
+        int ch2 = read();
+        return (short)((ch1 << 8) + (ch2 << 0));
     }
 
-    public int readUnsignedShort(){
-        int ch1=read();
-        int ch2=read();
-        return ((ch1<<8)+(ch2<<0));
+    public int readUnsignedShort() {
+        int ch1 = read();
+        int ch2 = read();
+        return ((ch1 << 8) + (ch2 << 0));
     }
 
-    public char readChar(){
-        int ch1=read();
-        int ch2=read();
-        return (char) ((ch1<<8)+(ch2<<0));
+    public char readChar() {
+        int ch1 = read();
+        int ch2 = read();
+        return (char)((ch1 << 8) + (ch2 << 0));
     }
 
-    public int readInt(){
-        int ch1=read();
-        int ch2=read();
-        int ch3=read();
-        int ch4=read();
-        return ((ch1<<24)+(ch2<<16)+(ch3<<8)+(ch4<<0));
+    public int readInt() {
+        int ch1 = read();
+        int ch2 = read();
+        int ch3 = read();
+        int ch4 = read();
+        return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
     }
 
-    public long readLong(){
-        return (((long) buf[pos++]<<56)+((long) (buf[pos++]&255)<<48)+((long) (buf[pos++]&255)<<40)
-                        +((long) (buf[pos++]&255)<<32)+((long) (buf[pos++]&255)<<24)+((buf[pos++]&255)<<16)
-                        +((buf[pos++]&255)<<8)+((buf[pos++]&255)<<0));
+    public long readLong() {
+        return (((long)buf[pos++] << 56) + ((long)(buf[pos++] & 255) << 48) + ((long)(buf[pos++] & 255) << 40) + ((long)(buf[pos++] & 255) << 32)
+                + ((long)(buf[pos++] & 255) << 24) + ((buf[pos++] & 255) << 16) + ((buf[pos++] & 255) << 8) + ((buf[pos++] & 255) << 0));
     }
 
-    public float readFloat() throws IOException{
+    public float readFloat() throws IOException {
         return Float.intBitsToFloat(readInt());
     }
 
-    public double readDouble() throws IOException{
+    public double readDouble() throws IOException {
         return Double.longBitsToDouble(readLong());
     }
 
-    public String readLine(){
-        int start=pos;
-        while(pos<buf.length){
-            int c=read();
-            if(c=='\n'){
+    public String readLine() {
+        int start = pos;
+        while (pos < buf.length) {
+            int c = read();
+            if (c == '\n') {
                 break;
             }
-            if(c=='\r'){
-                c=read();
-                if(c!='\n'&&c!=-1){
+            if (c == '\r') {
+                c = read();
+                if (c != '\n' && c != -1) {
                     pos--;
                 }
                 break;
             }
         }
-        return new String(buf,start,pos);
+        return new String(buf, start, pos);
     }
 
-    public String readUTF() throws IOException{
-        int length=readUnsignedShort();
-        char[] characters=new char[length];
-        int c,c2,c3;
-        int count=0;
-        int total=pos+length;
-        while(pos<total){
-            c=(int) buf[pos]&0xff;
-            if(c>127)
+    public String readUTF() throws IOException {
+        int length = readUnsignedShort();
+        char[] characters = new char[length];
+        int c, c2, c3;
+        int count = 0;
+        int total = pos + length;
+        while (pos < total) {
+            c = (int)buf[pos] & 0xff;
+            if (c > 127)
                 break;
             pos++;
-            characters[count++]=(char) c;
+            characters[count++] = (char)c;
         }
-        while(pos<total){
-            c=(int) buf[pos]&0xff;
-            switch(c>>4){
+        while (pos < total) {
+            c = (int)buf[pos] & 0xff;
+            switch (c >> 4) {
             case 0:
             case 1:
             case 2:
@@ -267,32 +274,32 @@
             case 6:
             case 7:
                 pos++;
-                characters[count++]=(char) c;
+                characters[count++] = (char)c;
                 break;
             case 12:
             case 13:
-                pos+=2;
-                if(pos>length)
+                pos += 2;
+                if (pos > length)
                     throw new UTFDataFormatException("bad string");
-                c2=(int) buf[pos-1];
-                if((c2&0xC0)!=0x80)
+                c2 = (int)buf[pos - 1];
+                if ((c2 & 0xC0) != 0x80)
                     throw new UTFDataFormatException("bad string");
-                characters[count++]=(char) (((c&0x1F)<<6)|(c2&0x3F));
+                characters[count++] = (char)(((c & 0x1F) << 6) | (c2 & 0x3F));
                 break;
             case 14:
-                pos+=3;
-                if(pos>length)
+                pos += 3;
+                if (pos > length)
                     throw new UTFDataFormatException("bad string");
-                c2=(int) buf[pos-2];
-                c3=(int) buf[pos-1];
-                if(((c2&0xC0)!=0x80)||((c3&0xC0)!=0x80))
+                c2 = (int)buf[pos - 2];
+                c3 = (int)buf[pos - 1];
+                if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80))
                     throw new UTFDataFormatException("bad string");
-                characters[count++]=(char) (((c&0x0F)<<12)|((c2&0x3F)<<6)|((c3&0x3F)<<0));
+                characters[count++] = (char)(((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0));
                 break;
             default:
                 throw new UTFDataFormatException("bad string");
             }
         }
-        return new String(characters,0,count);
+        return new String(characters, 0, count);
     }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/FactoryFinder.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/FactoryFinder.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/FactoryFinder.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/FactoryFinder.java Wed Aug  8 11:56:59 2007
@@ -20,10 +20,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
-
 import java.util.concurrent.ConcurrentHashMap;
 
-
 public class FactoryFinder {
 
     private final String path;
@@ -35,24 +33,21 @@
 
     /**
      * Creates a new instance of the given key
-     *
-     * @param key is the key to add to the path to find a text file
-     *            containing the factory name
+     * 
+     * @param key is the key to add to the path to find a text file containing
+     *                the factory name
      * @return a newly created instance
      */
-    public Object newInstance(String key)
-            throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException
-    {
+    public Object newInstance(String key) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException {
         return newInstance(key, null);
     }
 
-    public Object newInstance(String key, String propertyPrefix)
-            throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException
-    {
-        if (propertyPrefix == null)
+    public Object newInstance(String key, String propertyPrefix) throws IllegalAccessException, InstantiationException, IOException, ClassNotFoundException {
+        if (propertyPrefix == null) {
             propertyPrefix = "";
+        }
 
-        Class clazz = (Class) classMap.get(propertyPrefix + key);
+        Class clazz = (Class)classMap.get(propertyPrefix + key);
         if (clazz == null) {
             clazz = newInstance(doFindFactoryProperies(key), propertyPrefix);
             classMap.put(propertyPrefix + key, clazz);
@@ -71,8 +66,7 @@
         if (loader != null) {
             try {
                 clazz = loader.loadClass(className);
-            }
-            catch (ClassNotFoundException e) {
+            } catch (ClassNotFoundException e) {
                 // ignore
             }
         }
@@ -88,7 +82,8 @@
 
         // lets try the thread context class loader first
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        if (classLoader == null) classLoader = getClass().getClassLoader();
+        if (classLoader == null)
+            classLoader = getClass().getClassLoader();
         InputStream in = classLoader.getResourceAsStream(uri);
         if (in == null) {
             in = FactoryFinder.class.getClassLoader().getResourceAsStream(uri);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IdGenerator.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IdGenerator.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IdGenerator.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IdGenerator.java Wed Aug  8 11:56:59 2007
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 package org.apache.activemq.util;
+
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.util.logging.Level;
@@ -24,93 +25,95 @@
  * Generator for Globally unique Strings.
  */
 
-public class IdGenerator{
+public class IdGenerator {
 
-	private static final Logger log = Logger.getLogger(IdGenerator.class.getName());
-	private static final String UNIQUE_STUB;
-	private static int instanceCount;
+    private static final Logger log = Logger.getLogger(IdGenerator.class.getName());
+    private static final String UNIQUE_STUB;
+    private static int instanceCount;
     private static String hostName;
-	private String seed;
-	private long sequence;
-	
-	static {
-		String stub = "";
-		boolean canAccessSystemProps = true;
-		try{
-			SecurityManager sm = System.getSecurityManager();
-			if(sm != null){
-				sm.checkPropertiesAccess();
-			}
-		}catch(SecurityException se){
-			canAccessSystemProps = false;
-		}
-		
-		if ( canAccessSystemProps) {
-			try {
-				hostName = InetAddress.getLocalHost().getHostName();
-				ServerSocket ss = new ServerSocket(0);
-				stub="-" + ss.getLocalPort() + "-" + System.currentTimeMillis() + "-";
-				Thread.sleep(100);
-				ss.close();
-			}catch(Exception ioe){
-				log.log(Level.WARNING, "could not generate unique stub",ioe);
-			}
-		}else{
-            hostName="localhost";
-			stub = "-1-" +System.currentTimeMillis() +"-";
-		}
-		UNIQUE_STUB = stub;
-	}
-    
+    private String seed;
+    private long sequence;
+
+    static {
+        String stub = "";
+        boolean canAccessSystemProps = true;
+        try {
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null) {
+                sm.checkPropertiesAccess();
+            }
+        } catch (SecurityException se) {
+            canAccessSystemProps = false;
+        }
+
+        if (canAccessSystemProps) {
+            try {
+                hostName = InetAddress.getLocalHost().getHostName();
+                ServerSocket ss = new ServerSocket(0);
+                stub = "-" + ss.getLocalPort() + "-" + System.currentTimeMillis() + "-";
+                Thread.sleep(100);
+                ss.close();
+            } catch (Exception ioe) {
+                log.log(Level.WARNING, "could not generate unique stub", ioe);
+            }
+        } else {
+            hostName = "localhost";
+            stub = "-1-" + System.currentTimeMillis() + "-";
+        }
+        UNIQUE_STUB = stub;
+    }
+
     /**
-     * As we have to find the hostname as a side-affect of generating
-     * a unique stub, we allow it's easy retrevial here
+     * As we have to find the hostname as a side-affect of generating a unique
+     * stub, we allow it's easy retrevial here
+     * 
      * @return the local host name
      */
-    
-    public static String getHostName(){
+
+    public static String getHostName() {
         return hostName;
     }
-	
-	/**
-	 * Construct an IdGenerator
-	 *
-	 */
-	
-	public IdGenerator(String prefix){
-		synchronized(UNIQUE_STUB){
-			this.seed = prefix + UNIQUE_STUB +(instanceCount++) +":";
-		}
-	}
-    
-    public IdGenerator(){
+
+    /**
+     * Construct an IdGenerator
+     */
+
+    public IdGenerator(String prefix) {
+        synchronized (UNIQUE_STUB) {
+            this.seed = prefix + UNIQUE_STUB + (instanceCount++) + ":";
+        }
+    }
+
+    public IdGenerator() {
         this("ID:" + hostName);
     }
-	
-	/**
-	 * Generate a unqiue id
-	 * @return a unique id
-	 */
-	
-	public synchronized String generateId(){
-		return this.seed + (this.sequence++);
-	}
-    
+
+    /**
+     * Generate a unqiue id
+     * 
+     * @return a unique id
+     */
+
+    public synchronized String generateId() {
+        return this.seed + (this.sequence++);
+    }
+
     /**
      * Generate a unique ID - that is friendly for a URL or file system
+     * 
      * @return a unique id
      */
-    public String generateSanitizedId(){
+    public String generateSanitizedId() {
         String result = generateId();
         result = result.replace(':', '-');
         result = result.replace('_', '-');
         result = result.replace('.', '-');
         return result;
     }
-    
+
     /**
      * From a generated id - return the seed (i.e. minus the count)
-     *
+     * 
      * @param id the generated identifer
      * @return the seed
      */
@@ -127,7 +130,7 @@
 
     /**
      * From a generated id - return the generator count
-     *
+     * 
      * @param id
      * @return the count
      */
@@ -146,7 +149,7 @@
 
     /**
      * Does a proper compare on the ids
-     *
+     * 
      * @param id1
      * @param id2
      * @return 0 if equal else a positive if id1 is > id2 ...
@@ -161,7 +164,7 @@
             if (result == 0) {
                 long count1 = IdGenerator.getSequenceFromId(id1);
                 long count2 = IdGenerator.getSequenceFromId(id2);
-                result = (int) (count1 - count2);
+                result = (int)(count1 - count2);
             }
         }
         return result;

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/IntrospectionSupport.java Wed Aug  8 11:56:59 2007
@@ -34,19 +34,18 @@
 import java.util.Map.Entry;
 
 public class IntrospectionSupport {
-        
-	
+
     static public boolean getProperties(Object target, Map props, String optionPrefix) {
-    	
+
         boolean rc = false;
-        if( target == null )
+        if (target == null)
             throw new IllegalArgumentException("target was null.");
-        if( props == null )
+        if (props == null)
             throw new IllegalArgumentException("props was null.");
-        
-        if( optionPrefix == null )
-        	optionPrefix="";
-        
+
+        if (optionPrefix == null)
+            optionPrefix = "";
+
         Class clazz = target.getClass();
         Method[] methods = clazz.getMethods();
         for (int i = 0; i < methods.length; i++) {
@@ -54,47 +53,44 @@
             String name = method.getName();
             Class type = method.getReturnType();
             Class params[] = method.getParameterTypes();
-            if( name.startsWith("get") && params.length==0 && 
-            		type!=null && isSettableType(type)) {
+            if (name.startsWith("get") && params.length == 0 && type != null && isSettableType(type)) {
 
-            	try {
-            		
-            		Object value = method.invoke(target, new Object[]{});
-            		if( value == null )
-            			continue;
-            		
-            		String strValue = convertToString(value, type);
-            		if( strValue ==null )
-            			continue;
-            		
-                    name = name.substring(3,4).toLowerCase()+name.substring(4);
-                    props.put(optionPrefix+name, strValue);
+                try {
+
+                    Object value = method.invoke(target, new Object[] {});
+                    if (value == null)
+                        continue;
+
+                    String strValue = convertToString(value, type);
+                    if (strValue == null)
+                        continue;
+
+                    name = name.substring(3, 4).toLowerCase() + name.substring(4);
+                    props.put(optionPrefix + name, strValue);
                     rc = true;
-                    
-            	} catch ( Throwable ignore) {
-            	}
-            	
+
+                } catch (Throwable ignore) {
+                }
+
             }
         }
-        
+
         return rc;
     }
-	
-	
-	
+
     static public boolean setProperties(Object target, Map props, String optionPrefix) {
         boolean rc = false;
-        if( target == null )
+        if (target == null)
             throw new IllegalArgumentException("target was null.");
-        if( props == null )
+        if (props == null)
             throw new IllegalArgumentException("props was null.");
-        
+
         for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
-            String name = (String) iter.next();
-            if( name.startsWith(optionPrefix) ) {
+            String name = (String)iter.next();
+            if (name.startsWith(optionPrefix)) {
                 Object value = props.get(name);
                 name = name.substring(optionPrefix.length());
-                if( setProperty(target, name, value) ) {
+                if (setProperty(target, name, value)) {
                     iter.remove();
                     rc = true;
                 }
@@ -102,42 +98,42 @@
         }
         return rc;
     }
-    
+
     public static Map extractProperties(Map props, String optionPrefix) {
-        if( props == null )
+        if (props == null)
             throw new IllegalArgumentException("props was null.");
 
         HashMap rc = new HashMap(props.size());
-        
+
         for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
-            String name = (String) iter.next();
-            if( name.startsWith(optionPrefix) ) {
+            String name = (String)iter.next();
+            if (name.startsWith(optionPrefix)) {
                 Object value = props.get(name);
                 name = name.substring(optionPrefix.length());
                 rc.put(name, value);
                 iter.remove();
             }
         }
-        
+
         return rc;
     }
-          
+
     public static boolean setProperties(Object target, Map props) {
-    	boolean rc = false;
-    	
-        if( target == null )
+        boolean rc = false;
+
+        if (target == null)
             throw new IllegalArgumentException("target was null.");
-        if( props == null )
+        if (props == null)
             throw new IllegalArgumentException("props was null.");
-        
+
         for (Iterator iter = props.entrySet().iterator(); iter.hasNext();) {
-            Map.Entry entry = (Entry) iter.next();
-            if( setProperty(target, (String) entry.getKey(), entry.getValue()) ) {
+            Map.Entry entry = (Entry)iter.next();
+            if (setProperty(target, (String)entry.getKey(), entry.getValue())) {
                 iter.remove();
-                rc=true;
+                rc = true;
             }
         }
-        
+
         return rc;
     }
 
@@ -145,15 +141,16 @@
         try {
             Class clazz = target.getClass();
             Method setter = findSetterMethod(clazz, name);
-            if( setter == null )
+            if (setter == null)
                 return false;
-            
-            // If the type is null or it matches the needed type, just use the value directly
-            if( value == null || value.getClass()==setter.getParameterTypes()[0] ) {
-                setter.invoke(target, new Object[]{value});
+
+            // If the type is null or it matches the needed type, just use the
+            // value directly
+            if (value == null || value.getClass() == setter.getParameterTypes()[0]) {
+                setter.invoke(target, new Object[] {value});
             } else {
                 // We need to convert it
-                setter.invoke(target, new Object[]{ convert(value, setter.getParameterTypes()[0]) });
+                setter.invoke(target, new Object[] {convert(value, setter.getParameterTypes()[0])});
             }
             return true;
         } catch (Throwable ignore) {
@@ -163,11 +160,11 @@
 
     private static Object convert(Object value, Class type) throws URISyntaxException {
         PropertyEditor editor = PropertyEditorManager.findEditor(type);
-        if( editor != null ) { 
+        if (editor != null) {
             editor.setAsText(value.toString());
             return editor.getValue();
         }
-        if( type == URI.class ) {
+        if (type == URI.class) {
             return new URI(value.toString());
         }
         return null;
@@ -175,11 +172,11 @@
 
     private static String convertToString(Object value, Class type) throws URISyntaxException {
         PropertyEditor editor = PropertyEditorManager.findEditor(type);
-        if( editor != null ) { 
+        if (editor != null) {
             editor.setValue(value);
             return editor.getAsText();
         }
-        if( type == URI.class ) {
+        if (type == URI.class) {
             return ((URI)value).toString();
         }
         return null;
@@ -187,14 +184,12 @@
 
     private static Method findSetterMethod(Class clazz, String name) {
         // Build the method name.
-        name = "set"+name.substring(0,1).toUpperCase()+name.substring(1);
+        name = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
         Method[] methods = clazz.getMethods();
         for (int i = 0; i < methods.length; i++) {
             Method method = methods[i];
             Class params[] = method.getParameterTypes();
-            if( method.getName().equals(name) 
-                    && params.length==1
-                    && isSettableType(params[0])) {
+            if (method.getName().equals(name) && params.length == 1 && isSettableType(params[0])) {
                 return method;
             }
         }
@@ -202,11 +197,11 @@
     }
 
     private static boolean isSettableType(Class clazz) {
-        if( PropertyEditorManager.findEditor(clazz)!=null )
+        if (PropertyEditorManager.findEditor(clazz) != null)
             return true;
-        if( clazz == URI.class )
+        if (clazz == URI.class)
             return true;
-        if( clazz == Boolean.class )
+        if (clazz == Boolean.class)
             return true;
         return false;
     }
@@ -223,11 +218,10 @@
         Set entrySet = map.entrySet();
         boolean first = true;
         for (Iterator iter = entrySet.iterator(); iter.hasNext();) {
-            Map.Entry entry = (Map.Entry) iter.next();
+            Map.Entry entry = (Map.Entry)iter.next();
             if (first) {
                 first = false;
-            }
-            else {
+            } else {
                 buffer.append(", ");
             }
             buffer.append(entry.getKey());
@@ -240,10 +234,9 @@
 
     protected static void appendToString(StringBuffer buffer, Object value) {
         if (value instanceof ActiveMQDestination) {
-            ActiveMQDestination destination = (ActiveMQDestination) value;
+            ActiveMQDestination destination = (ActiveMQDestination)value;
             buffer.append(destination.getQualifiedName());
-        }
-        else {
+        } else {
             buffer.append(value);
         }
     }
@@ -251,33 +244,30 @@
     static public String simpleName(Class clazz) {
         String name = clazz.getName();
         int p = name.lastIndexOf(".");
-        if( p >= 0 ) {
-            name = name.substring(p+1);
+        if (p >= 0) {
+            name = name.substring(p + 1);
         }
         return name;
     }
-    
 
     static private void addFields(Object target, Class startClass, Class stopClass, LinkedHashMap map) {
-        
-        if( startClass!=stopClass ) 
-            addFields( target, startClass.getSuperclass(), stopClass, map );
-        
+
+        if (startClass != stopClass)
+            addFields(target, startClass.getSuperclass(), stopClass, map);
+
         Field[] fields = startClass.getDeclaredFields();
         for (int i = 0; i < fields.length; i++) {
             Field field = fields[i];
-            if( Modifier.isStatic(field.getModifiers()) || 
-                Modifier.isTransient(field.getModifiers()) ||
-                Modifier.isPrivate(field.getModifiers())  ) {
+            if (Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers()) || Modifier.isPrivate(field.getModifiers())) {
                 continue;
             }
-            
+
             try {
                 field.setAccessible(true);
                 Object o = field.get(target);
-                if( o!=null && o.getClass().isArray() ) {
+                if (o != null && o.getClass().isArray()) {
                     try {
-                        o = Arrays.asList((Object[]) o);
+                        o = Arrays.asList((Object[])o);
                     } catch (Throwable e) {
                     }
                 }
@@ -286,8 +276,7 @@
                 e.printStackTrace();
             }
         }
-        
+
     }
 
-    
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/JMSExceptionSupport.java Wed Aug  8 11:56:59 2007
@@ -34,13 +34,13 @@
         exception.initCause(cause);
         return exception;
     }
-    
+
     public static JMSException create(Throwable cause) {
         if (cause instanceof JMSException) {
-            return (JMSException) cause;
+            return (JMSException)cause;
         }
         String msg = cause.getMessage();
-        if( msg==null || msg.length()==0 )
+        if (msg == null || msg.length() == 0)
             msg = cause.toString();
         JMSException exception = new JMSException(msg);
         exception.initCause(cause);
@@ -49,10 +49,10 @@
 
     public static JMSException create(Exception cause) {
         if (cause instanceof JMSException) {
-            return (JMSException) cause;
+            return (JMSException)cause;
         }
         String msg = cause.getMessage();
-        if( msg==null || msg.length()==0 )
+        if (msg == null || msg.length() == 0)
             msg = cause.toString();
         JMSException exception = new JMSException(msg);
         exception.setLinkedException(cause);
@@ -62,17 +62,17 @@
 
     public static MessageEOFException createMessageEOFException(Exception cause) {
         String msg = cause.getMessage();
-        if( msg==null || msg.length()==0 )
+        if (msg == null || msg.length() == 0)
             msg = cause.toString();
         MessageEOFException exception = new MessageEOFException(msg);
         exception.setLinkedException(cause);
         exception.initCause(cause);
         return exception;
     }
-    
+
     public static MessageFormatException createMessageFormatException(Exception cause) {
         String msg = cause.getMessage();
-        if( msg==null || msg.length()==0 )
+        if (msg == null || msg.length() == 0)
             msg = cause.toString();
         MessageFormatException exception = new MessageFormatException(msg);
         exception.setLinkedException(cause);



Mime
View raw message