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

MonitorTask

public abstract class MonitorTask extends TimerTask

Fields Summary
final int
NUM_ROWS
int
counter
ServerRootMonitor
srm
String
monitorType
String
filter
Timer
timer
File
fileName
boolean
verbose
static final com.sun.enterprise.util.i18n.StringManager
localStrings
Constructors Summary
public MonitorTask()

    

      
public MonitorTask(ServerRootMonitor srm, String filter, Timer timer, boolean verbose, File fileName)

        this.srm = srm;
        this.timer = timer;
        if (filter != null)
            this.filter = filter;
        this.verbose = verbose;
        this.fileName = fileName;
    
Methods Summary
voidcancelMonitorTask()

        timer.cancel();
        final String msg = localStrings.getString("commands.monitor.press_to_quit");
        CLILogger.getInstance().printMessage(msg);
    
voidcheckForNumberOfElements(java.lang.String[] keys)

        if (keys.length<1)
        {
            throw new MonitorTaskException(localStrings.getString("command.monitor.no_value_to_monitor"));
        }
        else if (keys.length > 1)
        {
            StringBuffer sb = new StringBuffer();
            sb.append(localStrings.getString("commands.monitor.more_than_one_monitoring_elements"));
            sb.append(localStrings.getString("commands.monitor.available_elements"));
            for (String key: keys) {
                sb.append("    ");
                sb.append(key);
                sb.append("\n");
            }
            throw new MonitorTaskException(sb.toString());
        }
    
public abstract voiddisplayDetails()

synchronized voidwriteToFile(java.lang.String text)

        try {
            BufferedWriter out = new BufferedWriter(new FileWriter(fileName, true));
            out.append(text);
            out.newLine();
            out.close();
        }
        catch (IOException ioe) {
            final String unableToWriteFile = localStrings.getString("commands.monitor.unable_to_write_to_file", new Object[] {fileName.getName()});
            CLILogger.getInstance().printMessage(unableToWriteFile);
            if (verbose) {
                ioe.printStackTrace();
            }
        }