Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

MonitorConsole.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk.
00022  * Contributor(s): Mathieu Peltier.
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  * Monitoring console to retrieve information from the controller.
00044  * 
00045  * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
00046  * @author <a href="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
00047  */
00048 public class MonitorConsole extends AbstractConsoleModule
00049 {
00050 
00051   private String currentTarget;
00052 
00053   /**
00054    * Returns the currentTarget value.
00055    * 
00056    * @return Returns the currentTarget.
00057    */
00058   public String getCurrentTarget()
00059   {
00060     return currentTarget;
00061   }
00062 
00063   /**
00064    * Sets the currentTarget value.
00065    * 
00066    * @param currentTarget The currentTarget to set.
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    * Creates a new <code>VirtualDatabaseAdmin</code> instance.
00085    * 
00086    * @param console console console
00087    */
00088   public MonitorConsole(Console console)
00089   {
00090     super(console);
00091   }
00092 
00093   /**
00094    * @see org.objectweb.cjdbc.console.text.module.AbstractConsoleModule#getDescriptionString()
00095    */
00096   public String getDescriptionString()
00097   {
00098     return "Monitoring";
00099   }
00100 
00101   /**
00102    * @see org.objectweb.cjdbc.console.text.module.AbstractConsoleModule#getPromptString()
00103    */
00104   public String getPromptString()
00105   {
00106     return "Monitoring:" + currentTarget;
00107   }
00108 
00109   /**
00110    * @see org.objectweb.cjdbc.console.text.module.AbstractConsoleModule#loadCommands()
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    * @see org.objectweb.cjdbc.console.text.module.AbstractConsoleModule#login(java.lang.String[])
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 }

Generated on Mon Apr 11 22:01:32 2005 for C-JDBC by  doxygen 1.3.9.1