[jboss-svn-commits] JBL Code SVN: r32600 - labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Apr 23 09:39:32 EDT 2010


Author: tfennelly
Date: 2010-04-23 09:39:31 -0400 (Fri, 23 Apr 2010)
New Revision: 32600

Modified:
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java
   labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java
Log:
https://jira.jboss.org/jira/browse/JBESB-3263
JmsConnectionPool searches for associated JmsSessionPool by sequentially iterating over JmsSessions

Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java	2010-04-23 13:34:01 UTC (rev 32599)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java	2010-04-23 13:39:31 UTC (rev 32600)
@@ -21,8 +21,6 @@
 */
 package org.jboss.internal.soa.esb.rosetta.pooling;
 
-import java.io.IOException;
-import java.net.URL;
 import java.sql.SQLException;
 import java.util.*;
 import java.util.concurrent.Callable;
@@ -52,7 +50,6 @@
 import org.jboss.soa.esb.common.TransactionStrategyException;
 import org.jboss.soa.esb.helpers.NamingContextException;
 import org.jboss.soa.esb.helpers.NamingContextPool;
-import org.jboss.soa.esb.services.security.PasswordUtil;
 import org.jboss.soa.esb.util.JmsUtil;
 
 import com.arjuna.common.util.propertyservice.PropertyManager;
@@ -610,14 +607,8 @@
         }
     }
 
-    synchronized JmsSessionPool findOwnerPool(final JmsSession session) {
-        for(JmsSessionPool sessionPool : sessionPools) {
-            if(sessionPool.isOwnerPool(session)) {
-                return sessionPool;
-            }
-        }
-
-        return null;
+    JmsSessionPool findOwnerPool(final JmsSession session) {
+        return session.getSessionPool() ;
     }
 
     static
@@ -683,25 +674,6 @@
             inUseSessionsMap.put(Session.DUPS_OK_ACKNOWLEDGE, new ArrayList<JmsSession>() );
         }
 
-        private boolean isOwnerPool(JmsSession session) {
-            if (isInList(session, freeSessionsMap.values())) {
-                return true;
-            } else if (isInList(session, inUseSessionsMap.values())) {
-                return true;
-            }
-
-            return false;
-        }
-
-        private boolean isInList(JmsSession session, Collection<ArrayList<JmsSession>> sessionLists) {
-            for(ArrayList<JmsSession> sessionList : sessionLists) {
-                if(sessionList.contains(session)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-
         public synchronized void removeSessionPool() {
             freeSessionsMap = null ;
             inUseSessionsMap = null ;
@@ -825,9 +797,9 @@
                     final JmsSession session ;
 
                     if (transacted) {
-                        session = new JmsXASession(JmsConnectionPool.this, ((XAConnection)currentConnection).createXASession(), currentID, acknowledgeMode);
+                        session = new JmsXASession(JmsConnectionPool.this, JmsSessionPool.this, ((XAConnection)currentConnection).createXASession(), currentID, acknowledgeMode);
                     } else {
-                        session = new JmsSession(JmsConnectionPool.this, currentConnection.createSession(transacted, acknowledgeMode), currentID, acknowledgeMode);
+                        session = new JmsSession(JmsConnectionPool.this, JmsSessionPool.this, currentConnection.createSession(transacted, acknowledgeMode), currentID, acknowledgeMode);
                     }
 
                     return session ;

Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java	2010-04-23 13:34:01 UTC (rev 32599)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsSession.java	2010-04-23 13:39:31 UTC (rev 32600)
@@ -47,6 +47,8 @@
 import javax.jms.Topic;
 import javax.jms.TopicSubscriber;
 
+import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool.JmsSessionPool;
+
 /**
  * Wrapper for JMS session class, responsible for tracking resources and the pooling.
  */
@@ -55,8 +57,12 @@
     /**
      * The connection pool.
      */
-    private final JmsConnectionPool pool ;
+    private final JmsConnectionPool connectionPool ;
     /**
+     * The session pool.
+     */
+    private final JmsSessionPool sessionPool ;
+    /**
      * The session delegate.
      */
     private final Session session ;
@@ -93,18 +99,20 @@
     
     /**
      * Create the session wrapper.
-     * @param pool The pool associated with this session.
+     * @param connectionPool The connection pool associated with this session.
+     * @param sessionPool The session pool associated with this session.
      * @param session The session delegate.
      * @param id The pool instance id.
      * @param requestedAcknowledgeMode The requested acknowledge mode for this session.
      * @throws JMSException
      */
-    JmsSession(final JmsConnectionPool pool, final Session session, final long id, final int requestedAcknowledgeMode)
+    JmsSession(final JmsConnectionPool connectionPool, final JmsSessionPool sessionPool, final Session session, final long id, final int requestedAcknowledgeMode)
         throws JMSException
     {
-        this.pool = pool ;
+        this.connectionPool = connectionPool ;
+        this.sessionPool = sessionPool ;
         this.id = id ;
-        this.session = (Session)getExceptionHandler(pool, Session.class, session) ;
+        this.session = (Session)getExceptionHandler(connectionPool, Session.class, session) ;
         this.requestedAcknowledgeMode = requestedAcknowledgeMode ;
         acknowledgeMode = session.getAcknowledgeMode() ;
         // Workaround for JBESB-1873
@@ -306,7 +314,7 @@
         }
         final QueueBrowser result = getQueueBrowser(queueBrowser) ;
         queueBrowserSet.add(result) ;
-        return (QueueBrowser)getExceptionHandler(pool, QueueBrowser.class, result) ;
+        return (QueueBrowser)getExceptionHandler(connectionPool, QueueBrowser.class, result) ;
     }
 
     private synchronized MessageConsumer trackMessageConsumer(MessageConsumer messageConsumer)
@@ -319,7 +327,7 @@
         }
         final MessageConsumer result = getMessageConsumer(messageConsumer) ;
         messageConsumerSet.add(result) ;
-        return (MessageConsumer)getExceptionHandler(pool, MessageConsumer.class, result) ;
+        return (MessageConsumer)getExceptionHandler(connectionPool, MessageConsumer.class, result) ;
     }
 
     private synchronized TopicSubscriber trackTopicSubscriber(TopicSubscriber topicSubscriber)
@@ -332,7 +340,7 @@
         }
         final TopicSubscriber result = getTopicSubscriber(topicSubscriber) ;
         messageConsumerSet.add(result) ;
