KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > text > commands > dbadmin > ShowControllers


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Contact: c-jdbc@objectweb.org
4  *
5  * This library is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by the
7  * Free Software Foundation; either version 2.1 of the License, or any later
8  * version.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18  *
19  * Initial developer(s): Nick Burch
20  * Contributor(s): ______________________.
21  */

22
23 package org.objectweb.cjdbc.console.text.commands.dbadmin;
24
25 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate;
26 import org.objectweb.cjdbc.common.jmx.mbeans.VirtualDatabaseMBean;
27 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin;
28
29 /**
30  * This class defines a ShowControllers
31  *
32  * @author <a HREF="mailto:nick@torchbox.com">Nick Burch </a>
33  * @version 1.0
34  */

35 public class ShowControllers extends AbstractAdminCommand
36 {
37
38   /**
39    * Creates a new <code>ShowControllers.java</code> object
40    *
41    * @param module the commands is attached to
42    */

43   public ShowControllers(VirtualDatabaseAdmin module)
44   {
45     super(module);
46   }
47
48   /**
49    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#parse(String)
50    */

51   public void parse(String JavaDoc commandText) throws Exception JavaDoc
52   {
53     VirtualDatabaseMBean db = jmxClient.getVirtualDatabaseProxy(dbName, user,
54         password);
55     String JavaDoc[] controllers = db.viewControllerList();
56     console.println(ConsoleTranslate.get(
57         "admin.command.show.controllers.number", new Object JavaDoc[]{dbName,
58             new Integer JavaDoc(controllers.length)}));
59     for (int i = 0; i < controllers.length; i++)
60     {
61       console.println("\t" + controllers[i]);
62     }
63   }
64
65   /**
66    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandName()
67    */

68   public String JavaDoc getCommandName()
69   {
70     return "show controllers";
71   }
72
73   /**
74    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandDescription()
75    */

76   public String JavaDoc getCommandDescription()
77   {
78     return ConsoleTranslate.get("admin.command.show.controllers.description");
79   }
80 }
Popular Tags