Examples of ConnectionListener


Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

    * @return True if possible; otherwise false
    */
   protected boolean internalTestConnection(Subject subject)
   {
      boolean result = false;
      ConnectionListener cl = null;
      try
      {
         if (((PoolStatisticsImpl)getStatistics()).getAvailableCount(true) > 0)
         {
            cl = getConnection(null, subject, null);
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

    */
   public void returnManagedConnection(org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener bcl,
                                       boolean kill)
   {
      // Hack - We know that we can type cast it
      ConnectionListener cl = (ConnectionListener)bcl;

      Pool localStrategy = cl.getPool();
      if (localStrategy != pool)
      {
         kill = true;
      }

      try
      {
         if (!kill && cl.getState().equals(ConnectionState.NORMAL))
         {
            cl.tidyup();
         }
      }
      catch (Throwable t)
      {
         log.errorDuringTidyUpConnection(cl, t);
         kill = true;
      }

      try
      {
         localStrategy.returnConnection(cl, kill);
      }
      catch (ResourceException re)
      {
         // We can receive notification of an error on the connection
         // before it has been assigned to the pool. Reduce the noise for
         // these errors
         if (kill)
         {
            log.debug("resourceException killing connection (error retrieving from pool?)", re);
         }
         else
         {
            log.resourceExceptionReturningConnection(cl.getManagedConnection(), re);
         }
      }
   }
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

            bundle.wrongManagedConnectionFactorySentToAllocateConnection(pool.getManagedConnectionFactory(), mcf));
      }

      // Pick a managed connection from the pool
      Subject subject = getSubject();
      ConnectionListener cl = getManagedConnection(subject, cri);

      // Tell each connection manager the managed connection is active
      reconnectManagedConnection(cl);

      // Ask the managed connection for a connection
      Object connection = null;
      try
      {
         connection = cl.getManagedConnection().getConnection(subject, cri);
      }
      catch (Throwable t)
      {
         try
         {
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

      Set<ConnectionListener> cls = new HashSet<ConnectionListener>(conRecords.size());
      for (Iterator<ConnectionRecord> i = conRecords.iterator(); i.hasNext();)
      {
         ConnectionRecord cr = i.next();
         ConnectionListener cl = cr.getConnectionListener();
         cr.setConnectionListener(null);
         unregisterAssociation(cl, cr.getConnection());
         if (!cls.contains(cl))
         {
            cls.add(cl);
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

            //This might well be an error.
            log.reconnectingConnectionHandleHasManagedConnection(
               cr.getConnectionListener().getManagedConnection(),
               cr.getConnection());
         }
         ConnectionListener cl = criToCLMap.get(cr.getCri());
         if (cl == null)
         {
            cl = getManagedConnection(getSubject(), cr.getCri());
            criToCLMap.put(cr.getCri(), cl);
            //only call once per managed connection, when we get it.
            reconnectManagedConnection(cl);
         }

         cl.getManagedConnection().associateConnection(cr.getConnection());
         registerAssociation(cl, cr.getConnection());
         cr.setConnectionListener(cl);
      }
   }
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

    * {@inheritDoc}
    */
   public ConnectionListener createConnectionListener(ManagedConnection managedConnection, Object context)
      throws ResourceException
   {
      ConnectionListener cli = new NoTxConnectionListener(this, managedConnection, getPool(),
                                                          context, getFlushStrategy());
      managedConnection.addConnectionEventListener(cli);

      return cli;
   }
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

      }

      subject = (subject == null) ? defaultSubject : subject;
      cri = (cri == null) ? defaultCri : cri;

      ConnectionListener cl = null;
      boolean verifyConnectionListener = true;

      long startWait = System.currentTimeMillis();
      if (cls.size() > 0)
      {
         if (shutdown.get())
            throw new RetryableUnavailableException(
               bundle.thePoolHasBeenShutdown(pool.getName(),
                                             Integer.toHexString(System.identityHashCode(this))));
        
         cl = cls.peek();
         if (cl != null)
         {
            try
            {
               cl = cls.poll(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS);
               statistics.deltaTotalBlockingTime(System.currentTimeMillis() - startWait);
            }
            catch (InterruptedException ie)
            {
               Thread.interrupted();

               long end = System.currentTimeMillis() - startWait;
               throw new ResourceException(bundle.interruptedWhileRequestingConnection(end));
            }
         }
         else
         {
            try
            {
               // No, the pool was empty, so we have to make a new one.
               cl = createConnectionEventListener(subject, cri);

               if (trace)
                  log.trace("supplying new ManagedConnection: " + cl);
              
               verifyConnectionListener = false;
            }
            catch (Throwable t)
            {
               log.throwableWhileAttemptingGetNewGonnection(cl, t);

               throw new ResourceException(bundle.unexpectedThrowableWhileTryingCreateConnection(cl), t);
            }
         }
      }
      else
      {
         try
         {
            cl = cls.poll(poolConfiguration.getBlockingTimeout(), TimeUnit.MILLISECONDS);
            statistics.deltaTotalBlockingTime(System.currentTimeMillis() - startWait);

            if (shutdown.get())
               throw new RetryableUnavailableException(
                  bundle.thePoolHasBeenShutdown(pool.getName(),
                                                Integer.toHexString(System.identityHashCode(this))));
         }
         catch (InterruptedException ie)
         {
            Thread.interrupted();

            if (!poolConfiguration.isUseFastFail())
            {
               throw new ResourceException(bundle.noMManagedConnectionsAvailableWithinConfiguredBlockingTimeout(
                     poolConfiguration.getBlockingTimeout()));
            }
            else
            {
               if (trace)
                  log.trace("Fast failing for connection attempt. No more attempts will be made to " +
                            "acquire connection from pool and a new connection will be created immeadiately");

               try
               {
                  cl = createConnectionEventListener(subject, cri);
              
                  if ((poolConfiguration.isPrefill() || poolConfiguration.isStrictMin()) &&
                      pool instanceof PrefillPool &&
                      poolConfiguration.getMinSize() > 0)
                     PoolFiller.fillPool(this);
              
                  if (trace)
                     log.trace("supplying new ManagedConnection: " + cl);
              
                  verifyConnectionListener = false;
               }
               catch (Throwable t)
               {
                  log.throwableWhileAttemptingGetNewGonnection(cl, t);

                  throw new ResourceException(bundle.unexpectedThrowableWhileTryingCreateConnection(cl), t);
               }
            }
         }
      }

      // Register the connection listener
      checkedOut.add(cl);

      // Update in used statistics
      statistics.setInUsedCount(checkedOut.size());
     
      if (!verifyConnectionListener)
      {
         // Return connection listener
         return cl;
      }
      else
      {
         try
         {
            Object matchedMC =
               mcf.matchManagedConnections(Collections.singleton(cl.getManagedConnection()), subject, cri);

            if (matchedMC != null)
            {
               if (trace)
                  log.trace("supplying ManagedConnection from pool: " + cl);
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

      if (kill)
      {
         // Mark checked out connections as requiring destruction
         while (checkedOut.size() > 0)
         {
            ConnectionListener cl = checkedOut.pollFirst();

            if (trace)
               log.trace("Flush marking checked out connection for destruction " + cl);

            cl.setState(ConnectionState.DESTROY);

            if (destroy == null)
               destroy = new ArrayList<ConnectionListener>(1);

            destroy.add(cl);
         }
      }

      // Destroy connections in the pool
      ConnectionListener cl = cls.poll();
      while (cl != null)
      {
         if (destroy == null)
            destroy = new ArrayList<ConnectionListener>();
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

     
      boolean cont = true;
      while (cont)
      {
         // Check the first in the list
         ConnectionListener cl = cls.peek();
         if (cl != null && cl.isTimedOut(timeout) && shouldRemove())
         {
            statistics.deltaTimedOut();

            // We need to destroy this one
            if (destroy == null)
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.listener.ConnectionListener

            statistics.setInUsedCount(checkedOut.size());
            return;
         }

         // Create a connection to fill the pool
         ConnectionListener cl = null;
         boolean destroy = false;
         try
         {
            cl = createConnectionEventListener(defaultSubject, defaultCri);
            statistics.setInUsedCount(checkedOut.size() + 1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.