public class ConnectPool extends Object
Задачи
| Modifier and Type | Field and Description |
|---|---|
protected LinkedBlockingQueue<DataEvent> |
eventQueue |
protected DataEventSupport |
eventSupport |
protected WeakHashMap<DataSource,ConnectOptions> |
options |
protected EventList<ConnectionPoolService> |
services |
protected WeakHashMap<Statement,Long> |
statementCreateTime |
protected WeakHashMap<Statement,Connection> |
statements |
| Constructor and Description |
|---|
ConnectPool() |
ConnectPool(ConnectionPoolService... services) |
protected final transient DataEventSupport eventSupport
protected final transient LinkedBlockingQueue<DataEvent> eventQueue
protected final EventList<ConnectionPoolService> services
protected final WeakHashMap<Statement,Connection> statements
protected final WeakHashMap<Statement,Long> statementCreateTime
protected WeakHashMap<DataSource,ConnectOptions> options
public ConnectPool()
public ConnectPool(ConnectionPoolService... services)
public Closeable addDataEventListener(DataEventListener ls, boolean weak)
public Closeable addDataEventListener(DataEventListener ls)
public void removeDataEventListener(DataEventListener ls)
public boolean hasDataEventListener(DataEventListener ls)
public DataEventListener[] getDataEventListeners()
public void fireDataEvent(DataEvent event)
public void addDataEvent(DataEvent ev)
public void fireEventQueue()
public int getId()
public EventList<ConnectionPoolService> getServices()
public Timer getTimer()
protected void finalize()
throws Throwable
public void closeAll()
public void closeAllStatements(boolean addEvents)
addEvents - true - Добавить сообщения в очередь.public void closeAllConnections(boolean addEvents)
addEvents - true - Добавить сообщения в очередь.public void shutdown()
public void shutdown(boolean addEvents)
addEvents - true - Добавить сообщения в очередь.public EventMap<String,DataSource> getSources()
public boolean isSkipRegistered()
public void setSkipRegistered(boolean skipRegistered)
public void registerSource(String name, DataSource ds)
name - Имя истоничкаds - Источник данныхregisterSource(java.lang.String, javax.sql.DataSource, xyz.cofe.sql.ConnectOptions)public void registerSource(String name, DataSource ds, ConnectOptions copt)
Если источник уже зарегистрирован и свойство skipRegistered = true, то новых источник не регистрируется.
Если skipRegistered = false, то источник данных регистриуется (перетерая ранее зарегистрированный одноименный, если есть)
name - Имя истоничкаds - Источник данныхcopt - Опции соединения или nullpublic Set<String> namesOf(DataSource ds)
ds - источник данныхpublic String nameOf(DataSource ds)
ds - источник данныхpublic Set<String> namesOf(Connection conn)
conn - соединение с СУБДpublic String nameOf(Connection conn)
conn - соединение с СУБДpublic Set<Connection> getConnections(boolean autoCreateProxy)
autoCreateProxy - true - Автоматически создавать PROXY объектpublic Set<Connection> getSourceConnections()
Аналогично: getConnections(false)
public Set<Connection> getConnections()
Аналогично: getConnections(true)
public Map<DataSource,Set<Connection>> getConnectionsMap(boolean autoCreateProxy)
autoCreateProxy - true - Автоматически создавать PROXY для соединенийpublic Map<DataSource,Set<Connection>> getSourceConnectionsMap()
Аналогично: getConnectionsMap(false)
public Map<DataSource,Set<Connection>> getConnectionsMap()
Аналогично: getConnectionsMap(true)
public int getTotalConnectionsCount()
public Set<Connection> getOpenConnections(boolean autoCreateProxy)
autoCreateProxy - true - автоматически создавать PROXYpublic int getOpenConnectionsCount()
public GenericProxy.Builder proxyBuilder(Method meth, Statement st)
public GenericProxy.Builder proxyBuilder(Statement st)
public Statement proxy(Method meth, Connection conn, Statement st)
public Statement proxy(Connection conn, Statement st)
public PreparedStatement proxy(Connection conn, PreparedStatement st)
public CallableStatement proxy(Connection conn, CallableStatement st)
public Map<Connection,Set<Statement>> getStatementsMap(boolean autoCreateProxy)
public void registerStatement(Connection conn, Statement st)
public long createTimeOf(Connection conn)
public ConnectOptions getDefaultOptions()
public WeakHashMap<Object,InvokeActivityStat> getInvokeStats()
public InvokeActivityStat activityStatOf(Connection conn)
public InvokeActivityStat activityStatOf(Statement stmt)
public InvokeActivityStat activityStatOf(PreparedStatement stmt)
public InvokeActivityStat activityStatOf(CallableStatement stmt)
public ConnectOptions optionsOf(DataSource ds)
public ConnectOptions optionsOf(Connection conn)
public ConnectOptions optionsOf(Statement st)
public Connection sourceOf(Connection conn)
public CallableStatement sourceOf(CallableStatement conn)
public PreparedStatement sourceOf(PreparedStatement conn)
public <T> T sourceOf(Class<? extends T> cls, T obj)
public boolean isProxy(Object conn)
public Statement proxy(Connection conn, Statement st, ConnectOptions copts)
public Connection proxy(Connection conn, ConnectOptions copts)
public Connection connect(String source) throws SQLException
SQLExceptionpublic Connection connect(String source, String username, String password) throws SQLException
SQLExceptionpublic void removeClosedConnections()
public void removeClosedConnections(boolean addEvents)
public void removeClosedStatements()
public void removeClosedStatements(boolean addEvents)
Copyright © 2018. All rights reserved.