KickJava   Java API By Example, From Geeks To Geeks.

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


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

22
23 package org.continuent.sequoia.console.text.commands.dbadmin;
24
25 import java.util.Iterator JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.StringTokenizer JavaDoc;
28
29 import org.continuent.sequoia.common.i18n.ConsoleTranslate;
30 import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean;
31 import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
32
33 /**
34  * This class defines a Disable
35  *
36  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
37  * @version 1.0
38  */

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

46   public Disable(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     String JavaDoc backendName = null;
57
58     StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(commandText);
59     if (st.countTokens() != 1)
60     {
61       console.printError(getUsage());
62       return;
63     }
64     try
65     {
66       backendName = st.nextToken();
67     }
68     catch (Exception JavaDoc e)
69     {
70       console.printError(getUsage());
71       return;
72     }
73
74     VirtualDatabaseMBean vjdc = jmxClient.getVirtualDatabaseProxy(dbName, user,
75         password);
76     if ("*".equals(backendName)) //$NON-NLS-1$
77
{
78       console.printInfo(ConsoleTranslate
79           .get("admin.command.disable.backend.all.with.checkpoint")); //$NON-NLS-1$
80
List JavaDoc backendNames = vjdc.getAllBackendNames();
81       for (Iterator JavaDoc iter = backendNames.iterator(); iter.hasNext();)
82       {
83         String JavaDoc backend = (String JavaDoc) iter.next();
84         vjdc.disableBackendWithCheckpoint(backend);
85       }
86     }
87     else
88     {
89       vjdc.disableBackendWithCheckpoint(backendName);
90       console.printInfo(ConsoleTranslate.get(
91           "admin.command.disable.backend.with.checkpoint", backendName)); //$NON-NLS-1$
92
}
93   }
94
95   /**
96    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
97    */

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

106   public String JavaDoc getCommandName()
107   {
108     return "disable"; //$NON-NLS-1$
109
}
110
111   /**
112    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
113    */

114   public String JavaDoc getCommandDescription()
115   {
116     return ConsoleTranslate.get("admin.command.disable.backend.description"); //$NON-NLS-1$
117
}
118
119 }
120
Popular Tags