KickJava   Java API By Example, From Geeks To Geeks.

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


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

23
24 package org.continuent.sequoia.console.text.commands.dbadmin;
25
26 import java.util.Iterator JavaDoc;
27 import java.util.List 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 an Enable command to enable a backend from its last known
35  * checkpoint.
36  *
37  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
38  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
39  * </a>
40  * @version 1.0
41  */

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

50   public Enable(VirtualDatabaseAdmin module)
51   {
52     super(module);
53   }
54
55   /**
56    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
57    */

58   public void parse(String JavaDoc commandText) throws Exception JavaDoc
59   {
60     String JavaDoc backendName = null;
61
62     backendName = commandText.trim();
63
64     if ("".equals(backendName)) //$NON-NLS-1$
65
{
66       console.printError(getUsage());
67       return;
68     }
69     VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(dbName, user,
70         password);
71     if ("*".equals(backendName)) //$NON-NLS-1$
72
{
73       console.printInfo(ConsoleTranslate
74           .get("admin.command.enable.all.with.checkpoint")); //$NON-NLS-1$
75
List JavaDoc backendNames = vdjc.getAllBackendNames();
76       for (Iterator JavaDoc iter = backendNames.iterator(); iter.hasNext();)
77       {
78         String JavaDoc backend = (String JavaDoc) iter.next();
79         vdjc.enableBackendFromCheckpoint(backend);
80       }
81     }
82     else
83     {
84       console.printInfo(ConsoleTranslate.get(
85           "admin.command.enable.with.checkpoint", backendName)); //$NON-NLS-1$
86
vdjc.enableBackendFromCheckpoint(backendName);
87     }
88   }
89
90   /**
91    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
92    */

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

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

110   public String JavaDoc getCommandParameters()
111   {
112     return ConsoleTranslate.get("admin.command.enable.params"); //$NON-NLS-1$
113
}
114 }
115
Popular Tags