KickJava   Java API By Example, From Geeks To Geeks.

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


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 ForceEnable command that forces the enabling of a
34  * backend without checkpoint checking.
35  *
36  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
37  * </a>
38  * @version 1.0
39  */

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

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

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

92   public String JavaDoc getCommandName()
93   {
94
95     return "force enable";
96   }
97
98   /**
99    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandDescription()
100    */

101   public String JavaDoc getCommandDescription()
102   {
103     return ConsoleTranslate.get("admin.command.force.enable.description");
104   }
105
106   /**
107    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandParameters()
108    */

109   public String JavaDoc getCommandParameters()
110   {
111     return ConsoleTranslate.get("admin.command.force.enable.params");
112   }
113 }
114
Popular Tags