コード例 #1
0
  /** Allocates a connection. */
  private Object allocateConnection(
      ManagedConnectionFactory mcf, Subject subject, ConnectionRequestInfo info)
      throws ResourceException {
    UserPoolItem userPoolItem = null;

    try {
      while (true) {
        userPoolItem = null;
        UserTransactionImpl transaction = _tm.getUserTransaction();

        if (transaction != null) userPoolItem = allocateShared(transaction, mcf, subject, info);

        if (userPoolItem == null) userPoolItem = allocatePoolConnection(mcf, subject, info, null);

        Object userConn;

        userConn = userPoolItem.allocateUserConnection();

        if (userConn != null) {
          userPoolItem = null;
          return userConn;
        }

        userPoolItem.close();
      }
    } finally {
      if (userPoolItem != null) userPoolItem.close();
    }
  }
コード例 #2
0
  private void fillIdlePool() {
    int count = _minIdleCount;

    try {
      while (_connectionPool.size() < _minIdleCount && count-- >= 0 && _lifecycle.isActive()) {
        Subject subject = null;
        ConnectionRequestInfo info = null;

        UserPoolItem userPoolItem;

        userPoolItem = createConnection(_mcf, subject, info, null);

        if (userPoolItem != null) userPoolItem.toIdle();
      }
    } catch (Exception e) {
      e.printStackTrace();

      log.log(Level.FINE, e.toString(), e);
    }
  }