activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r563982 [10/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/network/jms/JmsQueueConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsQueueConnector.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsQueueConnector.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsQueueConnector.java Wed Aug  8 11:56:59 2007
@@ -28,15 +28,16 @@
 import javax.jms.QueueSession;
 import javax.jms.Session;
 import javax.naming.NamingException;
+
 /**
  * A Bridge to other JMS Queue providers
  * 
  * @org.apache.xbean.XBean
- *
+ * 
  * @version $Revision: 1.1.1.1 $
  */
-public class JmsQueueConnector extends JmsConnector{
-    private static final Log log=LogFactory.getLog(JmsQueueConnector.class);
+public class JmsQueueConnector extends JmsConnector {
+    private static final Log log = LogFactory.getLog(JmsQueueConnector.class);
     private String outboundQueueConnectionFactoryName;
     private String localConnectionFactoryName;
     private QueueConnectionFactory outboundQueueConnectionFactory;
@@ -44,145 +45,138 @@
     private QueueConnection outboundQueueConnection;
     private QueueConnection localQueueConnection;
     private InboundQueueBridge[] inboundQueueBridges;
-    private OutboundQueueBridge[] outboundQueueBridges;   
+    private OutboundQueueBridge[] outboundQueueBridges;
 
-    public boolean init(){
-        boolean result=super.init();
-        if(result){
-            try{
+    public boolean init() {
+        boolean result = super.init();
+        if (result) {
+            try {
                 initializeForeignQueueConnection();
                 initializeLocalQueueConnection();
                 initializeInboundJmsMessageConvertor();
                 initializeOutboundJmsMessageConvertor();
                 initializeInboundQueueBridges();
                 initializeOutboundQueueBridges();
-            }catch(Exception e){
-                log.error("Failed to initialize the JMSConnector",e);
+            } catch (Exception e) {
+                log.error("Failed to initialize the JMSConnector", e);
             }
         }
         return result;
-    }   
-    
+    }
 
-    
     /**
      * @return Returns the inboundQueueBridges.
      */
-    public InboundQueueBridge[] getInboundQueueBridges(){
+    public InboundQueueBridge[] getInboundQueueBridges() {
         return inboundQueueBridges;
     }
 
     /**
-     * @param inboundQueueBridges
-     *            The inboundQueueBridges to set.
+     * @param inboundQueueBridges The inboundQueueBridges to set.
      */
-    public void setInboundQueueBridges(InboundQueueBridge[] inboundQueueBridges){
-        this.inboundQueueBridges=inboundQueueBridges;
+    public void setInboundQueueBridges(InboundQueueBridge[] inboundQueueBridges) {
+        this.inboundQueueBridges = inboundQueueBridges;
     }
 
     /**
      * @return Returns the outboundQueueBridges.
      */
-    public OutboundQueueBridge[] getOutboundQueueBridges(){
+    public OutboundQueueBridge[] getOutboundQueueBridges() {
         return outboundQueueBridges;
     }
 
     /**
-     * @param outboundQueueBridges
-     *            The outboundQueueBridges to set.
+     * @param outboundQueueBridges The outboundQueueBridges to set.
      */
-    public void setOutboundQueueBridges(OutboundQueueBridge[] outboundQueueBridges){
-        this.outboundQueueBridges=outboundQueueBridges;
+    public void setOutboundQueueBridges(OutboundQueueBridge[] outboundQueueBridges) {
+        this.outboundQueueBridges = outboundQueueBridges;
     }
 
     /**
      * @return Returns the localQueueConnectionFactory.
      */
-    public QueueConnectionFactory getLocalQueueConnectionFactory(){
+    public QueueConnectionFactory getLocalQueueConnectionFactory() {
         return localQueueConnectionFactory;
     }
 
     /**
-     * @param localQueueConnectionFactory
-     *            The localQueueConnectionFactory to set.
+     * @param localQueueConnectionFactory The localQueueConnectionFactory to
+     *                set.
      */
-    public void setLocalQueueConnectionFactory(QueueConnectionFactory localConnectionFactory){
-        this.localQueueConnectionFactory=localConnectionFactory;
+    public void setLocalQueueConnectionFactory(QueueConnectionFactory localConnectionFactory) {
+        this.localQueueConnectionFactory = localConnectionFactory;
     }
 
     /**
      * @return Returns the outboundQueueConnectionFactory.
      */
-    public QueueConnectionFactory getOutboundQueueConnectionFactory(){
+    public QueueConnectionFactory getOutboundQueueConnectionFactory() {
         return outboundQueueConnectionFactory;
     }
 
     /**
      * @return Returns the outboundQueueConnectionFactoryName.
      */
-    public String getOutboundQueueConnectionFactoryName(){
+    public String getOutboundQueueConnectionFactoryName() {
         return outboundQueueConnectionFactoryName;
     }
 
     /**
-     * @param outboundQueueConnectionFactoryName
-     *            The outboundQueueConnectionFactoryName to set.
+     * @param outboundQueueConnectionFactoryName The
+     *                outboundQueueConnectionFactoryName to set.
      */
-    public void setOutboundQueueConnectionFactoryName(String foreignQueueConnectionFactoryName){
-        this.outboundQueueConnectionFactoryName=foreignQueueConnectionFactoryName;
+    public void setOutboundQueueConnectionFactoryName(String foreignQueueConnectionFactoryName) {
+        this.outboundQueueConnectionFactoryName = foreignQueueConnectionFactoryName;
     }
 
     /**
      * @return Returns the localConnectionFactoryName.
      */
-    public String getLocalConnectionFactoryName(){
+    public String getLocalConnectionFactoryName() {
         return localConnectionFactoryName;
     }
 
     /**
-     * @param localConnectionFactoryName
-     *            The localConnectionFactoryName to set.
+     * @param localConnectionFactoryName The localConnectionFactoryName to set.
      */
-    public void setLocalConnectionFactoryName(String localConnectionFactoryName){
-        this.localConnectionFactoryName=localConnectionFactoryName;
+    public void setLocalConnectionFactoryName(String localConnectionFactoryName) {
+        this.localConnectionFactoryName = localConnectionFactoryName;
     }
 
     /**
      * @return Returns the localQueueConnection.
      */
-    public QueueConnection getLocalQueueConnection(){
+    public QueueConnection getLocalQueueConnection() {
         return localQueueConnection;
     }
 
     /**
-     * @param localQueueConnection
-     *            The localQueueConnection to set.
+     * @param localQueueConnection The localQueueConnection to set.
      */
-    public void setLocalQueueConnection(QueueConnection localQueueConnection){
-        this.localQueueConnection=localQueueConnection;
+    public void setLocalQueueConnection(QueueConnection localQueueConnection) {
+        this.localQueueConnection = localQueueConnection;
     }
 
     /**
      * @return Returns the outboundQueueConnection.
      */
-    public QueueConnection getOutboundQueueConnection(){
+    public QueueConnection getOutboundQueueConnection() {
         return outboundQueueConnection;
     }
 
     /**
-     * @param outboundQueueConnection
-     *            The outboundQueueConnection to set.
+     * @param outboundQueueConnection The outboundQueueConnection to set.
      */
-    public void setOutboundQueueConnection(QueueConnection foreignQueueConnection){
-        this.outboundQueueConnection=foreignQueueConnection;
+    public void setOutboundQueueConnection(QueueConnection foreignQueueConnection) {
+        this.outboundQueueConnection = foreignQueueConnection;
     }
 
     /**
-     * @param outboundQueueConnectionFactory
-     *            The outboundQueueConnectionFactory to set.
+     * @param outboundQueueConnectionFactory The outboundQueueConnectionFactory
+     *                to set.
      */
-    public void setOutboundQueueConnectionFactory(QueueConnectionFactory foreignQueueConnectionFactory){
-        this.outboundQueueConnectionFactory=foreignQueueConnectionFactory;
+    public void setOutboundQueueConnectionFactory(QueueConnectionFactory foreignQueueConnectionFactory) {
+        this.outboundQueueConnectionFactory = foreignQueueConnectionFactory;
     }
 
     public void restartProducerConnection() throws NamingException, JMSException {
@@ -190,91 +184,93 @@
         initializeForeignQueueConnection();
     }
 
-    protected void initializeForeignQueueConnection() throws NamingException,JMSException{
-        if(outboundQueueConnection==null){
+    protected void initializeForeignQueueConnection() throws NamingException, JMSException {
+        if (outboundQueueConnection == null) {
             // get the connection factories
-            if(outboundQueueConnectionFactory==null){
+            if (outboundQueueConnectionFactory == null) {
                 // look it up from JNDI
-                if(outboundQueueConnectionFactoryName!=null){
-                    outboundQueueConnectionFactory=(QueueConnectionFactory) jndiOutboundTemplate.lookup(
-                                    outboundQueueConnectionFactoryName,QueueConnectionFactory.class);
-                    if(outboundUsername!=null){
-                        outboundQueueConnection=outboundQueueConnectionFactory.createQueueConnection(outboundUsername,
-                                        outboundPassword);
-                    }else{
-                        outboundQueueConnection=outboundQueueConnectionFactory.createQueueConnection();
+                if (outboundQueueConnectionFactoryName != null) {
+                    outboundQueueConnectionFactory = (QueueConnectionFactory)jndiOutboundTemplate
+                        .lookup(outboundQueueConnectionFactoryName, QueueConnectionFactory.class);
+                    if (outboundUsername != null) {
+                        outboundQueueConnection = outboundQueueConnectionFactory
+                            .createQueueConnection(outboundUsername, outboundPassword);
+                    } else {
+                        outboundQueueConnection = outboundQueueConnectionFactory.createQueueConnection();
                     }
-                }else {
+                } else {
                     throw new JMSException("Cannot create localConnection - no information");
                 }
-            }else {
-                if(outboundUsername!=null){
-                    outboundQueueConnection=outboundQueueConnectionFactory.createQueueConnection(outboundUsername,
-                                    outboundPassword);
-                }else{
-                    outboundQueueConnection=outboundQueueConnectionFactory.createQueueConnection();
+            } else {
+                if (outboundUsername != null) {
+                    outboundQueueConnection = outboundQueueConnectionFactory
+                        .createQueueConnection(outboundUsername, outboundPassword);
+                } else {
+                    outboundQueueConnection = outboundQueueConnectionFactory.createQueueConnection();
                 }
             }
         }
         outboundQueueConnection.start();
     }
 
-    protected void initializeLocalQueueConnection() throws NamingException,JMSException{
-        if(localQueueConnection==null){
+    protected void initializeLocalQueueConnection() throws NamingException, JMSException {
+        if (localQueueConnection == null) {
             // get the connection factories
-            if(localQueueConnectionFactory==null){
-                if(embeddedConnectionFactory==null){
+            if (localQueueConnectionFactory == null) {
+                if (embeddedConnectionFactory == null) {
                     // look it up from JNDI
-                    if(localConnectionFactoryName!=null){
-                        localQueueConnectionFactory=(QueueConnectionFactory) jndiLocalTemplate.lookup(
-                                        localConnectionFactoryName,QueueConnectionFactory.class);
-                        if(localUsername!=null){
-                            localQueueConnection=localQueueConnectionFactory.createQueueConnection(localUsername,
-                                            localPassword);
-                        }else{
-                            localQueueConnection=localQueueConnectionFactory.createQueueConnection();
+                    if (localConnectionFactoryName != null) {
+                        localQueueConnectionFactory = (QueueConnectionFactory)jndiLocalTemplate
+                            .lookup(localConnectionFactoryName, QueueConnectionFactory.class);
+                        if (localUsername != null) {
+                            localQueueConnection = localQueueConnectionFactory
+                                .createQueueConnection(localUsername, localPassword);
+                        } else {
+                            localQueueConnection = localQueueConnectionFactory.createQueueConnection();
                         }
-                    }else {
+                    } else {
                         throw new JMSException("Cannot create localConnection - no information");
                     }
-                }else{
+                } else {
                     localQueueConnection = embeddedConnectionFactory.createQueueConnection();
                 }
-            }else {
-                if(localUsername!=null){
-                    localQueueConnection=localQueueConnectionFactory.createQueueConnection(localUsername,
-                                    localPassword);
-                }else{
-                    localQueueConnection=localQueueConnectionFactory.createQueueConnection();
+            } else {
+                if (localUsername != null) {
+                    localQueueConnection = localQueueConnectionFactory.createQueueConnection(localUsername,
+                                                                                             localPassword);
+                } else {
+                    localQueueConnection = localQueueConnectionFactory.createQueueConnection();
                 }
             }
         }
         localQueueConnection.start();
     }
-    
-    protected void initializeInboundJmsMessageConvertor(){
-    	inboundMessageConvertor.setConnection(localQueueConnection);
-    }
-    
-    protected void initializeOutboundJmsMessageConvertor(){
-    	outboundMessageConvertor.setConnection(outboundQueueConnection);
-    }
-
-    protected void initializeInboundQueueBridges() throws JMSException{
-        if(inboundQueueBridges!=null){
-            QueueSession outboundSession = outboundQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
-            QueueSession localSession = localQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
-            for(int i=0;i<inboundQueueBridges.length;i++){
-                InboundQueueBridge bridge=inboundQueueBridges[i];
-                String localQueueName=bridge.getLocalQueueName();
-                Queue activemqQueue=createActiveMQQueue(localSession,localQueueName);
+
+    protected void initializeInboundJmsMessageConvertor() {
+        inboundMessageConvertor.setConnection(localQueueConnection);
+    }
+
+    protected void initializeOutboundJmsMessageConvertor() {
+        outboundMessageConvertor.setConnection(outboundQueueConnection);
+    }
+
+    protected void initializeInboundQueueBridges() throws JMSException {
+        if (inboundQueueBridges != null) {
+            QueueSession outboundSession = outboundQueueConnection
+                .createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+            QueueSession localSession = localQueueConnection.createQueueSession(false,
+                                                                                Session.AUTO_ACKNOWLEDGE);
+            for (int i = 0; i < inboundQueueBridges.length; i++) {
+                InboundQueueBridge bridge = inboundQueueBridges[i];
+                String localQueueName = bridge.getLocalQueueName();
+                Queue activemqQueue = createActiveMQQueue(localSession, localQueueName);
                 String queueName = bridge.getInboundQueueName();
-                Queue foreignQueue=createForeignQueue(outboundSession,queueName);
+                Queue foreignQueue = createForeignQueue(outboundSession, queueName);
                 bridge.setConsumerQueue(foreignQueue);
                 bridge.setProducerQueue(activemqQueue);
                 bridge.setProducerConnection(localQueueConnection);
                 bridge.setConsumerConnection(outboundQueueConnection);
-                if(bridge.getJmsMessageConvertor()==null){
+                if (bridge.getJmsMessageConvertor() == null) {
                     bridge.setJmsMessageConvertor(getInboundMessageConvertor());
                 }
                 bridge.setJmsConnector(this);
@@ -285,21 +281,23 @@
         }
     }
 
-    protected void initializeOutboundQueueBridges() throws JMSException{
-        if(outboundQueueBridges!=null){
-            QueueSession outboundSession = outboundQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
-            QueueSession localSession = localQueueConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
-            for(int i=0;i<outboundQueueBridges.length;i++){
-                OutboundQueueBridge bridge=outboundQueueBridges[i];
-                String localQueueName=bridge.getLocalQueueName();              
-                Queue activemqQueue=createActiveMQQueue(localSession,localQueueName);
-                String queueName=bridge.getOutboundQueueName();
-                Queue foreignQueue=createForeignQueue(outboundSession,queueName);
+    protected void initializeOutboundQueueBridges() throws JMSException {
+        if (outboundQueueBridges != null) {
+            QueueSession outboundSession = outboundQueueConnection
+                .createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+            QueueSession localSession = localQueueConnection.createQueueSession(false,
+                                                                                Session.AUTO_ACKNOWLEDGE);
+            for (int i = 0; i < outboundQueueBridges.length; i++) {
+                OutboundQueueBridge bridge = outboundQueueBridges[i];
+                String localQueueName = bridge.getLocalQueueName();
+                Queue activemqQueue = createActiveMQQueue(localSession, localQueueName);
+                String queueName = bridge.getOutboundQueueName();
+                Queue foreignQueue = createForeignQueue(outboundSession, queueName);
                 bridge.setConsumerQueue(activemqQueue);
                 bridge.setProducerQueue(foreignQueue);
                 bridge.setProducerConnection(outboundQueueConnection);
                 bridge.setConsumerConnection(localQueueConnection);
-                if(bridge.getJmsMessageConvertor()==null){
+                if (bridge.getJmsMessageConvertor() == null) {
                     bridge.setJmsMessageConvertor(getOutboundMessageConvertor());
                 }
                 bridge.setJmsConnector(this);
@@ -309,90 +307,93 @@
             localSession.close();
         }
     }
-    
-    protected Destination createReplyToBridge(Destination destination, Connection replyToProducerConnection, Connection replyToConsumerConnection){        
-    	Queue replyToProducerQueue =(Queue)destination;
-    	boolean isInbound = replyToProducerConnection.equals(localQueueConnection);
-    	
-    	if(isInbound){
-    		InboundQueueBridge bridge = (InboundQueueBridge) replyToBridges.get(replyToProducerQueue);
-    		if (bridge == null){
-    			bridge = new InboundQueueBridge(){
-    				protected Destination processReplyToDestination (Destination destination){
-    					return null;
-    				}
-    			};
-    			try{
-    				QueueSession replyToConsumerSession = ((QueueConnection)replyToConsumerConnection).createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
-    				Queue replyToConsumerQueue = replyToConsumerSession.createTemporaryQueue();
-    				replyToConsumerSession.close();
-    				bridge.setConsumerQueue(replyToConsumerQueue);
-    				bridge.setProducerQueue(replyToProducerQueue);
-    				bridge.setProducerConnection((QueueConnection)replyToProducerConnection);
-    				bridge.setConsumerConnection((QueueConnection)replyToConsumerConnection);
-    				bridge.setDoHandleReplyTo(false);
-    				if(bridge.getJmsMessageConvertor()==null){
-    					bridge.setJmsMessageConvertor(getInboundMessageConvertor());
-    				}
-    				bridge.setJmsConnector(this);
-    				bridge.start();
-    				log.info("Created replyTo bridge for " + replyToProducerQueue);
-    			}catch(Exception e){
-    				log.error("Failed to create replyTo bridge for queue: " + replyToProducerQueue, e);
-    				return null;
-    			}
-    			replyToBridges.put(replyToProducerQueue, bridge);
-    		}
-    		return bridge.getConsumerQueue();
-    	}else{
-    		OutboundQueueBridge bridge = (OutboundQueueBridge) replyToBridges.get(replyToProducerQueue);
-    		if (bridge == null){
-    			bridge = new OutboundQueueBridge(){
-    				protected Destination processReplyToDestination (Destination destination){
-    					return null;
-    				}
-    			};
-    			try{
-    				QueueSession replyToConsumerSession = ((QueueConnection)replyToConsumerConnection).createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
-    				Queue replyToConsumerQueue = replyToConsumerSession.createTemporaryQueue();
-    				replyToConsumerSession.close();
-    				bridge.setConsumerQueue(replyToConsumerQueue);
-    				bridge.setProducerQueue(replyToProducerQueue);
-    				bridge.setProducerConnection((QueueConnection)replyToProducerConnection);
-    				bridge.setConsumerConnection((QueueConnection)replyToConsumerConnection);
-    				bridge.setDoHandleReplyTo(false);
-    				if(bridge.getJmsMessageConvertor()==null){
-    					bridge.setJmsMessageConvertor(getOutboundMessageConvertor());
-    				}
-    				bridge.setJmsConnector(this);
-    				bridge.start();
-    				log.info("Created replyTo bridge for " + replyToProducerQueue);
-    			}catch(Exception e){
-    				log.error("Failed to create replyTo bridge for queue: " + replyToProducerQueue, e);
-    				return null;
-    			}
-    			replyToBridges.put(replyToProducerQueue, bridge);
-    		}
-    		return bridge.getConsumerQueue();
-    	}		
+
+    protected Destination createReplyToBridge(Destination destination, Connection replyToProducerConnection,
+                                              Connection replyToConsumerConnection) {
+        Queue replyToProducerQueue = (Queue)destination;
+        boolean isInbound = replyToProducerConnection.equals(localQueueConnection);
+
+        if (isInbound) {
+            InboundQueueBridge bridge = (InboundQueueBridge)replyToBridges.get(replyToProducerQueue);
+            if (bridge == null) {
+                bridge = new InboundQueueBridge() {
+                    protected Destination processReplyToDestination(Destination destination) {
+                        return null;
+                    }
+                };
+                try {
+                    QueueSession replyToConsumerSession = ((QueueConnection)replyToConsumerConnection)
+                        .createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+                    Queue replyToConsumerQueue = replyToConsumerSession.createTemporaryQueue();
+                    replyToConsumerSession.close();
+                    bridge.setConsumerQueue(replyToConsumerQueue);
+                    bridge.setProducerQueue(replyToProducerQueue);
+                    bridge.setProducerConnection((QueueConnection)replyToProducerConnection);
+                    bridge.setConsumerConnection((QueueConnection)replyToConsumerConnection);
+                    bridge.setDoHandleReplyTo(false);
+                    if (bridge.getJmsMessageConvertor() == null) {
+                        bridge.setJmsMessageConvertor(getInboundMessageConvertor());
+                    }
+                    bridge.setJmsConnector(this);
+                    bridge.start();
+                    log.info("Created replyTo bridge for " + replyToProducerQueue);
+                } catch (Exception e) {
+                    log.error("Failed to create replyTo bridge for queue: " + replyToProducerQueue, e);
+                    return null;
+                }
+                replyToBridges.put(replyToProducerQueue, bridge);
+            }
+            return bridge.getConsumerQueue();
+        } else {
+            OutboundQueueBridge bridge = (OutboundQueueBridge)replyToBridges.get(replyToProducerQueue);
+            if (bridge == null) {
+                bridge = new OutboundQueueBridge() {
+                    protected Destination processReplyToDestination(Destination destination) {
+                        return null;
+                    }
+                };
+                try {
+                    QueueSession replyToConsumerSession = ((QueueConnection)replyToConsumerConnection)
+                        .createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+                    Queue replyToConsumerQueue = replyToConsumerSession.createTemporaryQueue();
+                    replyToConsumerSession.close();
+                    bridge.setConsumerQueue(replyToConsumerQueue);
+                    bridge.setProducerQueue(replyToProducerQueue);
+                    bridge.setProducerConnection((QueueConnection)replyToProducerConnection);
+                    bridge.setConsumerConnection((QueueConnection)replyToConsumerConnection);
+                    bridge.setDoHandleReplyTo(false);
+                    if (bridge.getJmsMessageConvertor() == null) {
+                        bridge.setJmsMessageConvertor(getOutboundMessageConvertor());
+                    }
+                    bridge.setJmsConnector(this);
+                    bridge.start();
+                    log.info("Created replyTo bridge for " + replyToProducerQueue);
+                } catch (Exception e) {
+                    log.error("Failed to create replyTo bridge for queue: " + replyToProducerQueue, e);
+                    return null;
+                }
+                replyToBridges.put(replyToProducerQueue, bridge);
+            }
+            return bridge.getConsumerQueue();
+        }
     }
-    
-    protected Queue createActiveMQQueue(QueueSession session,String queueName) throws JMSException{
+
+    protected Queue createActiveMQQueue(QueueSession session, String queueName) throws JMSException {
         return session.createQueue(queueName);
     }
-    
-    protected Queue createForeignQueue(QueueSession session,String queueName) throws JMSException{
+
+    protected Queue createForeignQueue(QueueSession session, String queueName) throws JMSException {
         Queue result = null;
-        try{
+        try {
             result = session.createQueue(queueName);
-        }catch(JMSException e){
-            //look-up the Queue
-            try{
-                result = (Queue) jndiOutboundTemplate.lookup(queueName, Queue.class);
-            }catch(NamingException e1){
+        } catch (JMSException e) {
+            // look-up the Queue
+            try {
+                result = (Queue)jndiOutboundTemplate.lookup(queueName, Queue.class);
+            } catch (NamingException e1) {
                 String errStr = "Failed to look-up Queue for name: " + queueName;
-                log.error(errStr,e);
-                JMSException jmsEx =  new JMSException(errStr);
+                log.error(errStr, e);
+                JMSException jmsEx = new JMSException(errStr);
                 jmsEx.setLinkedException(e1);
                 throw jmsEx;
             }
@@ -400,5 +401,4 @@
         return result;
     }
 
-    
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsTopicConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsTopicConnector.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsTopicConnector.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/JmsTopicConnector.java Wed Aug  8 11:56:59 2007
@@ -36,8 +36,8 @@
  * 
  * @version $Revision: 1.1.1.1 $
  */
-public class JmsTopicConnector extends JmsConnector{
-    private static final Log log=LogFactory.getLog(JmsTopicConnector.class);
+public class JmsTopicConnector extends JmsConnector {
+    private static final Log log = LogFactory.getLog(JmsTopicConnector.class);
     private String outboundTopicConnectionFactoryName;
     private String localConnectionFactoryName;
     private TopicConnectionFactory outboundTopicConnectionFactory;
@@ -46,237 +46,231 @@
     private TopicConnection localTopicConnection;
     private InboundTopicBridge[] inboundTopicBridges;
     private OutboundTopicBridge[] outboundTopicBridges;
-    
-    public boolean init(){
-        boolean result=super.init();
-        if(result){
-            try{
+
+    public boolean init() {
+        boolean result = super.init();
+        if (result) {
+            try {
                 initializeForeignTopicConnection();
                 initializeLocalTopicConnection();
                 initializeInboundJmsMessageConvertor();
                 initializeOutboundJmsMessageConvertor();
                 initializeInboundTopicBridges();
                 initializeOutboundTopicBridges();
-            }catch(Exception e){
-                log.error("Failed to initialize the JMSConnector",e);
+            } catch (Exception e) {
+                log.error("Failed to initialize the JMSConnector", e);
             }
         }
         return result;
-    }   
-    
+    }
 
-    
     /**
      * @return Returns the inboundTopicBridges.
      */
-    public InboundTopicBridge[] getInboundTopicBridges(){
+    public InboundTopicBridge[] getInboundTopicBridges() {
         return inboundTopicBridges;
     }
 
     /**
-     * @param inboundTopicBridges
-     *            The inboundTopicBridges to set.
+     * @param inboundTopicBridges The inboundTopicBridges to set.
      */
-    public void setInboundTopicBridges(InboundTopicBridge[] inboundTopicBridges){
-        this.inboundTopicBridges=inboundTopicBridges;
+    public void setInboundTopicBridges(InboundTopicBridge[] inboundTopicBridges) {
+        this.inboundTopicBridges = inboundTopicBridges;
     }
 
     /**
      * @return Returns the outboundTopicBridges.
      */
-    public OutboundTopicBridge[] getOutboundTopicBridges(){
+    public OutboundTopicBridge[] getOutboundTopicBridges() {
         return outboundTopicBridges;
     }
 
     /**
-     * @param outboundTopicBridges
-     *            The outboundTopicBridges to set.
+     * @param outboundTopicBridges The outboundTopicBridges to set.
      */
-    public void setOutboundTopicBridges(OutboundTopicBridge[] outboundTopicBridges){
-        this.outboundTopicBridges=outboundTopicBridges;
+    public void setOutboundTopicBridges(OutboundTopicBridge[] outboundTopicBridges) {
+        this.outboundTopicBridges = outboundTopicBridges;
     }
 
     /**
      * @return Returns the localTopicConnectionFactory.
      */
-    public TopicConnectionFactory getLocalTopicConnectionFactory(){
+    public TopicConnectionFactory getLocalTopicConnectionFactory() {
         return localTopicConnectionFactory;
     }
 
     /**
-     * @param localTopicConnectionFactory
-     *            The localTopicConnectionFactory to set.
+     * @param localTopicConnectionFactory The localTopicConnectionFactory to
+     *                set.
      */
-    public void setLocalTopicConnectionFactory(TopicConnectionFactory localConnectionFactory){
-        this.localTopicConnectionFactory=localConnectionFactory;
+    public void setLocalTopicConnectionFactory(TopicConnectionFactory localConnectionFactory) {
+        this.localTopicConnectionFactory = localConnectionFactory;
     }
 
     /**
      * @return Returns the outboundTopicConnectionFactory.
      */
-    public TopicConnectionFactory getOutboundTopicConnectionFactory(){
+    public TopicConnectionFactory getOutboundTopicConnectionFactory() {
         return outboundTopicConnectionFactory;
     }
 
     /**
      * @return Returns the outboundTopicConnectionFactoryName.
      */
-    public String getOutboundTopicConnectionFactoryName(){
+    public String getOutboundTopicConnectionFactoryName() {
         return outboundTopicConnectionFactoryName;
     }
 
     /**
-     * @param outboundTopicConnectionFactoryName
-     *            The outboundTopicConnectionFactoryName to set.
+     * @param outboundTopicConnectionFactoryName The
+     *                outboundTopicConnectionFactoryName to set.
      */
-    public void setOutboundTopicConnectionFactoryName(String foreignTopicConnectionFactoryName){
-        this.outboundTopicConnectionFactoryName=foreignTopicConnectionFactoryName;
+    public void setOutboundTopicConnectionFactoryName(String foreignTopicConnectionFactoryName) {
+        this.outboundTopicConnectionFactoryName = foreignTopicConnectionFactoryName;
     }
 
     /**
      * @return Returns the localConnectionFactoryName.
      */
-    public String getLocalConnectionFactoryName(){
+    public String getLocalConnectionFactoryName() {
         return localConnectionFactoryName;
     }
 
     /**
-     * @param localConnectionFactoryName
-     *            The localConnectionFactoryName to set.
+     * @param localConnectionFactoryName The localConnectionFactoryName to set.
      */
-    public void setLocalConnectionFactoryName(String localConnectionFactoryName){
-        this.localConnectionFactoryName=localConnectionFactoryName;
+    public void setLocalConnectionFactoryName(String localConnectionFactoryName) {
+        this.localConnectionFactoryName = localConnectionFactoryName;
     }
 
     /**
      * @return Returns the localTopicConnection.
      */
-    public TopicConnection getLocalTopicConnection(){
+    public TopicConnection getLocalTopicConnection() {
         return localTopicConnection;
     }
 
     /**
-     * @param localTopicConnection
-     *            The localTopicConnection to set.
+     * @param localTopicConnection The localTopicConnection to set.
      */
-    public void setLocalTopicConnection(TopicConnection localTopicConnection){
-        this.localTopicConnection=localTopicConnection;
+    public void setLocalTopicConnection(TopicConnection localTopicConnection) {
+        this.localTopicConnection = localTopicConnection;
     }
 
     /**
      * @return Returns the outboundTopicConnection.
      */
-    public TopicConnection getOutboundTopicConnection(){
+    public TopicConnection getOutboundTopicConnection() {
         return outboundTopicConnection;
     }
 
     /**
-     * @param outboundTopicConnection
-     *            The outboundTopicConnection to set.
+     * @param outboundTopicConnection The outboundTopicConnection to set.
      */
-    public void setOutboundTopicConnection(TopicConnection foreignTopicConnection){
-        this.outboundTopicConnection=foreignTopicConnection;
+    public void setOutboundTopicConnection(TopicConnection foreignTopicConnection) {
+        this.outboundTopicConnection = foreignTopicConnection;
     }
 
     /**
-     * @param outboundTopicConnectionFactory
-     *            The outboundTopicConnectionFactory to set.
+     * @param outboundTopicConnectionFactory The outboundTopicConnectionFactory
+     *                to set.
      */
-    public void setOutboundTopicConnectionFactory(TopicConnectionFactory foreignTopicConnectionFactory){
-        this.outboundTopicConnectionFactory=foreignTopicConnectionFactory;
+    public void setOutboundTopicConnectionFactory(TopicConnectionFactory foreignTopicConnectionFactory) {
+        this.outboundTopicConnectionFactory = foreignTopicConnectionFactory;
     }
 
-
     public void restartProducerConnection() throws NamingException, JMSException {
         outboundTopicConnection = null;
         initializeForeignTopicConnection();
     }
 
-    protected void initializeForeignTopicConnection() throws NamingException,JMSException{
-        if(outboundTopicConnection==null){
+    protected void initializeForeignTopicConnection() throws NamingException, JMSException {
+        if (outboundTopicConnection == null) {
             // get the connection factories
-            if(outboundTopicConnectionFactory==null){
+            if (outboundTopicConnectionFactory == null) {
                 // look it up from JNDI
-                if(outboundTopicConnectionFactoryName!=null){
-                    outboundTopicConnectionFactory=(TopicConnectionFactory) jndiOutboundTemplate.lookup(
-                                    outboundTopicConnectionFactoryName,TopicConnectionFactory.class);
-                    if(outboundUsername!=null){
-                        outboundTopicConnection=outboundTopicConnectionFactory.createTopicConnection(outboundUsername,
-                                        outboundPassword);
-                    }else{
-                        outboundTopicConnection=outboundTopicConnectionFactory.createTopicConnection();
+                if (outboundTopicConnectionFactoryName != null) {
+                    outboundTopicConnectionFactory = (TopicConnectionFactory)jndiOutboundTemplate
+                        .lookup(outboundTopicConnectionFactoryName, TopicConnectionFactory.class);
+                    if (outboundUsername != null) {
+                        outboundTopicConnection = outboundTopicConnectionFactory
+                            .createTopicConnection(outboundUsername, outboundPassword);
+                    } else {
+                        outboundTopicConnection = outboundTopicConnectionFactory.createTopicConnection();
                     }
-                }else {
+                } else {
                     throw new JMSException("Cannot create localConnection - no information");
                 }
-            }else {
-                if(outboundUsername!=null){
-                    outboundTopicConnection=outboundTopicConnectionFactory.createTopicConnection(outboundUsername,
-                                    outboundPassword);
-                }else{
-                    outboundTopicConnection=outboundTopicConnectionFactory.createTopicConnection();
+            } else {
+                if (outboundUsername != null) {
+                    outboundTopicConnection = outboundTopicConnectionFactory
+                        .createTopicConnection(outboundUsername, outboundPassword);
+                } else {
+                    outboundTopicConnection = outboundTopicConnectionFactory.createTopicConnection();
                 }
             }
         }
         outboundTopicConnection.start();
     }
 
-    protected void initializeLocalTopicConnection() throws NamingException,JMSException{
-        if(localTopicConnection==null){
+    protected void initializeLocalTopicConnection() throws NamingException, JMSException {
+        if (localTopicConnection == null) {
             // get the connection factories
-            if(localTopicConnectionFactory==null){
-                if(embeddedConnectionFactory==null){
+            if (localTopicConnectionFactory == null) {
+                if (embeddedConnectionFactory == null) {
                     // look it up from JNDI
-                    if(localConnectionFactoryName!=null){
-                        localTopicConnectionFactory=(TopicConnectionFactory) jndiLocalTemplate.lookup(
-                                        localConnectionFactoryName,TopicConnectionFactory.class);
-                        if(localUsername!=null){
-                            localTopicConnection=localTopicConnectionFactory.createTopicConnection(localUsername,
-                                            localPassword);
-                        }else{
-                            localTopicConnection=localTopicConnectionFactory.createTopicConnection();
+                    if (localConnectionFactoryName != null) {
+                        localTopicConnectionFactory = (TopicConnectionFactory)jndiLocalTemplate
+                            .lookup(localConnectionFactoryName, TopicConnectionFactory.class);
+                        if (localUsername != null) {
+                            localTopicConnection = localTopicConnectionFactory
+                                .createTopicConnection(localUsername, localPassword);
+                        } else {
+                            localTopicConnection = localTopicConnectionFactory.createTopicConnection();
                         }
-                    }else {
+                    } else {
                         throw new JMSException("Cannot create localConnection - no information");
                     }
-                }else{
+                } else {
                     localTopicConnection = embeddedConnectionFactory.createTopicConnection();
                 }
-            }else {
-                if(localUsername!=null){
-                    localTopicConnection=localTopicConnectionFactory.createTopicConnection(localUsername,
-                                    localPassword);
-                }else{
-                    localTopicConnection=localTopicConnectionFactory.createTopicConnection();
+            } else {
+                if (localUsername != null) {
+                    localTopicConnection = localTopicConnectionFactory.createTopicConnection(localUsername,
+                                                                                             localPassword);
+                } else {
+                    localTopicConnection = localTopicConnectionFactory.createTopicConnection();
                 }
             }
         }
         localTopicConnection.start();
     }
-    
-    protected void initializeInboundJmsMessageConvertor(){
-    	inboundMessageConvertor.setConnection(localTopicConnection);
-    }
-    
-    protected void initializeOutboundJmsMessageConvertor(){
-    	outboundMessageConvertor.setConnection(outboundTopicConnection);
-    }
-
-    protected void initializeInboundTopicBridges() throws JMSException{
-        if(inboundTopicBridges!=null){
-            TopicSession outboundSession = outboundTopicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
-            TopicSession localSession = localTopicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
-            for(int i=0;i<inboundTopicBridges.length;i++){
-                InboundTopicBridge bridge=inboundTopicBridges[i];
-                String localTopicName=bridge.getLocalTopicName();          
-                Topic activemqTopic=createActiveMQTopic(localSession,localTopicName);
-                String topicName=bridge.getInboundTopicName();
-                Topic foreignTopic=createForeignTopic(outboundSession,topicName);
+
+    protected void initializeInboundJmsMessageConvertor() {
+        inboundMessageConvertor.setConnection(localTopicConnection);
+    }
+
+    protected void initializeOutboundJmsMessageConvertor() {
+        outboundMessageConvertor.setConnection(outboundTopicConnection);
+    }
+
+    protected void initializeInboundTopicBridges() throws JMSException {
+        if (inboundTopicBridges != null) {
+            TopicSession outboundSession = outboundTopicConnection
+                .createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+            TopicSession localSession = localTopicConnection.createTopicSession(false,
+                                                                                Session.AUTO_ACKNOWLEDGE);
+            for (int i = 0; i < inboundTopicBridges.length; i++) {
+                InboundTopicBridge bridge = inboundTopicBridges[i];
+                String localTopicName = bridge.getLocalTopicName();
+                Topic activemqTopic = createActiveMQTopic(localSession, localTopicName);
+                String topicName = bridge.getInboundTopicName();
+                Topic foreignTopic = createForeignTopic(outboundSession, topicName);
                 bridge.setConsumerTopic(foreignTopic);
                 bridge.setProducerTopic(activemqTopic);
                 bridge.setProducerConnection(localTopicConnection);
                 bridge.setConsumerConnection(outboundTopicConnection);
-                if(bridge.getJmsMessageConvertor()==null){
+                if (bridge.getJmsMessageConvertor() == null) {
                     bridge.setJmsMessageConvertor(getInboundMessageConvertor());
                 }
                 bridge.setJmsConnector(this);
@@ -287,21 +281,23 @@
         }
     }
 
-    protected void initializeOutboundTopicBridges() throws JMSException{
-        if(outboundTopicBridges!=null){
-            TopicSession outboundSession = outboundTopicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
-            TopicSession localSession = localTopicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
-            for(int i=0;i<outboundTopicBridges.length;i++){
-                OutboundTopicBridge bridge=outboundTopicBridges[i];
-                String localTopicName=bridge.getLocalTopicName();
-                Topic activemqTopic=createActiveMQTopic(localSession,localTopicName);
-                String topicName=bridge.getOutboundTopicName();
-                Topic foreignTopic=createForeignTopic(outboundSession,topicName);
+    protected void initializeOutboundTopicBridges() throws JMSException {
+        if (outboundTopicBridges != null) {
+            TopicSession outboundSession = outboundTopicConnection
+                .createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+            TopicSession localSession = localTopicConnection.createTopicSession(false,
+                                                                                Session.AUTO_ACKNOWLEDGE);
+            for (int i = 0; i < outboundTopicBridges.length; i++) {
+                OutboundTopicBridge bridge = outboundTopicBridges[i];
+                String localTopicName = bridge.getLocalTopicName();
+                Topic activemqTopic = createActiveMQTopic(localSession, localTopicName);
+                String topicName = bridge.getOutboundTopicName();
+                Topic foreignTopic = createForeignTopic(outboundSession, topicName);
                 bridge.setConsumerTopic(activemqTopic);
                 bridge.setProducerTopic(foreignTopic);
                 bridge.setProducerConnection(outboundTopicConnection);
                 bridge.setConsumerConnection(localTopicConnection);
-                if(bridge.getJmsMessageConvertor()==null){
+                if (bridge.getJmsMessageConvertor() == null) {
                     bridge.setJmsMessageConvertor(getOutboundMessageConvertor());
                 }
                 bridge.setJmsConnector(this);
@@ -311,90 +307,93 @@
             localSession.close();
         }
     }
-    
-    protected  Destination createReplyToBridge(Destination destination, Connection replyToProducerConnection, Connection replyToConsumerConnection){
-    	Topic replyToProducerTopic =(Topic)destination;
-    	boolean isInbound = replyToProducerConnection.equals(localTopicConnection);
-    	
-    	if(isInbound){
-    		InboundTopicBridge bridge = (InboundTopicBridge) replyToBridges.get(replyToProducerTopic);
-    		if (bridge == null){
-    			bridge = new InboundTopicBridge(){
-    				protected Destination processReplyToDestination (Destination destination){
-    					return null;
-    				}
-    			};
-    			try{
-    				TopicSession replyToConsumerSession = ((TopicConnection)replyToConsumerConnection).createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
-    				Topic replyToConsumerTopic = replyToConsumerSession.createTemporaryTopic();
-    				replyToConsumerSession.close();
-    				bridge.setConsumerTopic(replyToConsumerTopic);
-    				bridge.setProducerTopic(replyToProducerTopic);
-    				bridge.setProducerConnection((TopicConnection)replyToProducerConnection);
-    				bridge.setConsumerConnection((TopicConnection)replyToConsumerConnection);
-    				bridge.setDoHandleReplyTo(false);
-    				if(bridge.getJmsMessageConvertor()==null){
-    					bridge.setJmsMessageConvertor(getInboundMessageConvertor());
-    				}
-    				bridge.setJmsConnector(this);
-    				bridge.start();
-    				log.info("Created replyTo bridge for " + replyToProducerTopic);
-    			}catch(Exception e){
-    				log.error("Failed to create replyTo bridge for topic: " + replyToProducerTopic, e);
-    				return null;
-    			}
-    			replyToBridges.put(replyToProducerTopic, bridge);
-    		}
-    		return bridge.getConsumerTopic();
-    	}else{
-    		OutboundTopicBridge bridge = (OutboundTopicBridge) replyToBridges.get(replyToProducerTopic);
-    		if (bridge == null){
-    			bridge = new OutboundTopicBridge(){
-    				protected Destination processReplyToDestination (Destination destination){
-    					return null;
-    				}
-    			};
-    			try{
-    				TopicSession replyToConsumerSession = ((TopicConnection)replyToConsumerConnection).createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
-    				Topic replyToConsumerTopic = replyToConsumerSession.createTemporaryTopic();
-    				replyToConsumerSession.close();
-    				bridge.setConsumerTopic(replyToConsumerTopic);
-    				bridge.setProducerTopic(replyToProducerTopic);
-    				bridge.setProducerConnection((TopicConnection)replyToProducerConnection);
-    				bridge.setConsumerConnection((TopicConnection)replyToConsumerConnection);
-    				bridge.setDoHandleReplyTo(false);
-    				if(bridge.getJmsMessageConvertor()==null){
-    					bridge.setJmsMessageConvertor(getOutboundMessageConvertor());
-    				}
-    				bridge.setJmsConnector(this);
-    				bridge.start();
-    				log.info("Created replyTo bridge for " + replyToProducerTopic);
-    			}catch(Exception e){
-    				log.error("Failed to create replyTo bridge for topic: " + replyToProducerTopic, e);
-    				return null;
-    			}
-    			replyToBridges.put(replyToProducerTopic, bridge);
-    		}
-    		return bridge.getConsumerTopic();
-    	}		
+
+    protected Destination createReplyToBridge(Destination destination, Connection replyToProducerConnection,
+                                              Connection replyToConsumerConnection) {
+        Topic replyToProducerTopic = (Topic)destination;
+        boolean isInbound = replyToProducerConnection.equals(localTopicConnection);
+
+        if (isInbound) {
+            InboundTopicBridge bridge = (InboundTopicBridge)replyToBridges.get(replyToProducerTopic);
+            if (bridge == null) {
+                bridge = new InboundTopicBridge() {
+                    protected Destination processReplyToDestination(Destination destination) {
+                        return null;
+                    }
+                };
+                try {
+                    TopicSession replyToConsumerSession = ((TopicConnection)replyToConsumerConnection)
+                        .createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+                    Topic replyToConsumerTopic = replyToConsumerSession.createTemporaryTopic();
+                    replyToConsumerSession.close();
+                    bridge.setConsumerTopic(replyToConsumerTopic);
+                    bridge.setProducerTopic(replyToProducerTopic);
+                    bridge.setProducerConnection((TopicConnection)replyToProducerConnection);
+                    bridge.setConsumerConnection((TopicConnection)replyToConsumerConnection);
+                    bridge.setDoHandleReplyTo(false);
+                    if (bridge.getJmsMessageConvertor() == null) {
+                        bridge.setJmsMessageConvertor(getInboundMessageConvertor());
+                    }
+                    bridge.setJmsConnector(this);
+                    bridge.start();
+                    log.info("Created replyTo bridge for " + replyToProducerTopic);
+                } catch (Exception e) {
+                    log.error("Failed to create replyTo bridge for topic: " + replyToProducerTopic, e);
+                    return null;
+                }
+                replyToBridges.put(replyToProducerTopic, bridge);
+            }
+            return bridge.getConsumerTopic();
+        } else {
+            OutboundTopicBridge bridge = (OutboundTopicBridge)replyToBridges.get(replyToProducerTopic);
+            if (bridge == null) {
+                bridge = new OutboundTopicBridge() {
+                    protected Destination processReplyToDestination(Destination destination) {
+                        return null;
+                    }
+                };
+                try {
+                    TopicSession replyToConsumerSession = ((TopicConnection)replyToConsumerConnection)
+                        .createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+                    Topic replyToConsumerTopic = replyToConsumerSession.createTemporaryTopic();
+                    replyToConsumerSession.close();
+                    bridge.setConsumerTopic(replyToConsumerTopic);
+                    bridge.setProducerTopic(replyToProducerTopic);
+                    bridge.setProducerConnection((TopicConnection)replyToProducerConnection);
+                    bridge.setConsumerConnection((TopicConnection)replyToConsumerConnection);
+                    bridge.setDoHandleReplyTo(false);
+                    if (bridge.getJmsMessageConvertor() == null) {
+                        bridge.setJmsMessageConvertor(getOutboundMessageConvertor());
+                    }
+                    bridge.setJmsConnector(this);
+                    bridge.start();
+                    log.info("Created replyTo bridge for " + replyToProducerTopic);
+                } catch (Exception e) {
+                    log.error("Failed to create replyTo bridge for topic: " + replyToProducerTopic, e);
+                    return null;
+                }
+                replyToBridges.put(replyToProducerTopic, bridge);
+            }
+            return bridge.getConsumerTopic();
+        }
     }
-    
-    protected Topic createActiveMQTopic(TopicSession session,String topicName) throws JMSException{
+
+    protected Topic createActiveMQTopic(TopicSession session, String topicName) throws JMSException {
         return session.createTopic(topicName);
     }
-    
-    protected Topic createForeignTopic(TopicSession session,String topicName) throws JMSException{
+
+    protected Topic createForeignTopic(TopicSession session, String topicName) throws JMSException {
         Topic result = null;
-        try{
+        try {
             result = session.createTopic(topicName);
-        }catch(JMSException e){
-            //look-up the Topic
-            try{
-                result = (Topic) jndiOutboundTemplate.lookup(topicName, Topic.class);
-            }catch(NamingException e1){
+        } catch (JMSException e) {
+            // look-up the Topic
+            try {
+                result = (Topic)jndiOutboundTemplate.lookup(topicName, Topic.class);
+            } catch (NamingException e1) {
                 String errStr = "Failed to look-up Topic for name: " + topicName;
-                log.error(errStr,e);
-                JMSException jmsEx =  new JMSException(errStr);
+                log.error(errStr, e);
+                JMSException jmsEx = new JMSException(errStr);
                 jmsEx.setLinkedException(e1);
                 throw jmsEx;
             }
@@ -402,5 +401,4 @@
         return result;
     }
 
-    
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/OutboundQueueBridge.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/OutboundQueueBridge.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/OutboundQueueBridge.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/OutboundQueueBridge.java Wed Aug  8 11:56:59 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.activemq.network.jms;
 
-
 /**
  * Create an Outbound Queue Bridge
  * 
@@ -24,54 +23,56 @@
  * 
  * @version $Revision: 1.1.1.1 $
  */
-public class OutboundQueueBridge extends QueueBridge{
-       
+public class OutboundQueueBridge extends QueueBridge {
+
     String outboundQueueName;
     String localQueueName;
+
     /**
      * Constructor that takes a foreign destination as an argument
+     * 
      * @param outboundQueueName
      */
-    public  OutboundQueueBridge(String  outboundQueueName){
+    public OutboundQueueBridge(String outboundQueueName) {
         this.outboundQueueName = outboundQueueName;
         this.localQueueName = outboundQueueName;
     }
-    
+
     /**
      * Default Contructor
      */
-    public  OutboundQueueBridge(){
+    public OutboundQueueBridge() {
     }
 
     /**
      * @return Returns the outboundQueueName.
      */
-    public String getOutboundQueueName(){
+    public String getOutboundQueueName() {
         return outboundQueueName;
     }
 
     /**
      * @param outboundQueueName The outboundQueueName to set.
      */
-    public void setOutboundQueueName(String outboundQueueName){
-        this.outboundQueueName=outboundQueueName;
-        if (this.localQueueName==null){
-            this.localQueueName=outboundQueueName;
+    public void setOutboundQueueName(String outboundQueueName) {
+        this.outboundQueueName = outboundQueueName;
+        if (this.localQueueName == null) {
+            this.localQueueName = outboundQueueName;
         }
     }
 
     /**
      * @return the localQueueName
      */
-    public String getLocalQueueName(){
+    public String getLocalQueueName() {
         return localQueueName;
     }
 
     /**
      * @param localQueueName the localQueueName to set
      */
-    public void setLocalQueueName(String localQueueName){
-        this.localQueueName=localQueueName;
+    public void setLocalQueueName(String localQueueName) {
+        this.localQueueName = localQueueName;
     }
-    
+
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/OutboundTopicBridge.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/OutboundTopicBridge.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/OutboundTopicBridge.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/OutboundTopicBridge.java Wed Aug  8 11:56:59 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.activemq.network.jms;
 
-
 /**
  * Create an Outbound Topic Bridge
  * 
@@ -24,54 +23,56 @@
  * 
  * @version $Revision: 1.1.1.1 $
  */
-public class OutboundTopicBridge extends TopicBridge{
-       
+public class OutboundTopicBridge extends TopicBridge {
+
     String outboundTopicName;
     String localTopicName;
+
     /**
      * Constructor that takes a foreign destination as an argument
+     * 
      * @param outboundTopicName
      */
-    public  OutboundTopicBridge(String  outboundTopicName){
+    public OutboundTopicBridge(String outboundTopicName) {
         this.outboundTopicName = outboundTopicName;
         this.localTopicName = outboundTopicName;
     }
-    
+
     /**
      * Default Contructor
      */
-    public  OutboundTopicBridge(){
+    public OutboundTopicBridge() {
     }
 
     /**
      * @return Returns the outboundTopicName.
      */
-    public String getOutboundTopicName(){
+    public String getOutboundTopicName() {
         return outboundTopicName;
     }
 
     /**
      * @param outboundTopicName The outboundTopicName to set.
      */
-    public void setOutboundTopicName(String outboundTopicName){
-        this.outboundTopicName=outboundTopicName;
-        if(this.localTopicName==null){
-            this.localTopicName=outboundTopicName;
+    public void setOutboundTopicName(String outboundTopicName) {
+        this.outboundTopicName = outboundTopicName;
+        if (this.localTopicName == null) {
+            this.localTopicName = outboundTopicName;
         }
     }
 
     /**
      * @return the localTopicName
      */
-    public String getLocalTopicName(){
+    public String getLocalTopicName() {
         return localTopicName;
     }
 
     /**
      * @param localTopicName the localTopicName to set
      */
-    public void setLocalTopicName(String localTopicName){
-        this.localTopicName=localTopicName;
+    public void setLocalTopicName(String localTopicName) {
+        this.localTopicName = localTopicName;
     }
-    
+
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/QueueBridge.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/QueueBridge.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/QueueBridge.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/QueueBridge.java Wed Aug  8 11:56:59 2007
@@ -28,141 +28,136 @@
 import javax.jms.QueueSession;
 import javax.jms.Session;
 import javax.jms.Topic;
+
 /**
  * A Destination bridge is used to bridge between to different JMS systems
  * 
  * @version $Revision: 1.1.1.1 $
  */
-class QueueBridge extends DestinationBridge{
+class QueueBridge extends DestinationBridge {
     protected Queue consumerQueue;
     protected Queue producerQueue;
     protected QueueSession consumerSession;
     protected QueueSession producerSession;
-   
+
     protected String selector;
     protected QueueSender producer;
     protected QueueConnection consumerConnection;
     protected QueueConnection producerConnection;
-    
 
-    public void stop() throws Exception{
+    public void stop() throws Exception {
         super.stop();
-        if(consumerSession!=null){
+        if (consumerSession != null) {
             consumerSession.close();
         }
-        if(producerSession!=null){
+        if (producerSession != null) {
             producerSession.close();
         }
     }
-    
 
-    protected MessageConsumer createConsumer() throws JMSException{
+    protected MessageConsumer createConsumer() throws JMSException {
         // set up the consumer
-        consumerSession=consumerConnection.createQueueSession(false,Session.CLIENT_ACKNOWLEDGE);
-        MessageConsumer consumer=null;
-        
-            if(selector!=null&&selector.length()>0){
-                consumer=consumerSession.createReceiver(consumerQueue,selector);
-            }else{
-                consumer=consumerSession.createReceiver(consumerQueue);
-            }
-       
+        consumerSession = consumerConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
+        MessageConsumer consumer = null;
+
+        if (selector != null && selector.length() > 0) {
+            consumer = consumerSession.createReceiver(consumerQueue, selector);
+        } else {
+            consumer = consumerSession.createReceiver(consumerQueue);
+        }
+
         return consumer;
     }
-    
-    protected synchronized MessageProducer createProducer() throws JMSException{
-        producerSession=producerConnection.createQueueSession(false,Session.AUTO_ACKNOWLEDGE);
+
+    protected synchronized MessageProducer createProducer() throws JMSException {
+        producerSession = producerConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
         producer = producerSession.createSender(null);
         return producer;
     }
-    
-        
-        
-    
-    protected synchronized void sendMessage(Message message) throws JMSException{
+
+    protected synchronized void sendMessage(Message message) throws JMSException {
         if (producer == null) {
             createProducer();
         }
-        producer.send(producerQueue,message);
+        producer.send(producerQueue, message);
     }
 
     /**
      * @return Returns the consumerConnection.
      */
-    public QueueConnection getConsumerConnection(){
+    public QueueConnection getConsumerConnection() {
         return consumerConnection;
     }
 
     /**
      * @param consumerConnection The consumerConnection to set.
      */
-    public void setConsumerConnection(QueueConnection consumerConnection){
-        this.consumerConnection=consumerConnection;
+    public void setConsumerConnection(QueueConnection consumerConnection) {
+        this.consumerConnection = consumerConnection;
     }
 
     /**
      * @return Returns the consumerQueue.
      */
-    public Queue getConsumerQueue(){
+    public Queue getConsumerQueue() {
         return consumerQueue;
     }
 
     /**
      * @param consumerQueue The consumerQueue to set.
      */
-    public void setConsumerQueue(Queue consumerQueue){
-        this.consumerQueue=consumerQueue;
+    public void setConsumerQueue(Queue consumerQueue) {
+        this.consumerQueue = consumerQueue;
     }
 
     /**
      * @return Returns the producerConnection.
      */
-    public QueueConnection getProducerConnection(){
+    public QueueConnection getProducerConnection() {
         return producerConnection;
     }
 
     /**
      * @param producerConnection The producerConnection to set.
      */
-    public void setProducerConnection(QueueConnection producerConnection){
-        this.producerConnection=producerConnection;
+    public void setProducerConnection(QueueConnection producerConnection) {
+        this.producerConnection = producerConnection;
     }
 
     /**
      * @return Returns the producerQueue.
      */
-    public Queue getProducerQueue(){
+    public Queue getProducerQueue() {
         return producerQueue;
     }
 
     /**
      * @param producerQueue The producerQueue to set.
      */
-    public void setProducerQueue(Queue producerQueue){
-        this.producerQueue=producerQueue;
+    public void setProducerQueue(Queue producerQueue) {
+        this.producerQueue = producerQueue;
     }
 
     /**
      * @return Returns the selector.
      */
-    public String getSelector(){
+    public String getSelector() {
         return selector;
     }
 
     /**
      * @param selector The selector to set.
      */
-    public void setSelector(String selector){
-        this.selector=selector;
+    public void setSelector(String selector) {
+        this.selector = selector;
     }
-    
-    protected Connection getConnnectionForConsumer(){
+
+    protected Connection getConnnectionForConsumer() {
         return getConsumerConnection();
     }
-    
-    protected Connection getConnectionForProducer(){
+
+    protected Connection getConnectionForProducer() {
         return getProducerConnection();
     }
-    
-  
+
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/SimpleJmsMessageConvertor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/SimpleJmsMessageConvertor.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/SimpleJmsMessageConvertor.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/SimpleJmsMessageConvertor.java Wed Aug  8 11:56:59 2007
@@ -28,32 +28,32 @@
  * 
  * @version $Revision: 1.1.1.1 $
  */
-public class SimpleJmsMessageConvertor implements  JmsMesageConvertor {
-    
+public class SimpleJmsMessageConvertor implements JmsMesageConvertor {
+
     /**
-     * Convert a foreign JMS Message to a native ActiveMQ Message - Inbound
-     * or visa-versa outbound
+     * Convert a foreign JMS Message to a native ActiveMQ Message - Inbound or
+     * visa-versa outbound
+     * 
      * @param message
      * @return the converted message
      * @throws JMSException
      */
-    public Message convert(Message message) throws JMSException{
+    public Message convert(Message message) throws JMSException {
         return message;
     }
-    
-    public Message convert(Message message, Destination replyTo) throws JMSException{
-    	Message msg = convert(message);
-    	if(replyTo != null) {
-    		msg.setJMSReplyTo(replyTo);
-		}else{
-			msg.setJMSReplyTo(null);
-		}
-		return msg;
+
+    public Message convert(Message message, Destination replyTo) throws JMSException {
+        Message msg = convert(message);
+        if (replyTo != null) {
+            msg.setJMSReplyTo(replyTo);
+        } else {
+            msg.setJMSReplyTo(null);
+        }
+        return msg;
     }
-    
-    public void setConnection(Connection connection){
-    	//do nothing
+
+    public void setConnection(Connection connection) {
+        // do nothing
     }
-    
-   
+
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/TopicBridge.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/TopicBridge.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/TopicBridge.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/jms/TopicBridge.java Wed Aug  8 11:56:59 2007
@@ -27,12 +27,13 @@
 import javax.jms.TopicConnection;
 import javax.jms.TopicPublisher;
 import javax.jms.TopicSession;
+
 /**
  * A Destination bridge is used to bridge between to different JMS systems
  * 
  * @version $Revision: 1.1.1.1 $
  */
-class TopicBridge extends DestinationBridge{
+class TopicBridge extends DestinationBridge {
     protected Topic consumerTopic;
     protected Topic producerTopic;
     protected TopicSession consumerSession;
@@ -42,150 +43,140 @@
     protected TopicPublisher producer;
     protected TopicConnection consumerConnection;
     protected TopicConnection producerConnection;
-    
 
-    public void stop() throws Exception{
+    public void stop() throws Exception {
         super.stop();
-        if(consumerSession!=null){
+        if (consumerSession != null) {
             consumerSession.close();
         }
-        if(producerSession!=null){
+        if (producerSession != null) {
             producerSession.close();
         }
     }
-    
-   
 
-    protected MessageConsumer createConsumer() throws JMSException{
+    protected MessageConsumer createConsumer() throws JMSException {
         // set up the consumer
-        consumerSession=consumerConnection.createTopicSession(false,Session.CLIENT_ACKNOWLEDGE);
-        MessageConsumer consumer=null;
-        if(consumerName!=null&&consumerName.length()>0){
-            if(selector!=null&&selector.length()>0){
-                consumer=consumerSession.createDurableSubscriber(consumerTopic,consumerName,selector,false);
-            }else{
-                consumer=consumerSession.createDurableSubscriber(consumerTopic,consumerName);
+        consumerSession = consumerConnection.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE);
+        MessageConsumer consumer = null;
+        if (consumerName != null && consumerName.length() > 0) {
+            if (selector != null && selector.length() > 0) {
+                consumer = consumerSession.createDurableSubscriber(consumerTopic, consumerName, selector,
+                                                                   false);
+            } else {
+                consumer = consumerSession.createDurableSubscriber(consumerTopic, consumerName);
             }
-        }else{
-            if(selector!=null&&selector.length()>0){
-                consumer=consumerSession.createSubscriber(consumerTopic,selector,false);
-            }else{
-                consumer=consumerSession.createSubscriber(consumerTopic);
+        } else {
+            if (selector != null && selector.length() > 0) {
+                consumer = consumerSession.createSubscriber(consumerTopic, selector, false);
+            } else {
+                consumer = consumerSession.createSubscriber(consumerTopic);
             }
         }
         return consumer;
     }
-    
-    
-    
-    protected synchronized MessageProducer createProducer() throws JMSException{
-        producerSession=producerConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
+
+    protected synchronized MessageProducer createProducer() throws JMSException {
+        producerSession = producerConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
         producer = producerSession.createPublisher(null);
         return producer;
     }
-    
-    protected synchronized void sendMessage(Message message) throws JMSException{
+
+    protected synchronized void sendMessage(Message message) throws JMSException {
         if (producer == null) {
             createProducer();
         }
-        producer.publish(producerTopic,message);
+        producer.publish(producerTopic, message);
     }
 
     /**
      * @return Returns the consumerConnection.
      */
-    public TopicConnection getConsumerConnection(){
+    public TopicConnection getConsumerConnection() {
         return consumerConnection;
     }
 
     /**
-     * @param consumerConnection
-     *            The consumerConnection to set.
+     * @param consumerConnection The consumerConnection to set.
      */
-    public void setConsumerConnection(TopicConnection consumerConnection){
-        this.consumerConnection=consumerConnection;
+    public void setConsumerConnection(TopicConnection consumerConnection) {
+        this.consumerConnection = consumerConnection;
     }
 
     /**
      * @return Returns the subscriptionName.
      */
-    public String getConsumerName(){
+    public String getConsumerName() {
         return consumerName;
     }
 
     /**
-     * @param subscriptionName
-     *            The subscriptionName to set.
+     * @param subscriptionName The subscriptionName to set.
      */
-    public void setConsumerName(String consumerName){
-        this.consumerName=consumerName;
+    public void setConsumerName(String consumerName) {
+        this.consumerName = consumerName;
     }
 
     /**
      * @return Returns the consumerTopic.
      */
-    public Topic getConsumerTopic(){
+    public Topic getConsumerTopic() {
         return consumerTopic;
     }
 
     /**
-     * @param consumerTopic
-     *            The consumerTopic to set.
+     * @param consumerTopic The consumerTopic to set.
      */
-    public void setConsumerTopic(Topic consumerTopic){
-        this.consumerTopic=consumerTopic;
+    public void setConsumerTopic(Topic consumerTopic) {
+        this.consumerTopic = consumerTopic;
     }
 
     /**
      * @return Returns the producerConnection.
      */
-    public TopicConnection getProducerConnection(){
+    public TopicConnection getProducerConnection() {
         return producerConnection;
     }
 
     /**
-     * @param producerConnection
-     *            The producerConnection to set.
+     * @param producerConnection The producerConnection to set.
      */
-    public void setProducerConnection(TopicConnection producerConnection){
-        this.producerConnection=producerConnection;
+    public void setProducerConnection(TopicConnection producerConnection) {
+        this.producerConnection = producerConnection;
     }
 
     /**
      * @return Returns the producerTopic.
      */
-    public Topic getProducerTopic(){
+    public Topic getProducerTopic() {
         return producerTopic;
     }
 
     /**
-     * @param producerTopic
-     *            The producerTopic to set.
+     * @param producerTopic The producerTopic to set.
      */
-    public void setProducerTopic(Topic producerTopic){
-        this.producerTopic=producerTopic;
+    public void setProducerTopic(Topic producerTopic) {
+        this.producerTopic = producerTopic;
     }
 
     /**
      * @return Returns the selector.
      */
-    public String getSelector(){
+    public String getSelector() {
         return selector;
     }
 
     /**
-     * @param selector
-     *            The selector to set.
+     * @param selector The selector to set.
      */
-    public void setSelector(String selector){
-        this.selector=selector;
+    public void setSelector(String selector) {
+        this.selector = selector;
     }
-    
-    protected Connection getConnnectionForConsumer(){
+
+    protected Connection getConnnectionForConsumer() {
         return getConsumerConnection();
     }
-    
-    protected Connection getConnectionForProducer(){
+
+    protected Connection getConnectionForProducer() {
         return getProducerConnection();
     }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/BooleanStream.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/BooleanStream.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/BooleanStream.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/BooleanStream.java Wed Aug  8 11:56:59 2007
@@ -26,101 +26,99 @@
 final public class BooleanStream {
 
     byte data[] = new byte[48];
-    short arrayLimit;    
-    short arrayPos;    
+    short arrayLimit;
+    short arrayPos;
     byte bytePos;
-    
+
     public boolean readBoolean() throws IOException {
         assert arrayPos <= arrayLimit;
         byte b = data[arrayPos];
-        boolean rc = ((b>>bytePos)&0x01)!=0;
+        boolean rc = ((b >> bytePos) & 0x01) != 0;
         bytePos++;
-        if( bytePos >= 8 ) {
-            bytePos=0;
+        if (bytePos >= 8) {
+            bytePos = 0;
             arrayPos++;
         }
         return rc;
     }
-    
+
     public void writeBoolean(boolean value) throws IOException {
-        if( bytePos == 0 ) {
+        if (bytePos == 0) {
             arrayLimit++;
-            if( arrayLimit >= data.length ) {
+            if (arrayLimit >= data.length) {
                 // re-grow the array.
-                byte d[] = new byte[data.length*2];
+                byte d[] = new byte[data.length * 2];
                 System.arraycopy(data, 0, d, 0, data.length);
                 data = d;
             }
         }
-        if( value ) {
-            data[arrayPos] |= (0x01 << bytePos); 
+        if (value) {
+            data[arrayPos] |= (0x01 << bytePos);
         }
         bytePos++;
-        if( bytePos >= 8 ) {
-            bytePos=0;
+        if (bytePos >= 8) {
+            bytePos = 0;
             arrayPos++;
         }
     }
-    
+
     public void marshal(DataOutput dataOut) throws IOException {
-        if( arrayLimit < 64 ) {
+        if (arrayLimit < 64) {
             dataOut.writeByte(arrayLimit);
-        } else if( arrayLimit < 256 ) { // max value of unsigned byte
+        } else if (arrayLimit < 256) { // max value of unsigned byte
             dataOut.writeByte(0xC0);
-            dataOut.writeByte(arrayLimit);            
+            dataOut.writeByte(arrayLimit);
         } else {
             dataOut.writeByte(0x80);
-            dataOut.writeShort(arrayLimit);            
+            dataOut.writeShort(arrayLimit);
         }
-        
+
         dataOut.write(data, 0, arrayLimit);
         clear();
     }
-    
+
     public void marshal(ByteBuffer dataOut) {
-        if( arrayLimit < 64 ) {
-            dataOut.put((byte) arrayLimit);
-        } else if( arrayLimit < 256 ) { // max value of unsigned byte
-            dataOut.put((byte) 0xC0);
-            dataOut.put((byte) arrayLimit);            
+        if (arrayLimit < 64) {
+            dataOut.put((byte)arrayLimit);
+        } else if (arrayLimit < 256) { // max value of unsigned byte
+            dataOut.put((byte)0xC0);
+            dataOut.put((byte)arrayLimit);
         } else {
-            dataOut.put((byte) 0x80);
-            dataOut.putShort(arrayLimit);            
+            dataOut.put((byte)0x80);
+            dataOut.putShort(arrayLimit);
         }
-        
+
         dataOut.put(data, 0, arrayLimit);
     }
 
-
     public void unmarshal(DataInput dataIn) throws IOException {
-        
-        arrayLimit = (short) (dataIn.readByte() & 0xFF);
-        if ( arrayLimit == 0xC0 ) {
+
+        arrayLimit = (short)(dataIn.readByte() & 0xFF);
+        if (arrayLimit == 0xC0) {
             arrayLimit = (short)(dataIn.readByte() & 0xFF);
-        } else if( arrayLimit == 0x80 ) {
+        } else if (arrayLimit == 0x80) {
             arrayLimit = dataIn.readShort();
-        } 
-        if( data.length < arrayLimit ) {
+        }
+        if (data.length < arrayLimit) {
             data = new byte[arrayLimit];
         }
         dataIn.readFully(data, 0, arrayLimit);
         clear();
     }
-    
+
     public void clear() {
-        arrayPos=0;
-        bytePos=0;
+        arrayPos = 0;
+        bytePos = 0;
     }
 
     public int marshalledSize() {
-        if( arrayLimit < 64 ) {
-            return 1+arrayLimit;
+        if (arrayLimit < 64) {
+            return 1 + arrayLimit;
         } else if (arrayLimit < 256) {
-            return 2+arrayLimit;
+            return 2 + arrayLimit;
         } else {
-            return 3+arrayLimit;
+            return 3 + arrayLimit;
         }
     }
-
 
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormatFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormatFactory.java?view=diff&rev=563982&r1=563981&r2=563982
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormatFactory.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/openwire/OpenWireFormatFactory.java Wed Aug  8 11:56:59 2007
@@ -25,37 +25,38 @@
  */
 public class OpenWireFormatFactory implements WireFormatFactory {
 
-	//
-	// The default values here are what the wire format changes to after a default negotiation.
-	//
-	
-    private int version=OpenWireFormat.DEFAULT_VERSION;
-    private boolean stackTraceEnabled=true;
-    private boolean tcpNoDelayEnabled=true;
-    private boolean cacheEnabled=true;
-    private boolean tightEncodingEnabled=true;
-    private boolean sizePrefixDisabled=false;
-    private long maxInactivityDuration=30*1000;
-    private int cacheSize=1024;
-    
+    //
+    // The default values here are what the wire format changes to after a
+    // default negotiation.
+    //
+
+    private int version = OpenWireFormat.DEFAULT_VERSION;
+    private boolean stackTraceEnabled = true;
+    private boolean tcpNoDelayEnabled = true;
+    private boolean cacheEnabled = true;
+    private boolean tightEncodingEnabled = true;
+    private boolean sizePrefixDisabled = false;
+    private long maxInactivityDuration = 30 * 1000;
+    private int cacheSize = 1024;
+
     public WireFormat createWireFormat() {
-		WireFormatInfo info = new WireFormatInfo();
-		info.setVersion(version);
-		
+        WireFormatInfo info = new WireFormatInfo();
+        info.setVersion(version);
+
         try {
-			info.setStackTraceEnabled(stackTraceEnabled);
-			info.setCacheEnabled(cacheEnabled);
-			info.setTcpNoDelayEnabled(tcpNoDelayEnabled);
-			info.setTightEncodingEnabled(tightEncodingEnabled);
-			info.setSizePrefixDisabled(sizePrefixDisabled);
+            info.setStackTraceEnabled(stackTraceEnabled);
+            info.setCacheEnabled(cacheEnabled);
+            info.setTcpNoDelayEnabled(tcpNoDelayEnabled);
+            info.setTightEncodingEnabled(tightEncodingEnabled);
+            info.setSizePrefixDisabled(sizePrefixDisabled);
             info.seMaxInactivityDuration(maxInactivityDuration);
             info.setCacheSize(cacheSize);
-		} catch (Exception e) {
-			IllegalStateException ise = new IllegalStateException("Could not configure WireFormatInfo");
+        } catch (Exception e) {
+            IllegalStateException ise = new IllegalStateException("Could not configure WireFormatInfo");
             ise.initCause(e);
             throw ise;
-		}
-		
+        }
+
         OpenWireFormat f = new OpenWireFormat();
         f.setPreferedWireFormatInfo(info);
         return f;
@@ -101,13 +102,13 @@
         this.tightEncodingEnabled = tightEncodingEnabled;
     }
 
-	public boolean isSizePrefixDisabled() {
-		return sizePrefixDisabled;
-	}
-
-	public void setSizePrefixDisabled(boolean sizePrefixDisabled) {
-		this.sizePrefixDisabled = sizePrefixDisabled;
-	}
+    public boolean isSizePrefixDisabled() {
+        return sizePrefixDisabled;
+    }
+
+    public void setSizePrefixDisabled(boolean sizePrefixDisabled) {
+        this.sizePrefixDisabled = sizePrefixDisabled;
+    }
 
     public long getMaxInactivityDuration() {
         return maxInactivityDuration;
@@ -117,11 +118,11 @@
         this.maxInactivityDuration = maxInactivityDuration;
     }
 
-	public int getCacheSize() {
-		return cacheSize;
-	}
-
-	public void setCacheSize(int cacheSize) {
-		this.cacheSize = cacheSize;
-	}
+    public int getCacheSize() {
+        return cacheSize;
+    }
+
+    public void setCacheSize(int cacheSize) {
+        this.cacheSize = cacheSize;
+    }
 }



Mime
View raw message