KickJava   Java API By Example, From Geeks To Geeks.

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


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

23
24 package org.objectweb.cjdbc.console.text.commands.dbadmin;
25
26 import java.util.ArrayList JavaDoc;
27
28 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate;
29 import org.objectweb.cjdbc.common.jmx.mbeans.VirtualDatabaseMBean;
30 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin;
31
32 /**
33  * This class defines the ForceDisable command that forces the disabling of a
34  * backend without setting a checkpoint.
35  *
36  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
37  * </a>
38  * @version 1.0
39  */

40 public class ForceDisable extends AbstractAdminCommand
41 {
42   /**
43    * Creates a new <code>Disable.java</code> object
44    *
45    * @param module the command is attached to
46    */

47   public ForceDisable(VirtualDatabaseAdmin module)
48   {
49     super(module);
50   }
51
52   /**
53    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#parse(java.lang.String)
54    */

55   public void parse(String JavaDoc commandText) throws Exception JavaDoc
56   {
57     if (commandText.trim().length() == 0)
58     {
59       console.printError(getUsage());
60       return;
61     }
62
63     String JavaDoc[] backendNames;
64     VirtualDatabaseMBean vjdc = jmxClient.getVirtualDatabaseProxy(dbName, user,
65         password);
66     
67     if (("*").equals(commandText.trim()))
68     {
69       ArrayList JavaDoc backendNamesList = vjdc.getAllBackendNames();
70       backendNames = (String JavaDoc[]) backendNamesList
71           .toArray(new String JavaDoc[backendNamesList.size()]);
72     }
73     else
74     {
75       String JavaDoc backendName = commandText.trim();
76       backendNames = new String JavaDoc[]{backendName};
77     }
78     for (int i = 0; i < backendNames.length; i++)
79     {
80       String JavaDoc backendName = backendNames[i];
81       vjdc.forceDisableBackend(backendName);
82       console.println(ConsoleTranslate.get(
83           "admin.command.force.disable.backend", backendName));
84       }
85   }
86
87   /**
88    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandDescription()
89    */

90   public String JavaDoc getCommandDescription()
91   {
92     return ConsoleTranslate.get("admin.command.force.disable.description");
93   }
94
95   /**
96    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandName()
97    */

98   public String JavaDoc getCommandName()
99   {
100     return "force disable";
101   }
102
103   /**
104    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandParameters()
105    */

106   public String JavaDoc getCommandParameters()
107   {
108     return ConsoleTranslate.get("admin.command.force.disable.params");
109   }
110
111 }
112
Popular Tags