|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.logicalcobwebs.proxool.ProxoolFacade
public class ProxoolFacade
This provides some nice-to-have features that can't be provided by the
Driver
implementation
of java.sql.Driver. Like starting up
a pool before you need a connection. And getting statistical information.
You need to use this class wisely. It is obviously specfic to proxool so it will stop you switching to another driver. Consider isolating the code that calls this class so that you can easily remove it if you have to.
Constructor Summary | |
---|---|
ProxoolFacade()
|
Method Summary | |
---|---|
static void |
addConfigurationListener(java.lang.String alias,
ConfigurationListenerIF configurationListener)
Adds a listener that gets called everytime the configuration changes. |
static void |
addConnectionListener(java.lang.String alias,
ConnectionListenerIF connectionListener)
Add a listener that monitors each time a connection is made or destroyed. |
static void |
addProxoolListener(ProxoolListenerIF proxoolListener)
Add a listener that gets called everytime a global Proxool event ocours. |
static void |
addStateListener(java.lang.String alias,
StateListenerIF stateListener)
Add a listener that monitors the change of state of the pool (quiet, busy, overloaded, or down) |
static void |
addStatisticsListener(java.lang.String alias,
org.logicalcobwebs.proxool.admin.StatisticsListenerIF statisticsListener)
Add a listener that receives statistics as they are produced |
static java.lang.String |
getAlias(java.sql.Connection connection)
Get the alias for the connection pool that served a connection |
static java.lang.String[] |
getAliases()
Get a list of all the registered pools |
static java.util.Collection |
getConnectionInfos(java.lang.String alias)
Deprecated. use snapshot instead. |
static ConnectionPoolDefinitionIF |
getConnectionPoolDefinition(java.lang.String alias)
Get the definition of a pool. |
static ConnectionPoolStatisticsIF |
getConnectionPoolStatistics(java.lang.String alias)
Deprecated. use getSnapshot(java.lang.String, boolean) |
static java.lang.String |
getConnectionPoolStatisticsDump(java.lang.String alias)
Deprecated. use getSnapshot(java.lang.String, boolean) |
static java.sql.Connection |
getDelegateConnection(java.sql.Connection connection)
Deprecated. Just cast the connection that you are given into the driver specific one. |
static java.sql.Statement |
getDelegateStatement(java.sql.Statement statement)
Deprecated. Just cast the statement that you are given into the driver specific one. |
static long |
getId(java.sql.Connection connection)
Get the connection ID for a connection |
static org.logicalcobwebs.proxool.admin.SnapshotIF |
getSnapshot(java.lang.String alias)
Calls getSnapshot
using false for the detail parameter. |
static org.logicalcobwebs.proxool.admin.SnapshotIF |
getSnapshot(java.lang.String alias,
boolean detail)
Gives a snapshot of what the pool is doing |
static org.logicalcobwebs.proxool.admin.StatisticsIF[] |
getStatistics(java.lang.String alias)
Get all the lastest performance statistics for this pool |
static org.logicalcobwebs.proxool.admin.StatisticsIF |
getStatistics(java.lang.String alias,
java.lang.String token)
Get a particular set of performance statistics for this pool |
static void |
killAllConnections(java.lang.String alias)
Deprecated. use alternative
to provide better auditing in log |
static void |
killAllConnections(java.lang.String alias,
boolean merciful)
Deprecated. use alternative
to provide better auditing in log |
static void |
killAllConnections(java.lang.String alias,
java.lang.String reason)
Like killAllConnections(java.lang.String, boolean) but defaults to merciful. |
static void |
killAllConnections(java.lang.String alias,
java.lang.String reason,
boolean merciful)
Kill all connections in a pool. |
static boolean |
killConnecton(java.sql.Connection connection,
boolean merciful)
Kill a single connection |
static boolean |
killConnecton(java.lang.String alias,
long id,
boolean merciful)
Kill a single connection |
static void |
redefineConnectionPool(java.lang.String url,
java.util.Properties info)
Redefine the behaviour of the pool. |
static void |
registerConnectionPool(java.lang.String url)
With no configurator or properties (using default values) |
static java.lang.String |
registerConnectionPool(java.lang.String url,
java.util.Properties info)
Build a ConnectionPool based on this definition and then start it. |
static void |
removeAllConnectionPools(int delay)
Deprecated. use the better named shutdown() instead. |
static boolean |
removeConfigurationListener(java.lang.String alias,
ConfigurationListenerIF configurationListener)
Remove a listener that gets called everytime the configuration changes. |
static boolean |
removeConnectionListener(java.lang.String alias,
ConnectionListenerIF connectionListener)
Remove a listener that monitors each time a connection is made or destroyed. |
static void |
removeConnectionPool(java.lang.String alias)
Like removeConnectionPool(java.lang.String, int) but uses no delay. |
static void |
removeConnectionPool(java.lang.String alias,
int delay)
Remove a connection pool. |
static boolean |
removeProxoolListener(ProxoolListenerIF proxoolListener)
Remove a registered ProxoolListenerIF . |
boolean |
removeStateListener(java.lang.String alias,
StateListenerIF stateListener)
Remove a listener that monitors the change of state of the pool (quiet, busy, overloaded, or down) |
static void |
setConfigurationListener(java.lang.String alias,
ConfigurationListenerIF configurationListener)
Deprecated. use addConfigurationListener(String, ConfigurationListenerIF) instead. |
static void |
setConnectionListener(java.lang.String alias,
ConnectionListenerIF connectionListener)
Deprecated. use addConnectionListener(String, ConnectionListenerIF) instead. |
static void |
setStateListener(java.lang.String alias,
StateListenerIF stateListener)
Deprecated. use addStateListener(String, StateListenerIF) instead. |
static void |
shutdown()
Removes all connection pools. |
static void |
shutdown(int delay)
Removes all connection pools. |
static void |
updateConnectionPool(java.lang.String url,
java.util.Properties info)
Update the behaviour of the pool. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ProxoolFacade()
Method Detail |
---|
public static java.lang.String registerConnectionPool(java.lang.String url, java.util.Properties info) throws ProxoolException
url
- defines the delegate driver and delegate url.info
- the properties used to configure Proxool (and any for the delegate driver too) - optional
ProxoolException
- if anything goes wrongpublic static void registerConnectionPool(java.lang.String url) throws ProxoolException
ProxoolException
registerConnectionPool(java.lang.String, java.util.Properties)
public static void removeConnectionPool(java.lang.String alias, int delay) throws ProxoolException
alias
- the pool to removedelay
- the time to wait for connections to become inactive before killing it (milliseconds)
ProxoolException
- if we couldn't find the poolpublic static void removeAllConnectionPools(int delay)
shutdown()
instead.
delay
- the time to wait for connections to become inactive before killing it (milliseconds)public static void shutdown()
shutdown(java.lang.String, int)
but passes the current thread name
and a delay of zero.
public static void shutdown(int delay)
shutdown(java.lang.String, int)
but passes the current thread name.
delay
- the time to wait for connections to become inactive before killing it (milliseconds)public static void removeConnectionPool(java.lang.String alias) throws ProxoolException
removeConnectionPool(java.lang.String, int)
but uses no delay. (Kills
everything as quickly as possible).
alias
- to identify the pool
ProxoolException
- if we couldn't find the poolpublic static ConnectionPoolStatisticsIF getConnectionPoolStatistics(java.lang.String alias) throws ProxoolException
getSnapshot(java.lang.String, boolean)
alias
- to identify the pool
ProxoolException
- if we couldn't find the poolpublic static java.lang.String getConnectionPoolStatisticsDump(java.lang.String alias) throws ProxoolException
getSnapshot(java.lang.String, boolean)
alias
- to identify the pool
ProxoolException
- if we couldn't find the poolpublic static ConnectionPoolDefinitionIF getConnectionPoolDefinition(java.lang.String alias) throws ProxoolException
alias
- identifies the pool
ProxoolException
- if we couldn't find the poolpublic static java.util.Collection getConnectionInfos(java.lang.String alias) throws ProxoolException
snapshot
instead.
alias
- identifies the pool
ConnectionInfoIFs
ProxoolException
- if we couldn't find the poolpublic static void killAllConnections(java.lang.String alias, boolean merciful) throws ProxoolException
alternative
to provide better auditing in log
alias
- the pool containing the connectionmerciful
- if true will only kill connections that aren't active
ProxoolException
- if we couldn't find the poolpublic static void killAllConnections(java.lang.String alias, java.lang.String reason, boolean merciful) throws ProxoolException
alias
- the pool containing the connectionreason
- provides audit in log of why connections were killedmerciful
- if true will only kill connections that aren't active
ProxoolException
- if we couldn't find the poolpublic static void killAllConnections(java.lang.String alias) throws ProxoolException
alternative
to provide better auditing in log
killAllConnections(java.lang.String, boolean)
but defaults to merciful.
alias
- to identify the pool
ProxoolException
- if we couldn't find the poolpublic static void killAllConnections(java.lang.String alias, java.lang.String reason) throws ProxoolException
killAllConnections(java.lang.String, boolean)
but defaults to merciful.
alias
- to identify the poolreason
- provides audit in log of why connections were killed
ProxoolException
- if we couldn't find the poolpublic static boolean killConnecton(java.lang.String alias, long id, boolean merciful) throws ProxoolException
alias
- the pool containing the connectionid
- the id of the specific connectionmerciful
- if true will only kill connections that aren't active
ProxoolException
- if we couldn't find the poolpublic static boolean killConnecton(java.sql.Connection connection, boolean merciful) throws ProxoolException
connection
- the connection to killmerciful
- if true will only kill connections that aren't active
ProxoolException
- if we didn't recognise the connectionpublic static void addProxoolListener(ProxoolListenerIF proxoolListener)
proxoolListener
- the listener to add.public static boolean removeProxoolListener(ProxoolListenerIF proxoolListener)
ProxoolListenerIF
.
proxoolListener
- the listener to remove.
public static void setStateListener(java.lang.String alias, StateListenerIF stateListener) throws ProxoolException
addStateListener(String, StateListenerIF)
instead.
ProxoolException
public static void addStateListener(java.lang.String alias, StateListenerIF stateListener) throws ProxoolException
alias
- identifies the poolstateListener
- the new listener
ProxoolException
- if we couldn't find the poolpublic boolean removeStateListener(java.lang.String alias, StateListenerIF stateListener) throws ProxoolException
alias
- identifies the poolstateListener
- the listener to be removed.
ProxoolException
- if we couldn't find the poolpublic static void setConnectionListener(java.lang.String alias, ConnectionListenerIF connectionListener) throws ProxoolException
addConnectionListener(String, ConnectionListenerIF)
instead.
ProxoolException
public static void addConnectionListener(java.lang.String alias, ConnectionListenerIF connectionListener) throws ProxoolException
alias
- identifies the poolconnectionListener
- the new listener
ProxoolException
- if we couldn't find the poolpublic static boolean removeConnectionListener(java.lang.String alias, ConnectionListenerIF connectionListener) throws ProxoolException
alias
- identifies the poolconnectionListener
- the listener to be removed
ProxoolException
- if we couldn't find the poolpublic static void setConfigurationListener(java.lang.String alias, ConfigurationListenerIF configurationListener) throws ProxoolException
addConfigurationListener(String, ConfigurationListenerIF)
instead.
ProxoolException
public static void addConfigurationListener(java.lang.String alias, ConfigurationListenerIF configurationListener) throws ProxoolException
alias
- identifies the poolconfigurationListener
- the new listener
ProxoolException
- if we couldn't find the poolpublic static boolean removeConfigurationListener(java.lang.String alias, ConfigurationListenerIF configurationListener) throws ProxoolException
alias
- identifies the pool.configurationListener
- the listener to be removed.
ProxoolException
- if we couldn't find the poolpublic static void redefineConnectionPool(java.lang.String url, java.util.Properties info) throws ProxoolException
url
- the url that defines the pool (or the abbreviated ""proxool.alias")info
- the new properties
ProxoolException
updateConnectionPool(java.lang.String, java.util.Properties)
public static void updateConnectionPool(java.lang.String url, java.util.Properties info) throws ProxoolException
url
- the url that defines the pool (or the abbreviated ""proxool.alias")info
- the new properties
ProxoolException
redefineConnectionPool(java.lang.String, java.util.Properties)
public static java.sql.Statement getDelegateStatement(java.sql.Statement statement) throws ProxoolException
ProxoolException
public static java.sql.Connection getDelegateConnection(java.sql.Connection connection) throws ProxoolException
ProxoolException
public static long getId(java.sql.Connection connection) throws ProxoolException
connection
- the connection that was served
ProxoolException
- if the connection wasn't recognised.public static java.lang.String getAlias(java.sql.Connection connection) throws ProxoolException
connection
- the connection that was served
ProxoolException
- if the connection wasn't recognised.public static java.lang.String[] getAliases()
public static org.logicalcobwebs.proxool.admin.StatisticsIF getStatistics(java.lang.String alias, java.lang.String token) throws ProxoolException
alias
- identifies the pooltoken
- identifies which set, as defined in the configuration (see definition
)
ProxoolException
- if we couldn't find the poolpublic static org.logicalcobwebs.proxool.admin.StatisticsIF[] getStatistics(java.lang.String alias) throws ProxoolException
alias
- identifies the pool
ProxoolException
- if we couldn't find the poolpublic static void addStatisticsListener(java.lang.String alias, org.logicalcobwebs.proxool.admin.StatisticsListenerIF statisticsListener) throws ProxoolException
statisticsListener
- the new listener
ProxoolException
- if the pool couldn't be foundpublic static org.logicalcobwebs.proxool.admin.SnapshotIF getSnapshot(java.lang.String alias, boolean detail) throws ProxoolException
alias
- identifies the pooldetail
- if true then include detail of each connection. Note it you ask for
detail then the pool must necessarily be locked for the duration it takes to gather
the information (which isn't very long). You probably shouldn't do it that often (like
not every second or something). Being locked means that connections cannot be
served or returned (it doesn't mean that they can't be active).
ProxoolException
- if we couldn't find the poolpublic static org.logicalcobwebs.proxool.admin.SnapshotIF getSnapshot(java.lang.String alias) throws ProxoolException
getSnapshot
using false for the detail parameter.
ProxoolException
getSnapshot(java.lang.String, boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |