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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Mar 23 09:51:26 EDT 2007


Author: kevin.conner at jboss.com
Date: 2007-03-23 09:51:26 -0400 (Fri, 23 Mar 2007)
New Revision: 10472

Modified:
   labs/jbossesb/branches/JBESB_4_0_MP1/product/core/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
Log:
Removed sleep in synchronized block, added cleanup method

Modified: labs/jbossesb/branches/JBESB_4_0_MP1/product/core/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_0_MP1/product/core/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java	2007-03-23 13:11:46 UTC (rev 10471)
+++ labs/jbossesb/branches/JBESB_4_0_MP1/product/core/rosetta/src/org/jboss/internal/soa/esb/rosetta/pooling/JmsConnectionPool.java	2007-03-23 13:51:26 UTC (rev 10472)
@@ -138,8 +138,7 @@
                             + ", maxsize=" + MAX_SESSIONS 
                             + ", number of pools=" + JmsConnectionPoolContainer.getNumberOfPools());
                 }
-                session = freeSessions.get(freeSessions.size()-1);
-                freeSessions.remove(session);
+                session = freeSessions.remove(freeSessions.size()-1);
                 inUseSessions.add(session);
             } else {
                 if (waitInSeconds++ > 30) { 
@@ -153,7 +152,7 @@
                     try {
                         //wait one second and try again.
                         logger.info("The connection pool was exhausted. Waiting 1 second before trying again..");
-                        Thread.sleep(1000);
+                        wait(1000);
                     } catch (Exception e) {
                         e.printStackTrace();
                     }
@@ -192,8 +191,18 @@
      */
     public  synchronized void closeSession(Session connectionToClose){
         freeSessions.add(connectionToClose);
-        inUseSessions.remove(connectionToClose);
+        releaseSession(connectionToClose) ;
     }
+    
+    /**
+     * This method closes an open session without returning it to the pool.
+     * @param sessionToClose The session to be returned to the pool.
+     * @throws SQLException
+     */
+    public synchronized void releaseSession(final Session sessionToClose) {
+        inUseSessions.remove(sessionToClose);
+        notifyAll() ;
+    }
 
     /**
      * This method is called when the pool needs to destroyed. It closes all open sessions




More information about the jboss-svn-commits mailing list