Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.logicalcobwebs.proxool.ProxoolFacade
public class ProxoolFacade
extends java.lang.Object
java.sql.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.
Method Summary | |
static void |
|
static void |
|
static void |
|
static void |
|
static void |
|
protected static void |
|
static void |
|
static void |
|
protected void |
|
static String |
|
protected static String |
|
static String[] |
|
static Collection |
|
static ConnectionPoolDefinitionIF |
|
static ConnectionPoolStatisticsIF |
|
static String |
|
static Connection |
|
static Statement |
|
static long |
|
static SnapshotIF |
|
static SnapshotIF |
|
static StatisticsIF[] |
|
static StatisticsIF |
|
static boolean |
|
static void |
|
static void |
|
static void |
|
static void |
|
static boolean |
|
static boolean |
|
static void |
|
static void |
|
static String |
|
protected static String |
|
protected static void |
|
static void |
|
static boolean |
|
static boolean |
|
static void |
|
static void |
|
static boolean |
|
static boolean |
|
static void |
|
static void |
|
protected static void |
|
static void |
|
static void |
|
protected static void |
|
static void |
|
static void |
|
public static void addConfigurationListener(String alias, ConfigurationListenerIF configurationListener) throws ProxoolException
Adds a listener that gets called everytime the configuration changes.
- Parameters:
alias
- identifies the poolconfigurationListener
- the new listener
- Throws:
ProxoolException
- if we couldn't find the pool
public static void addConnectionListener(String alias, ConnectionListenerIF connectionListener) throws ProxoolException
Add a listener that monitors each time a connection is made or destroyed.
- Parameters:
alias
- identifies the poolconnectionListener
- the new listener
- Throws:
ProxoolException
- if we couldn't find the pool
public static void addProxoolListener(ProxoolListenerIF proxoolListener)
Add a listener that gets called everytime a global Proxool event ocours.
- Parameters:
proxoolListener
- the listener to add.
public static void addStateListener(String alias, StateListenerIF stateListener) throws ProxoolException
Add a listener that monitors the change of state of the pool (quiet, busy, overloaded, or down)
- Parameters:
alias
- identifies the poolstateListener
- the new listener
- Throws:
ProxoolException
- if we couldn't find the pool
public static void addStatisticsListener(String alias, StatisticsListenerIF statisticsListener) throws ProxoolException
Add a listener that receives statistics as they are produced
- Parameters:
statisticsListener
- the new listener
- Throws:
ProxoolException
- if the pool couldn't be found
protected static void definitionUpdated(String alias, ConnectionPoolDefinitionIF connectionPoolDefinition, Properties completeInfo, Properties changedInfo)
Broadcast a configuration change
- Parameters:
alias
- identifies the poolconnectionPoolDefinition
- the definitioncompleteInfo
- all propertieschangedInfo
- only changed properties (since the last time this method was called)
public static void disableShutdownHook()
If you call this then you'll have to call shutdown explicitly
- See Also:
shutdown(String,int)
public static void enableShutdownHook()
Call this if you change your mind aboutdisabling
it. The default behaviour is to have it enabled so unless you have disabled it then there's nothing to do.
protected void finalize() throws Throwable
public static String getAlias(Connection connection) throws ProxoolException
Get the alias for the connection pool that served a connection
- Parameters:
connection
- the connection that was served
- Returns:
- the alias
- Throws:
ProxoolException
- if the connection wasn't recognised.
protected static String getAlias(String url) throws ProxoolException
Extracts the pool alias from the url: proxool.alias:driver:url -> alias proxool.alias -> alias
- Returns:
- the alias defined within the url
- Throws:
ProxoolException
- if we couldn't find the alias
public static String[] getAliases()
Get a list of all the registered pools
- Returns:
- an array of aliases
- Since:
- Proxool 0.7
public static Collection getConnectionInfos(String alias) throws ProxoolException
Deprecated. use
snapshot
instead.Get details on each connection within the pool. This can tell you which ones are active, how long they have been active, etc.
- Parameters:
alias
- identifies the pool
- Returns:
- a collection of
ConnectionInfoIFs
- Throws:
ProxoolException
- if we couldn't find the pool
public static ConnectionPoolDefinitionIF getConnectionPoolDefinition(String alias) throws ProxoolException
Get the definition of a pool.
- Parameters:
alias
- identifies the pool
- Throws:
ProxoolException
- if we couldn't find the pool
public static ConnectionPoolStatisticsIF getConnectionPoolStatistics(String alias) throws ProxoolException
Deprecated. use
getSnapshot
Get real-time statistical information about how a pool is performing.
- Parameters:
alias
- to identify the pool
- Returns:
- the statistics
- Throws:
ProxoolException
- if we couldn't find the pool
public static String getConnectionPoolStatisticsDump(String alias) throws ProxoolException
Deprecated. use
getSnapshot
Get real-time statistical information about how a pool is performing. and extract the information piece by piece.
- Parameters:
alias
- to identify the pool
- Returns:
- a horrible string describing the statistics
- Throws:
ProxoolException
- if we couldn't find the pool
public static Connection getDelegateConnection(Connection connection) throws ProxoolException
Deprecated. Just cast the connection that you are given into the driver specific one.
Returns the driver provided connection that Proxool wraps up before it gives it to you.
- Returns:
- delegate connection
public static Statement getDelegateStatement(Statement statement) throws ProxoolException
Deprecated. Just cast the statement that you are given into the driver specific one.
Returns the driver provided statement that Proxool wraps up before it gives it to you.
- Returns:
- delegate statement
public static long getId(Connection connection) throws ProxoolException
Get the connection ID for a connection
- Parameters:
connection
- the connection that was served
- Returns:
- the ID
- Throws:
ProxoolException
- if the connection wasn't recognised.
public static SnapshotIF getSnapshot(String alias) throws ProxoolException
CallsgetSnapshot
using false for the detail parameter.
- See Also:
getSnapshot(java.lang.String, boolean)
public static SnapshotIF getSnapshot(String alias, boolean detail) throws ProxoolException
Gives a snapshot of what the pool is doing
- Parameters:
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).
- Returns:
- the current status of the pool
- Throws:
ProxoolException
- if we couldn't find the pool
public static StatisticsIF[] getStatistics(String alias) throws ProxoolException
Get all the lastest performance statistics for this pool
- Parameters:
alias
- identifies the pool
- Returns:
- a sample containing the statistics, or a zero length array if there none
- Throws:
ProxoolException
- if we couldn't find the pool
public static StatisticsIF getStatistics(String alias, String token) throws ProxoolException
Get a particular set of performance statistics for this pool
- Parameters:
alias
- identifies the pooltoken
- identifies which set, as defined in the configuration (seedefinition
)
- Returns:
- a sample containing the statistics
- Throws:
ProxoolException
- if we couldn't find the pool
public static boolean isShutdownHookEnabled()
Whether theShutdownHook
should do anything.
- Returns:
- true if the shutdown hook should clean up
- See Also:
disableShutdownHook()
,enableShutdownHook()
public static void killAllConnections(String alias) throws ProxoolException
Deprecated. use
alternative
to provide better auditing in logLikekillAllConnections
but defaults to merciful.
- Parameters:
alias
- to identify the pool
- Throws:
ProxoolException
- if we couldn't find the pool
public static void killAllConnections(String alias, String reason) throws ProxoolException
LikekillAllConnections
but defaults to merciful.
- Parameters:
alias
- to identify the poolreason
- provides audit in log of why connections were killed
- Throws:
ProxoolException
- if we couldn't find the pool
public static void killAllConnections(String alias, String reason, boolean merciful) throws ProxoolException
Kill all connections in a pool. The pool continues to work however, and new connections will be made as required.
- Parameters:
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
- Throws:
ProxoolException
- if we couldn't find the pool
public static void killAllConnections(String alias, boolean merciful) throws ProxoolException
Deprecated. use
alternative
to provide better auditing in logKill all connections in a pool. The pool continues to work however, and new connections will be made as required.
- Parameters:
alias
- the pool containing the connectionmerciful
- if true will only kill connections that aren't active
- Throws:
ProxoolException
- if we couldn't find the pool
public static boolean killConnecton(Connection connection, boolean merciful) throws ProxoolException
Kill a single connection
- Parameters:
connection
- the connection to killmerciful
- if true will only kill connections that aren't active
- Returns:
- true if the connection was killed, or false if it couldn't be found.
- Throws:
ProxoolException
- if we didn't recognise the connection
public static boolean killConnecton(String alias, long id, boolean merciful) throws ProxoolException
Kill a single connection
- Parameters:
alias
- the pool containing the connectionid
- the id of the specific connectionmerciful
- if true will only kill connections that aren't active
- Returns:
- true if the connection was killed, or false if it couldn't be found.
- Throws:
ProxoolException
- if we couldn't find the pool
public static void redefineConnectionPool(String url, Properties info) throws ProxoolException
Redefine the behaviour of the pool. All existing properties (for Proxool and the delegate driver are reset to their default) and reapplied based on the parameters sent here.
- Parameters:
url
- the url that defines the pool (or the abbreviated ""proxool.alias")info
- the new properties
public static void registerConnectionPool(String url) throws ProxoolException
With no configurator or properties (using default values)
- See Also:
registerConnectionPool(java.lang.String, java.util.Properties)
public static String registerConnectionPool(String url, Properties info) throws ProxoolException
Build a ConnectionPool based on this definition and then start it.
- Parameters:
url
- defines the delegate driver and delegate url.info
- the properties used to configure Proxool (and any for the delegate driver too) - optional
- Returns:
- the alias for this pool (or the full url if no alias is specified)
- Throws:
ProxoolException
- if anything goes wrong
protected static String registerConnectionPool(String url, Properties info, boolean explicitRegister) throws ProxoolException
Build a ConnectionPool based on this definition and then start it.
- Parameters:
url
- defines the delegate driver and delegate url.info
- the properties used to configure Proxool (and any for the delegate driver too) - optionalexplicitRegister
- set to true if we are registering a new pool explicitly, or false if it's just because we are serving a url that we haven't come across before
- Returns:
- the alias for this pool (or the full url if no alias is specified)
- Throws:
ProxoolException
- if anything goes wrong
protected static void registerConnectionPool(org.logicalcobwebs.proxool.ConnectionPoolDefinition connectionPoolDefinition) throws ProxoolException
public static void removeAllConnectionPools(int delay)
Deprecated. use the better named
shutdown()
instead.Removes all connection pools. Kills all the connections. Resets everything.
- Parameters:
delay
- the time to wait for connections to become inactive before killing it (milliseconds)
public static boolean removeConfigurationListener(String alias, ConfigurationListenerIF configurationListener) throws ProxoolException
Remove a listener that gets called everytime the configuration changes.
- Parameters:
alias
- identifies the pool.configurationListener
- the listener to be removed.
- Returns:
- wether the listnener was found and removed or not.
- Throws:
ProxoolException
- if we couldn't find the pool
public static boolean removeConnectionListener(String alias, ConnectionListenerIF connectionListener) throws ProxoolException
Remove a listener that monitors each time a connection is made or destroyed.
- Parameters:
alias
- identifies the poolconnectionListener
- the listener to be removed
- Returns:
- wether the listnener was found and removed or not.
- Throws:
ProxoolException
- if we couldn't find the pool
public static void removeConnectionPool(String alias) throws ProxoolException
LikeremoveConnectionPool(java.lang.String, int)
but uses no delay. (Kills everything as quickly as possible).
- Parameters:
alias
- to identify the pool
- Throws:
ProxoolException
- if we couldn't find the pool
public static void removeConnectionPool(String alias, int delay) throws ProxoolException
Remove a connection pool. Kills all the connections. Resets everything.
- Parameters:
alias
- the pool to removedelay
- the time to wait for connections to become inactive before killing it (milliseconds)
- Throws:
ProxoolException
- if we couldn't find the pool
public static boolean removeProxoolListener(ProxoolListenerIF proxoolListener)
Remove a registeredProxoolListenerIF
.
- Parameters:
proxoolListener
- the listener to remove.
- Returns:
- whether the listener was found or removed or not.
public static boolean removeStateListener(String alias, StateListenerIF stateListener) throws ProxoolException
Remove a listener that monitors the change of state of the pool (quiet, busy, overloaded, or down)
- Parameters:
alias
- identifies the poolstateListener
- the listener to be removed.
- Returns:
- wether the listnener was found and removed or not.
- Throws:
ProxoolException
- if we couldn't find the pool
public static void setConfigurationListener(String alias, ConfigurationListenerIF configurationListener) throws ProxoolException
Deprecated. use
addConfigurationListener(String,ConfigurationListenerIF)
instead.
public static void setConnectionListener(String alias, ConnectionListenerIF connectionListener) throws ProxoolException
Deprecated. use
addConnectionListener(String,ConnectionListenerIF)
instead.
protected static void setShutdownHook(Thread t)
By remembering the most recentShutdownHook
ProxoolFacade will know to disable it when it isshutdown
. It will gracefully cope with the fact that it may be shutting down by the request of the sutdownHook. If you don't do this and do several "hot deploys" then you end up with a series of shutdown hooks. We only every want one.
- Parameters:
t
- the thread that will be run as a shutdown hook
- See Also:
ShutdownHook
public static void setStateListener(String alias, StateListenerIF stateListener) throws ProxoolException
Deprecated. use
addStateListener(String,StateListenerIF)
instead.
public static void shutdown()
Removes all connection pools. Kills all the connections. Resets everything. Likeshutdown(java.lang.String, int)
but passes the current thread name and a delay of zero.
protected static void shutdown(String finalizer, int delay)
Removes all connection pools. Kills all the connections. Resets everything.
- Parameters:
finalizer
- used to identify who is causing the pools to be removed (helps logging)delay
- the time to wait for connections to become inactive before killing it (milliseconds)
public static void shutdown(int delay)
Removes all connection pools. Kills all the connections. Resets everything. Likeshutdown(java.lang.String, int)
but passes the current thread name.
- Parameters:
delay
- the time to wait for connections to become inactive before killing it (milliseconds)
public static void updateConnectionPool(String url, Properties info) throws ProxoolException
Update the behaviour of the pool. Only properties that are defined here are overwritten. That is, properties that were defined before but are not mentioned here are retained.
- Parameters:
url
- the url that defines the pool (or the abbreviated ""proxool.alias")info
- the new properties