-        return (TopicSubscriber)getExceptionHandler(pool, TopicSubscriber.class, result) ;
+        return (TopicSubscriber)getExceptionHandler(connectionPool, TopicSubscriber.class, result) ;
     }
 
     private synchronized MessageProducer trackMessageProducer(MessageProducer messageProducer)
@@ -345,7 +353,7 @@
         }
         final MessageProducer result = getMessageProducer(messageProducer) ;
         messageProducerSet.add(result) ;
-        return (MessageProducer)getExceptionHandler(pool, MessageProducer.class, result) ;
+        return (MessageProducer)getExceptionHandler(connectionPool, MessageProducer.class, result) ;
     }
 
     synchronized void releaseResources()
@@ -417,6 +425,11 @@
     {
     }
     
+    protected JmsSessionPool getSessionPool()
+    {
+        return sessionPool ;
+    }
+    
     protected void setSuspect(final boolean suspect)
     {
         this.suspect = suspect ;
@@ -434,15 +447,15 @@
 
     /**
      * Wrap the object in an exception handler.
-     * @param pool The pool associated with this session.
+     * @param connectionPool The connection pool associated with this session.
      * @param instanceClass The interface type of the instance.
      * @param instance The instance
      * @return 
      */
-    protected Object getExceptionHandler(final JmsConnectionPool pool,
+    protected Object getExceptionHandler(final JmsConnectionPool connectionPool,
             final Class<?> instanceClass, final Object instance)
     {
-        final InvocationHandler handler = new ExceptionHandler(pool, instance) ;
+        final InvocationHandler handler = new ExceptionHandler(connectionPool, instance) ;
         return Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {instanceClass}, handler);
     }
     

Modified: labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java	2010-04-23 13:34:01 UTC (rev 32599)
+++ labs/jbossesb/branches/JBESB_4_7_CP/product/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsXASession.java	2010-04-23 13:39:31 UTC (rev 32600)
@@ -36,6 +36,7 @@
 import javax.transaction.Synchronization;
 import javax.transaction.xa.XAResource;
 
+import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool.JmsSessionPool;
 import org.jboss.soa.esb.common.TransactionStrategy;
 import org.jboss.soa.esb.common.TransactionStrategyException;
 
@@ -47,7 +48,7 @@
     /**
      * The connection pool.
      */
-    private final JmsConnectionPool pool ;
+    private final JmsConnectionPool connectionPool ;
     
     /**
      * The session delegate.
@@ -71,18 +72,19 @@
     
     /**
      * Create the session wrapper.
-     * @param pool The current connection pool
+     * @param connectionPool The current connection pool
+     * @param sessionPool The current session pool
      * @param session The session delegate.
      * @param id The pool instance id.
      * @param requestedAcknowledgeMode The requested acknowledge mode for this session.
      * @throws JMSException
      */
-    JmsXASession(final JmsConnectionPool pool, final XASession session, final long id, final int requestedAcknowledgeMode)
+    JmsXASession(final JmsConnectionPool connectionPool, final JmsSessionPool sessionPool, final XASession session, final long id, final int requestedAcknowledgeMode)
         throws JMSException
     {
-        super(pool, session, id, requestedAcknowledgeMode) ;
-        this.pool = pool ;
-        this.session = (XASession)getExceptionHandler(pool, XASession.class, session) ;
+        super(connectionPool, sessionPool, session, id, requestedAcknowledgeMode) ;
+        this.connectionPool = connectionPool ;
+        this.session = (XASession)getExceptionHandler(connectionPool, XASession.class, session) ;
     }
     
     @Override
@@ -142,7 +144,7 @@
         }
         else
         {
-            pool.handleCloseSession(this) ;
+            connectionPool.handleCloseSession(this) ;
         }
     }
     
@@ -154,7 +156,7 @@
         }
         else
         {
-            pool.handleReleaseSession(this) ;
+            connectionPool.handleReleaseSession(this) ;
         }
     }
     
@@ -180,7 +182,7 @@
             }
             try
             {
-                pool.associateTransaction(this) ;
+                connectionPool.associateTransaction(this) ;
             }
             catch (final ConnectionException ce)
             {
@@ -200,18 +202,18 @@
     
     public synchronized void afterCompletion(final int result)
     {
-        pool.disassociateTransaction(this) ;
+        connectionPool.disassociateTransaction(this) ;
         switch (cleanupAction)
         {
         case close:
             if (result == Status.STATUS_COMMITTED)
             {
-                pool.handleCloseSession(this) ;
+                connectionPool.handleCloseSession(this) ;
                 break ;
             }
             // fall through
         case release:
-            pool.handleReleaseSession(this) ;
+            connectionPool.handleReleaseSession(this) ;
             break ;
         case none:
             // Reference held by caller



More information about the jboss-svn-commits mailing list