dbpool.java

来自「RESIN 3.2 最新源码」· Java 代码 · 共 826 行 · 第 1/2 页

JAVA
826
字号
  /**   * Get the time in milliseconds a connection will remain in the pool before   * being closed.   */  public long getMaxIdleTime()  {    return _connectionPool.getMaxIdleTime();  }  /**   * Set the time in milliseconds a connection will remain in the pool before   * being closed.   */  public void setMaxIdleTime(Period idleTime)  {    _connectionPool.setMaxIdleTime(idleTime.getPeriod());  }  /**   * Get the time in milliseconds a connection will remain in the pool before   * being closed.   */  public long getMaxPoolTime()  {    return _connectionPool.getMaxPoolTime();  }  /**   * Set the time in milliseconds a connection will remain in the pool before   * being closed.   */  public void setMaxPoolTime(Period maxPoolTime)  {    _connectionPool.setMaxPoolTime(maxPoolTime.getPeriod());  }  /**   * Get the time in milliseconds a connection can remain active.   */  public long getMaxActiveTime()  {    return _connectionPool.getMaxActiveTime();  }  /**   * Set the time in milliseconds a connection can remain active.   */  public void setMaxActiveTime(Period maxActiveTime)  {    _connectionPool.setMaxActiveTime(maxActiveTime.getPeriod());  }  /**   * Get the table to 'ping' to see if the connection is still live.   */  public String getPingTable()  {    return getPool().getPingTable();  }  /**   * Set the table to 'ping' to see if the connection is still live.   *   * @param pingTable name of the SQL table to ping.   */  public void setPingTable(String pingTable)  {    getPool().setPingTable(pingTable);  }  /**   * Set the query to 'ping' to see if the connection is still live.   *   * @param pingQuery SQL to use for ping.   */  public void setPingQuery(String pingQuery)  {    getPool().setPingQuery(pingQuery);  }  /**   * If true, the pool will ping when attempting to reuse a connection.   */  public boolean getPingOnReuse()  {    return getPool().getPingOnReuse();  }  /**   * Set the table to 'ping' to see if the connection is still live.   */  public void setPingOnReuse(boolean pingOnReuse)  {    getPool().setPingOnReuse(pingOnReuse);  }  /**   * If true, the pool will ping in the idle pool.   */  public boolean getPingOnIdle()  {    return getPool().getPingOnIdle();  }  /**   * Set the table to 'ping' to see if the connection is still live.   */  public void setPingOnIdle(boolean pingOnIdle)  {    getPool().setPingOnIdle(pingOnIdle);  }  /**   * Set the table to 'ping' to see if the connection is still live.   */  public void setPing(boolean ping)  {    getPool().setPing(ping);  }  /**   * Sets the time to ping for ping-on-idle   */  public void setPingInterval(Period interval)  {    getPool().setPingInterval(interval);  }  /**   * Gets how often the ping for ping-on-idle   */  public long getPingInterval() {    return getPool().getPingInterval();  }  /**   * Returns the prepared statement cache size.   */  public int getPreparedStatementCacheSize()  {    return getPool().getPreparedStatementCacheSize();  }  /**   * Sets the prepared statement cache size.   */  public void setPreparedStatementCacheSize(int size)  {    getPool().setPreparedStatementCacheSize(size);  }  /**   * Set the transaction manager for this pool.   */  public void setTransactionManager(TransactionManagerImpl tm)  {    getPool().setTransactionManager(tm);  }  /**   * Set true if statement should be wrapped.   */  public void setWrapStatements(boolean isWrap)  {    getPool().setWrapStatements(isWrap);  }  /**   * Returns the transaction manager.   */  /*  public TransactionManager getTransactionManager()  {    return getPool().getTransactionManager();  }  */  /**   * Sets the transaction timeout.   */  public void setTransactionTimeout(Period period)  {    getPool().setTransactionTimeout(period);  }  /**   * Returns true if this is transactional.   */  public boolean isXA()  {    return getPool().isXA();  }  /**   * Returns true if this is transactional.   */  public void setXA(boolean isTransactional)  {    getPool().setXA(isTransactional);  }  /**   * Returns true if this is transactional.   */  public void setXAForbidSameRM(boolean isXAForbidSameRM)  {    getPool().setXAForbidSameRM(isXAForbidSameRM);  }  /**   * Set the output for spying.   */  public void setSpy(boolean isSpy)    throws IOException  {    getPool().setSpy(isSpy);  }  /**   * HandleAware callback to set the webbeans handle for serialization   */  public void setSerializationHandle(Object handle)  {    _serializationHandle = handle;  }  /**   * Initialize the pool.   */  @PostConstruct  public void init()    throws Exception  {    _localPoolImpl = new EnvironmentLocal<DBPoolImpl>("caucho.db-pool." + getName());    _localPoolImpl.set(_poolImpl);    _poolImpl.init();    _connectionPool.setName(getName());    _connectionPool.setShareable(true);    _connectionPool.setXATransaction(_poolImpl.isXATransaction());    _connectionPool.setLocalTransaction(_poolImpl.isLocalTransaction());    ManagedConnectionFactory mcf = _poolImpl.getManagedConnectionFactory();            _dataSource = (DataSource) _connectionPool.init(mcf);    _connectionPool.start();    _localDataSourceImpl = new EnvironmentLocal<DataSource>("caucho.data-source." + getName());    _localDataSourceImpl.set(_dataSource);    if (_jndiName != null) {      String name = _jndiName;      Jndi.bindDeepShort(name, this);    }    String name = _name;        if (name == null)      name = _jndiName;        if (name == null)      name = _var;    if (name != null)      WebBeansContainer.create().addSingleton(this, name);    else      WebBeansContainer.create().addSingleton(this); }  /**   * Returns a new or pooled connection.   */  public Connection getConnection() throws SQLException  {    return getDataSource().getConnection();  }  /**   * Return a connection.  The connection will only be pooled if   * user and password match the configuration.  In general, applications   * should use the null-argument getConnection().   *   * @param user database user   * @param password database password   * @return a database connection   */  public Connection getConnection(String user, String password)    throws SQLException  {    return getDataSource().getConnection(user, password);  }  /**   * Clears the pool.   */  public void closeIdleConnections()  {    ConnectionPool connectionPool = _connectionPool;        if (connectionPool != null)      connectionPool.clear();  }    /*   * Closes the specified connection and removes from the pool.   */  public void markForPoolRemoval(ManagedConnectionImpl mConn)  {    _connectionPool.markForPoolRemoval(mConn);  }  /**   * Returns the login timeout   */  public int getLoginTimeout() throws SQLException  {    return getDataSource().getLoginTimeout();  }  /**   * Sets the login timeout   */  public void setLoginTimeout(int timeout) throws SQLException  {    getDataSource().setLoginTimeout(timeout);  }  /**   * Gets the log writer   */  public PrintWriter getLogWriter() throws SQLException  {    return getDataSource().getLogWriter();  }  /**   * Sets the log writer   */  public void setLogWriter(PrintWriter log) throws SQLException  {    getDataSource().setLogWriter(log);  }  /**   * Returns the underlying pool.   */  private DBPoolImpl getPool()  {    if (_poolImpl == null || _poolImpl.isClosed()) {      _poolImpl = _localPoolImpl.get();      if (_poolImpl == null)        throw new IllegalStateException(L.l("DBPool `{0}' no longer exists.",                                            getName()));    }    return _poolImpl;  }  /**   * Returns the underlying data source.   */  private DataSource getDataSource()  {    if (_dataSource == null ||	_resinDataSource != null && _resinDataSource.isClosed()) {      _dataSource = _localDataSourceImpl.get();      if (_dataSource instanceof DataSourceImpl)	_resinDataSource = (DataSourceImpl) _dataSource;      else	_resinDataSource = null;      if (_dataSource == null)        throw new IllegalStateException(L.l("DBPool `{0}' no longer exists.",                                            getName()));    }    return _dataSource;  }  public <T> T unwrap(Class<T> iface) throws SQLException {    throw new UnsupportedOperationException("Not supported yet.");  }  public boolean isWrapperFor(Class<?> iface) throws SQLException {    throw new UnsupportedOperationException("Not supported yet.");  }  /**   * For serialization, return the handle   */  private Object writeReplace()  {    return _serializationHandle;  }  /**   * Returns a string description of the pool.   */  public String toString()  {    return "DBPool[" + getName() + "]";  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?