Package org.jboss.resource.connectionmanager

Examples of org.jboss.resource.connectionmanager.ManagedConnectionPool


      pp.idleTimeout = 500;

      BaseConnectionManager2 cm = getCM(pp);
      try
      {
         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);

         // Return second
         cm.returnManagedConnection(cl2, true);
         assertTrue("4: Zero connections", ps.getConnectionCount() == 0);
      }
      finally
      {
         shutdown(cm);
      }
View Full Code Here


      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
      pp.minSize = 0;
      pp.maxSize = poolSize;
      pp.blockingTimeout = 100;
      pp.idleTimeout = 500;
      ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.OnePool(mcf, pp, false, poolLog);
      cri = new TestConnectionRequestInfo();
      cm = new TxConnectionManager(ccm, poolingStrategy, tm);
      cm.setLocalTransactions(true);
      poolingStrategy.setConnectionListenerFactory(cm);
   }
View Full Code Here

      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
      pp.minSize = 0;
      pp.maxSize = poolSize;
      pp.blockingTimeout = 100;
      pp.idleTimeout = 500;
      ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.OnePool(mcf, pp, false, poolLog);
      cri = new TestConnectionRequestInfo();
      cm = new TxConnectionManager(ccm, poolingStrategy, tm);
      cm.setLocalTransactions(false);
      cm.setInterleaving(true);
      poolingStrategy.setConnectionListenerFactory(cm);
   }
View Full Code Here

   }

   private BaseConnectionManager2 getCM(InternalManagedConnectionPool.PoolParams pp, int ar, int arwm) throws Exception
   {
      ManagedConnectionFactory mcf = new TestManagedConnectionFactory();
      ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
      BaseConnectionManager2 cm = new NoTxConnectionManager(ccm, poolingStrategy);
      cm.setAllocationRetry(ar);
      cm.setAllocationRetryWaitMillis(arwm);
      poolingStrategy.setConnectionListenerFactory(cm);
     
      if (pp.prefill)
      {
         BasePool bp = (BasePool)poolingStrategy;
         bp.prefill(null, null, false);
View Full Code Here

   private BaseConnectionManager2 getCM(
      InternalManagedConnectionPool.PoolParams pp)
      throws Exception
   {
      ManagedConnectionFactory mcf = new TestManagedConnectionFactory();
      ManagedConnectionPool poolingStrategy = new TestPool(mcf, pp, false, log);
      BaseConnectionManager2 cm = new NoTxConnectionManager(ccm, poolingStrategy);
      poolingStrategy.setConnectionListenerFactory(cm);
      return cm;
   }
View Full Code Here

      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
      pp.minSize = 1;
      pp.maxSize = 2;
      pp.blockingTimeout = 10000;

      ManagedConnectionPool mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
      NoTxConnectionManager noTxn = new NoTxConnectionManager(null, mcp);
      mcp.setConnectionListenerFactory(noTxn);
      Connection conn = (Connection)noTxn.allocateConnection(mcf, null);
      Object proxy = ((WrappedConnection)conn).getUnderlyingConnection();
      TestConnection uc = (TestConnection) Proxy.getInvocationHandler(proxy);
      uc.setFail(true);
     
View Full Code Here

      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
      pp.minSize = 1;
      pp.maxSize = 2;
      pp.blockingTimeout = 10000;

      ManagedConnectionPool mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
      NoTxConnectionManager noTxn = new NoTxConnectionManager(null, mcp);
      mcp.setConnectionListenerFactory(noTxn);
      Connection conn = (Connection)noTxn.allocateConnection(mcf, null);
      Object proxy = ((WrappedConnection)conn).getUnderlyingConnection();
      TestConnection uc = (TestConnection) Proxy.getInvocationHandler(proxy);
      uc.setFail(true);
     
      try
      {
         conn.createStatement().execute("blah");
        
      }catch(SQLException e)
      {
         //Normal
         assertFalse("Should not be StaleConnectionException", e instanceof StaleConnectionException);
         assertTrue("Connection error should be fatal", mcp.getConnectionDestroyedCount() > 0);
        
      }
     
      assertTrue("Exception should be falal", mcp.getConnectionDestroyedCount() > 0);     

   }
View Full Code Here

      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();
      pp.minSize = 1;
      pp.maxSize = 2;
      pp.blockingTimeout = 10000;

      ManagedConnectionPool mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);
      NoTxConnectionManager noTxn = new NoTxConnectionManager(null, mcp);
      mcp.setConnectionListenerFactory(noTxn);
      Connection conn = (Connection)noTxn.allocateConnection(mcf, null);
      Object proxy = ((WrappedConnection)conn).getUnderlyingConnection();
      TestConnection uc = (TestConnection) Proxy.getInvocationHandler(proxy);
      uc.setFail(true);
     
      try
      {
         conn.createStatement().execute("blah");
        
      }catch(SQLException e)
      {
         //Normal
         assertTrue("Should be StaleConnectionException", e instanceof StaleConnectionException);
        
      }
     
      assertTrue("StaleConnectionException should not destroy connection", mcp.getConnectionDestroyedCount() == 0);     
     
   }
View Full Code Here

      mcf = new TestManagedConnectionFactory();

      InternalManagedConnectionPool.PoolParams pp = new InternalManagedConnectionPool.PoolParams();

      ManagedConnectionPool poolingStrategy = new JBossManagedConnectionPool.OnePool(mcf, pp, false, log);

      cm = new TxConnectionManager(ccm, poolingStrategy, tm);

      poolingStrategy.setConnectionListenerFactory(cm);

      MBeanServer server = MBeanServerLocator.locateJBoss();
      ObjectName onTM = new ObjectName("jboss:service=TransactionManager");

      txTimeout = ((Integer)server.getAttribute(onTM, "TransactionTimeout")).intValue();
View Full Code Here

  
   public static ManagedConnectionPool getManagedConnectionPool(PoolType type, ManagedConnectionFactory mcf,
         boolean noTxnSeperatePool, InternalManagedConnectionPool.PoolParams pp, Logger log)
   {

      ManagedConnectionPool mcp = null;

      if (type.equals(PoolType.ONE_POOL))
      {

         mcp = new JBossManagedConnectionPool.OnePool(mcf, pp, noTxnSeperatePool, null, log);
View Full Code Here

TOP

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

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.