Package org.jboss.resource.connectionmanager

Examples of org.jboss.resource.connectionmanager.ConnectionListener


      pp.backgroundInterval = 2000;
      ManagedConnectionPool mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
      NoTxConnectionManager noTxn = new NoTxConnectionManager(null, mcp);
      mcp.setConnectionListenerFactory(noTxn);
     
      ConnectionListener cl = noTxn.getManagedConnection(null, null);
      noTxn.returnManagedConnection(cl, false);
     
      Thread.sleep(pp.backgroundInterval);
      assertTrue(mcp.getConnectionDestroyedCount() > 0);
     
View Full Code Here


      BaseConnectionManager2 cm = getCM(pp);
      try
      {
         // Get a connection
         ConnectionListener cl = cm.getManagedConnection(null, null);
         assertTrue("1: Got a null connection!", cl.getManagedConnection() != null);
         assertTrue("1: InternalManagedConnectionPool", cl.getContext() instanceof InternalManagedConnectionPool);
         InternalManagedConnectionPool imcp = (InternalManagedConnectionPool)cl.getContext();
         cm.returnManagedConnection(cl, true);

         // Shutdown the pool in order to trigger the RetryableResourceException
         imcp.shutdown();

         // Get a connection - new internal managed pool is created
         cl = cm.getManagedConnection(null, null);
         assertTrue("2: Got a null connection!", cl.getManagedConnection() != null);
         cm.returnManagedConnection(cl, true);
      }
      finally
      {
         shutdown(cm);
View Full Code Here

         ManagedConnectionPool ps = cm.getPoolingStrategy();

         assertTrue("0: Initial check", ps.getConnectionCount() == 0);

         // Get a connection
         ConnectionListener cl = cm.getManagedConnection(null, null);
         assertTrue("1: Got a null connection!", cl.getManagedConnection() != null);
         assertTrue("1: One connection", ps.getConnectionCount() == 1);

         // Get another connection
         ConnectionListener cl2 = cm.getManagedConnection(null, null);
         assertTrue("2: Got a null connection!", cl2.getManagedConnection() != null);
         assertTrue("2: Two connections", ps.getConnectionCount() == 2);

         // Return first
         cm.returnManagedConnection(cl, true);
         assertTrue("3: One connection", ps.getConnectionCount() == 1);
View Full Code Here

      try
      {
         ArrayList cs = new ArrayList();
         for (int i = 0; i < pp.maxSize; i++)
         {
            ConnectionListener cl = cm.getManagedConnection(null, null);
            assertTrue("Got a null connection!", cl.getManagedConnection() != null);
            cs.add(cl);
         } // end of for ()
         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);
         try
         {
View Full Code Here

         for (Iterator i =  mcs.iterator(); i.hasNext(); )
            cm.returnManagedConnection((ConnectionListener)i.next(), false);

         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);
         Thread.sleep(1500);
         ConnectionListener cl = cm.getManagedConnection(subject, cri);
         cm.returnManagedConnection(cl, false);

         // Let the idle remover kick in
         Thread.sleep(1500);
         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == 1);
View Full Code Here

      pp.blockingTimeout = 10;
      pp.idleTimeout = 2000;
      BaseConnectionManager2 cm = getCM(pp);
      try
      {
         ConnectionListener cl = cm.getManagedConnection(subject, cri);
         cm.returnManagedConnection(cl, false);
         // Allow fill to min to work
         Thread.sleep(1000);
         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.minSize);
         // Allow the idle remover to work
View Full Code Here

      pp.blockingTimeout = 10;
      pp.idleTimeout = 2000;
      BaseConnectionManager2 cm = getCM(pp);
      try
      {
         ConnectionListener cl = cm.getManagedConnection(subject, cri);
         cm.returnManagedConnection(cl, false);
         // Allow fill to min to work
         Thread.sleep(1000);
         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);
         // Allow the idle remover to work
View Full Code Here

      {
         // Checkout all the connections
         ArrayList cs = new ArrayList();
         for (int i = 0; i < pp.maxSize; i++)
         {
            ConnectionListener cl = cm.getManagedConnection(null, null);
            assertTrue("Got a null connection!", cl.getManagedConnection() != null);
            cs.add(cl);
         }
         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);

         // Reconfigure
         pp.maxSize = 6;
         pool.flush();

         // Put the connections back (should destroy/close them with no errors)
         for (Iterator i = cs.iterator(); i.hasNext();)
         {
            cm.returnManagedConnection((ConnectionListener)i.next(), true);
         }

         // Checkout all the connections with the new maximum size
         cs = new ArrayList();
         for (int i = 0; i < pp.maxSize; i++)
         {
            ConnectionListener cl = cm.getManagedConnection(null, null);
            assertTrue("Got a null connection!", cl.getManagedConnection() != null);
            cs.add(cl);
         }
         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);

         try
View Full Code Here

      try
      {
         ArrayList cs = new ArrayList();
         for (int i = 0; i < pp.maxSize; i++)
         {
            ConnectionListener cl = cm.getManagedConnection(null, null);
            assertTrue("Got a null connection!", cl.getManagedConnection() != null);
            cs.add(cl);
         }

         assertTrue("Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);
View Full Code Here

                     for (int i = 0; i < iterations; i++)
                     {
                        try
                        {
                           ConnectionListener cl = cm.getManagedConnection(null, null);
                           assertTrue("Got a null connection!", cl.getManagedConnection() != null);
                           cs.add(cl);
                        }
                        catch (ResourceException re)
                        {
                           failed = true;
                           failedDescription = "Failed to get a connection";
                           failedException = re;
                        }
                     }

                     assertEquals("1: Wrong number of connections", iterations, cs.size());

                     firstPart.countDown();

                     cont.await();

                     for (Iterator i = cs.iterator(); i.hasNext();)
                     {
                        cm.returnManagedConnection((ConnectionListener)i.next(), true);
                     }

                     done.countDown();
                  }
                  catch (InterruptedException ie)
                  {
                  }
               }
            };
            new Thread(t).start();
         }
         start.countDown();

         firstPart.await();
         assertTrue("2: Wrong number of connections counted: " + cm.getConnectionCount(), cm.getConnectionCount() == pp.maxSize);

         try
         {
            ConnectionListener cl = cm.getManagedConnection(null, null);
            cm.returnManagedConnection(cl, true);

            failedDescription = "Got a connection";
            failedException = new Exception(cl.toString());
            failed = true;
         }
         catch (ResourceException ignore)
         {
         }
View Full Code Here

TOP

Related Classes of org.jboss.resource.connectionmanager.ConnectionListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.