patterntesting.runtime.monitor.db
Class ConnectionMonitor

Package class diagram package ConnectionMonitor
java.lang.Object
  extended by patterntesting.runtime.monitor.db.ConnectionMonitor
All Implemented Interfaces:
ConnectionMonitorMBean
Direct Known Subclasses:
ConnectionMonitor

public class ConnectionMonitor
extends Object
implements ConnectionMonitorMBean

This is the monitor class for the ProxyConnection which monitors the different newInstance() and close() call. So you can ask this class how many and which connections are open.

The instance of this class is automatically registered as MBean as soon as a ProxyConnection is used.

Note: Since 1.4.2 this class was moved from package "patterntesting.runtime.db" to here.

Since:
1.3 (07.10.2012)
Version:
$Revision: 1.5 $
Author:
oliver (ob@aosd.de)

Constructor Summary
protected ConnectionMonitor()
          No need to instantiate it - we provide only some services.
 
Method Summary
static void addConnection(ProxyConnection proxyConnection)
          Adds the connection.
static void assertConnectionsClosed()
          Assert that all connections are closed.
static StackTraceElement getCallerOf(Connection connection)
          Gets the caller of the given connection.
 StackTraceElement[] getCallers()
          Gets the callers.
 TabularData getCallerStacktraces()
          Gets the caller stacktraces of all connections.
 int getClosedConnections()
          Gets the closed connections.
static ConnectionMonitorMBean getInstance()
          Yes, it is a Singleton because it offers only some services.
 StackTraceElement getLastCaller()
          Gets the caller which opens the last connection.
 StackTraceElement[] getLastCallerStacktrace()
          Gets the stacktrace of the caller which opens the last connection.
static Connection getMonitoredConnection(Connection connection)
          If you want to monitor the connection use this method.
 int getOpenConnections()
          Gets the number of open connections.
 int getSumOfConnections()
          Gets the total sum of open and closed connections.
static void removeConnection(ProxyConnection proxyConnection)
          Removes the connection.
 String toString()
          To string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionMonitor

protected ConnectionMonitor()
No need to instantiate it - we provide only some services. The constructor is protected because it is still used by the (deprecated) ConnectionMonitor in patterntesting.runtime.db.

Method Detail

getInstance

public static ConnectionMonitorMBean getInstance()
Yes, it is a Singleton because it offers only some services. So we don't need the object twice.

Returns:
the only instance

getMonitoredConnection

public static Connection getMonitoredConnection(Connection connection)
If you want to monitor the connection use this method.

Parameters:
connection - the original connection
Returns:
a proxy for the connection

addConnection

public static void addConnection(ProxyConnection proxyConnection)
Adds the connection.

Parameters:
proxyConnection - the proxy connection

removeConnection

public static void removeConnection(ProxyConnection proxyConnection)
Removes the connection.

Parameters:
proxyConnection - the proxy connection

getCallerOf

public static StackTraceElement getCallerOf(Connection connection)
Gets the caller of the given connection.

Parameters:
connection - the connection
Returns:
the caller of

getCallers

public StackTraceElement[] getCallers()
Gets the callers.

Specified by:
getCallers in interface ConnectionMonitorMBean
Returns:
the callers
See Also:
ConnectionMonitorMBean.getCallers()

getLastCallerStacktrace

public StackTraceElement[] getLastCallerStacktrace()
Gets the stacktrace of the caller which opens the last connection.

Specified by:
getLastCallerStacktrace in interface ConnectionMonitorMBean
Returns:
the all caller

getCallerStacktraces

public TabularData getCallerStacktraces()
                                 throws OpenDataException
Gets the caller stacktraces of all connections.

Specified by:
getCallerStacktraces in interface ConnectionMonitorMBean
Returns:
stacktraces of all callers
Throws:
OpenDataException - the open data exception

getLastCaller

public StackTraceElement getLastCaller()
Gets the caller which opens the last connection.

Specified by:
getLastCaller in interface ConnectionMonitorMBean
Returns:
the all caller

getOpenConnections

public int getOpenConnections()
Gets the number of open connections.

Specified by:
getOpenConnections in interface ConnectionMonitorMBean
Returns:
the open count
See Also:
ConnectionMonitorMBean.getOpenConnections()

getClosedConnections

public int getClosedConnections()
Gets the closed connections.

Specified by:
getClosedConnections in interface ConnectionMonitorMBean
Returns:
the closed connections
Since:
1.4.1

getSumOfConnections

public int getSumOfConnections()
Gets the total sum of open and closed connections.

Specified by:
getSumOfConnections in interface ConnectionMonitorMBean
Returns:
the sum of connections
Since:
1.4.1

assertConnectionsClosed

public static void assertConnectionsClosed()
Assert that all connections are closed.


toString

public String toString()
To string.

Overrides:
toString in class Object
Returns:
the string
See Also:
Object.toString()


Copyright © 2002–2014 PatternTesting Team. All rights reserved.