00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 package org.objectweb.cjdbc.console.text.module;
00026
00027 import java.util.Iterator;
00028
00029 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate;
00030 import org.objectweb.cjdbc.console.text.Console;
00031 import org.objectweb.cjdbc.console.text.commands.monitor.AbstractMonitorCommand;
00032 import org.objectweb.cjdbc.console.text.commands.monitor.ChangeTarget;
00033 import org.objectweb.cjdbc.console.text.commands.monitor.ShowBackends;
00034 import org.objectweb.cjdbc.console.text.commands.monitor.ShowCache;
00035 import org.objectweb.cjdbc.console.text.commands.monitor.ShowCacheStats;
00036 import org.objectweb.cjdbc.console.text.commands.monitor.ShowController;
00037 import org.objectweb.cjdbc.console.text.commands.monitor.ShowDatabases;
00038 import org.objectweb.cjdbc.console.text.commands.monitor.ShowRecoveryLog;
00039 import org.objectweb.cjdbc.console.text.commands.monitor.ShowScheduler;
00040 import org.objectweb.cjdbc.console.text.commands.monitor.ShowStats;
00041
00042
00043
00044
00045
00046
00047
00048 public class MonitorConsole extends AbstractConsoleModule
00049 {
00050
00051 private String currentTarget;
00052
00053
00054
00055
00056
00057
00058 public String getCurrentTarget()
00059 {
00060 return currentTarget;
00061 }
00062
00063
00064
00065
00066
00067
00068 public void setCurrentTarget(String currentTarget)
00069 {
00070 this.currentTarget = currentTarget;
00071 Object o;
00072 Iterator it = commands.iterator();
00073 while (it.hasNext())
00074 {
00075 o = it.next();
00076 if (o instanceof AbstractMonitorCommand)
00077 {
00078 ((AbstractMonitorCommand) o).setCurrentTarget(currentTarget);
00079 }
00080 }
00081 }
00082
00083
00084
00085
00086
00087
00088 public MonitorConsole(Console console)
00089 {
00090 super(console);
00091 }
00092
00093
00094
00095
00096 public String getDescriptionString()
00097 {
00098 return "Monitoring";
00099 }
00100
00101
00102
00103
00104 public String getPromptString()
00105 {
00106 return "Monitoring:" + currentTarget;
00107 }
00108
00109
00110
00111
00112 protected void loadCommands()
00113 {
00114 commands.add(new ChangeTarget(this));
00115 commands.add(new ShowBackends(this));
00116 commands.add(new ShowCache(this));
00117 commands.add(new ShowCacheStats(this));
00118 commands.add(new ShowController(this));
00119 commands.add(new ShowDatabases(this));
00120 commands.add(new ShowScheduler(this));
00121 commands.add(new ShowStats(this));
00122 commands.add(new ShowRecoveryLog(this));
00123 }
00124
00125
00126
00127
00128 public void login(String[] params)
00129 {
00130 String command = (params.length > 0 && params[0] != null) ? params[0] : "";
00131 if (command.equals("") == false)
00132 {
00133 try
00134 {
00135 new ChangeTarget(this).execute(params[0]);
00136 }
00137 catch (Exception e)
00138 {
00139 console.printError(e.getMessage(), e);
00140 quit = true;
00141 }
00142 }
00143 else
00144 {
00145 console.printError(ConsoleTranslate.get("module.database.invalid", ""));
00146 quit = true;
00147 }
00148 }
00149 }