KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > console > text > commands > controller > LoadDriver


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2006 Continuent, Inc.
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.controller;
23
24 import org.continuent.sequoia.common.i18n.ConsoleTranslate;
25 import org.continuent.sequoia.console.text.commands.ConsoleCommand;
26 import org.continuent.sequoia.console.text.module.AbstractConsoleModule;
27
28 /**
29  * This class defines a load driver command.
30  *
31  * @author <a HREF="mailto:emmanuel.cecchet@continuent.com">Emmanuel Cecchet</a>
32  * @version 1.0
33  */

34 public class LoadDriver extends ConsoleCommand
35 {
36   /**
37    * Creates a new <code>LoadDriver</code> command.
38    *
39    * @param module the command is attached to
40    */

41   public LoadDriver(AbstractConsoleModule module)
42   {
43     super(module);
44   }
45
46   /**
47    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
48    */

49   public void parse(String JavaDoc commandText) throws Exception JavaDoc
50   {
51     checkJmxConnectionToController();
52
53     String JavaDoc className = null;
54     // Get class name if needed
55
if (commandText == null || commandText.trim().equals("")) //$NON-NLS-1$
56
className = console.readLine(ConsoleTranslate
57           .get("controller.command.load.driver.input")); //$NON-NLS-1$
58
else
59       className = commandText.trim();
60
61     try
62     {
63       Class.forName(className);
64     }
65     catch (Exception JavaDoc e)
66     {
67       console
68           .printError(ConsoleTranslate
69               .get(
70                   "controller.command.load.driver.failed", new String JavaDoc[]{className, e.toString()})); //$NON-NLS-1$
71
return;
72     }
73
74     console.printInfo(ConsoleTranslate.get(
75         "controller.command.load.driver.success", //$NON-NLS-1$
76
className));
77   }
78
79   /**
80    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
81    */

82   public String JavaDoc getCommandName()
83   {
84     return "load driver"; //$NON-NLS-1$
85
}
86
87   /**
88    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
89    */

90   public String JavaDoc getCommandDescription()
91   {
92     return ConsoleTranslate.get("controller.command.load.driver.description"); //$NON-NLS-1$
93
}
94
95   /**
96    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
97    */

98   public String JavaDoc getCommandParameters()
99   {
100     return ConsoleTranslate.get("controller.command.load.driver.params"); //$NON-NLS-1$
101
}
102 }
103
Popular Tags