qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject svn commit: r1546108 - in /qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl: ConnectionImpl.java SessionImpl.java
Date Wed, 27 Nov 2013 16:57:58 GMT
Author: robbie
Date: Wed Nov 27 16:57:58 2013
New Revision: 1546108

URL: http://svn.apache.org/r1546108
Log:
QPIDJMS-9: reorder some code for clarity

Modified:
    qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java
    qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java

Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java?rev=1546108&r1=1546107&r2=1546108&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/ConnectionImpl.java Wed Nov 27 16:57:58
2013
@@ -148,6 +148,11 @@ public class ConnectionImpl implements C
         }
     }
 
+    boolean isStarted()
+    {
+        return _isStarted;
+    }
+
     private void connect() throws IOException, ConnectionException, JmsTimeoutException,
JmsInterruptedException
     {
         lock();
@@ -184,6 +189,49 @@ public class ConnectionImpl implements C
         }
     }
 
+    /**
+     * <p>
+     * Acquire the connection lock.
+     * </p>
+     * <p>
+     * Must be held by an application thread before reading or modifying
+     * the state of this connection or any of its associated child objects
+     * (e.g. sessions, senders, receivers, links, and messages).
+     * Also must be held when calling {@link #stateChanged()}.
+     * </p>
+     * <p>
+     * Following these rules ensures that this lock is acquired BEFORE the lock(s) managed
by {@link AmqpConnection}.
+     * </p>
+     *
+     * @see #releaseLock()
+     */
+    void lock()
+    {
+        _connectionLock.lock();
+    }
+
+    /**
+     * @see #lock()
+     */
+    void releaseLock()
+    {
+        _connectionLock.unlock();
+    }
+
+    /**
+     * Inform the connection that its state has been locally changed so that, for example,
+     * it can schedule network I/O to occur.
+     * The caller must first acquire the connection lock (via {@link #lock()}).
+     */
+    void stateChanged()
+    {
+        _connectionLock.stateChanged();
+    }
+
+
+    //======= JMS Methods =======
+
+
     @Override
     public void close() throws JMSException
     {
@@ -247,45 +295,6 @@ public class ConnectionImpl implements C
         }
     }
 
-    /**
-     * <p>
-     * Acquire the connection lock.
-     * </p>
-     * <p>
-     * Must be held by an application thread before reading or modifying
-     * the state of this connection or any of its associated child objects
-     * (e.g. sessions, senders, receivers, links, and messages).
-     * Also must be held when calling {@link #stateChanged()}.
-     * </p>
-     * <p>
-     * Following these rules ensures that this lock is acquired BEFORE the lock(s) managed
by {@link AmqpConnection}.
-     * </p>
-     *
-     * @see #releaseLock()
-     */
-    void lock()
-    {
-        _connectionLock.lock();
-    }
-
-    /**
-     * @see #lock()
-     */
-    void releaseLock()
-    {
-        _connectionLock.unlock();
-    }
-
-    /**
-     * Inform the connection that its state has been locally changed so that, for example,
-     * it can schedule network I/O to occur.
-     * The caller must first acquire the connection lock (via {@link #lock()}).
-     */
-    void stateChanged()
-    {
-        _connectionLock.stateChanged();
-    }
-
     @Override
     public String getClientID() throws JMSException
     {
@@ -347,9 +356,4 @@ public class ConnectionImpl implements C
         // TODO Auto-generated method stub
         throw new UnsupportedOperationException("Not Implemented");
     }
-
-    boolean isStarted()
-    {
-        return _isStarted;
-    }
 }

Modified: qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java
URL: http://svn.apache.org/viewvc/qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java?rev=1546108&r1=1546107&r2=1546108&view=diff
==============================================================================
--- qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java (original)
+++ qpid/jms/trunk/src/main/java/org/apache/qpid/jms/impl/SessionImpl.java Wed Nov 27 16:57:58
2013
@@ -62,7 +62,7 @@ public class SessionImpl implements Sess
         _connectionImpl = connectionImpl;
     }
 
