FileDocCategorySizeDatePackage
JDBCPoolMonitorTask.javaAPI DocGlassfish v2 API4793Fri May 04 22:25:18 BST 2007com.sun.enterprise.cli.commands.monitor

JDBCPoolMonitorTask

public class JDBCPoolMonitorTask extends ConnectionPoolTask

Fields Summary
Constructors Summary
public JDBCPoolMonitorTask(ServerRootMonitor srm, String filter, Timer timer, boolean verbose, File fileName)

        super(srm, filter, timer, verbose, fileName);
        final Map<String,JDBCConnectionPoolMonitor> jdbcMap = srm.getJDBCConnectionPoolMonitorMap();
        
        if (jdbcMap == null)
            throw new MonitorTaskException(localStrings.getString("commands.monitor.unable_to_monitor_jdbc_pool"));
            
        final String[] keys = MapUtil.getKeyStrings(jdbcMap);
        if (this.filter == null)
        {
            checkForNumberOfElements(keys);
            this.filter = keys[0];
        }
        else
        {
            if (!jdbcMap.containsKey(this.filter))
            {
                throw new MonitorTaskException(localStrings.getString("commands.monitor.does_not_exist", new Object[] {this.filter}));
            }
        }

        final String jdbcPoolMonitoring = localStrings.getString("commands.monitor.jdbc_pool_monitoring", new Object[] {this.filter});
        final String title = String.format("%1$60s", jdbcPoolMonitoring);
        CLILogger.getInstance().printMessage(title);
        displayHeader();
    
Methods Summary
private voidmonitorConnectionPool(java.lang.String element, java.util.Map jdbcMap)

        final JDBCConnectionPoolMonitor jdbcPoolMonitor = jdbcMap.get(element);
        final AltJDBCConnectionPoolStats stats = jdbcPoolMonitor.getAltJDBCConnectionPoolStats();
        displayData(stats);
    
public voidrun()

        if (srm == null) super.cancelMonitorTask();
        final Map<String,JDBCConnectionPoolMonitor> jdbcMap = srm.getJDBCConnectionPoolMonitorMap();
            //maybe lost connection?
        if (jdbcMap == null) {
            cancelMonitorTask();
        }
        else {
            if (verbose && counter == NUM_ROWS)
            {
                displayHeader();
                counter = 0;  //reset to 0
            }
            monitorConnectionPool(filter, jdbcMap);
            if (verbose) counter++;
        }