KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > console > text > commands > dbadmin > ForceEnable


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2005 Emic Networks.
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Initial developer(s): Emmanuel Cecchet.
19  * Contributor(s): ______________________.
20  */

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

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

46   public ForceEnable(VirtualDatabaseAdmin module)
47   {
48     super(module);
49   }
50
51   /**
52    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
53    */

54   public void parse(String JavaDoc commandText) throws Exception JavaDoc
55   {
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())) //$NON-NLS-1$
68
{
69       List 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       console.printInfo(ConsoleTranslate.get(
82           "admin.command.force.enable.backend", backendName)); //$NON-NLS-1$
83
vjdc.forceEnableBackend(backendName);
84     }
85   }
86
87   /**
88    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
89    */

90   public String JavaDoc getCommandName()
91   {
92     return "force enable"; //$NON-NLS-1$
93
}
94
95   /**
96    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
97    */

98   public String JavaDoc getCommandDescription()
99   {
100     return ConsoleTranslate.get("admin.command.force.enable.description"); //$NON-NLS-1$
101
}
102
103   /**
104    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
105    */

106   public String JavaDoc getCommandParameters()
107   {
108     return ConsoleTranslate.get("admin.command.force.enable.params"); //$NON-NLS-1$
109
}
110 }
111
Popular Tags