-    public void establish() throws JmsTimeoutException, JmsInterruptedException
+    void establish() throws JmsTimeoutException, JmsInterruptedException
     {
         _connectionImpl.waitUntil(new SimplePredicate("Session established", _amqpSession)
         {
@@ -74,6 +74,58 @@ public class SessionImpl implements Sess
         }, AmqpConnection.TIMEOUT);
     }
 
+    ConnectionImpl getConnectionImpl()
+    {
+        return _connectionImpl;
+    }
+
+    private SenderImpl createSender(String address) throws JMSException
+    {
+        _connectionImpl.lock();
+        try
+        {
+            AmqpSender amqpSender = _amqpSession.createAmqpSender(address);
+            SenderImpl sender = new SenderImpl(this, _connectionImpl, amqpSender);
+            _connectionImpl.stateChanged();
+            sender.establish();
+            return sender;
+        }
+        finally
+        {
+            _connectionImpl.releaseLock();
+        }
+    }
+
+    private ReceiverImpl createReceiver(String address) throws JMSException
+    {
+        _connectionImpl.lock();
+        try
+        {
+            AmqpReceiver amqpReceiver = _amqpSession.createAmqpReceiver(address);
+            ReceiverImpl receiver = new ReceiverImpl(_connectionImpl, this, amqpReceiver);
+            _connectionImpl.stateChanged();
+            receiver.establish();
+
+            if(_connectionImpl.isStarted())
+            {
+                //Issue initial flow for the consumer.
+                //TODO: decide on prefetch behaviour, i.e. whether we defer flow or do it
now, and what value to use.
+                amqpReceiver.credit(INITIAL_RECEIVER_CREDIT);
+                _connectionImpl.stateChanged();
+            }
+
+            return receiver;
+        }
+        finally
+        {
+            _connectionImpl.releaseLock();
+        }
+    }
+
+
+    //======= JMS Methods =======
+
+
     @Override
     public void close() throws JMSException
     {
@@ -105,12 +157,6 @@ public class SessionImpl implements Sess
         }
     }
 
-    ConnectionImpl getConnectionImpl()
-    {
-        return _connectionImpl;
-    }
-
-
     @Override
     public MessageProducer createProducer(Destination destination) throws JMSException
     {
@@ -134,23 +180,6 @@ public class SessionImpl implements Sess
 
     }
 
-    private SenderImpl createSender(String address) throws JMSException
-    {
-        _connectionImpl.lock();
-        try
-        {
-            AmqpSender amqpSender = _amqpSession.createAmqpSender(address);
-            SenderImpl sender = new SenderImpl(this, _connectionImpl, amqpSender);
-            _connectionImpl.stateChanged();
-            sender.establish();
-            return sender;
-        }
-        finally
-        {
-            _connectionImpl.releaseLock();
-        }
-    }
-
     @Override
     public MessageConsumer createConsumer(Destination destination) throws JMSException
     {
@@ -174,32 +203,6 @@ public class SessionImpl implements Sess
         }
     }
 
-    private ReceiverImpl createReceiver(String address) throws JMSException
-    {
-        _connectionImpl.lock();
-        try
-        {
-            AmqpReceiver amqpReceiver = _amqpSession.createAmqpReceiver(address);
-            ReceiverImpl receiver = new ReceiverImpl(_connectionImpl, this, amqpReceiver);
-            _connectionImpl.stateChanged();
-            receiver.establish();
-
-            if(_connectionImpl.isStarted())
-            {
-                //Issue initial flow for the consumer.
-                //TODO: decide on prefetch behaviour, i.e. whether we defer flow or do it
now, and what value to use.
-                amqpReceiver.credit(INITIAL_RECEIVER_CREDIT);
-                _connectionImpl.stateChanged();
-            }
-
-            return receiver;
-        }
-        finally
-        {
-            _connectionImpl.releaseLock();
-        }
-    }
-
     @Override
     public BytesMessage createBytesMessage() throws JMSException
     {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message