01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2006 Continuent, Inc.
04: * Contact: sequoia@continuent.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
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: */package org.continuent.sequoia.console.text.commands.controller;
21:
22: import org.continuent.sequoia.common.i18n.ConsoleTranslate;
23: import org.continuent.sequoia.console.text.commands.ConsoleCommand;
24: import org.continuent.sequoia.console.text.module.AbstractConsoleModule;
25:
26: /**
27: * This class defines a load driver command.
28: *
29: * @author <a href="mailto:emmanuel.cecchet@continuent.com">Emmanuel Cecchet</a>
30: * @version 1.0
31: */
32: public class LoadDriver extends ConsoleCommand {
33: /**
34: * Creates a new <code>LoadDriver</code> command.
35: *
36: * @param module the command is attached to
37: */
38: public LoadDriver(AbstractConsoleModule module) {
39: super (module);
40: }
41:
42: /**
43: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
44: */
45: public void parse(String commandText) throws Exception {
46: checkJmxConnectionToController();
47:
48: String className = null;
49: // Get class name if needed
50: if (commandText == null || commandText.trim().equals("")) //$NON-NLS-1$
51: className = console.readLine(ConsoleTranslate
52: .get("controller.command.load.driver.input")); //$NON-NLS-1$
53: else
54: className = commandText.trim();
55:
56: try {
57: Class.forName(className);
58: } catch (Exception e) {
59: console
60: .printError(ConsoleTranslate
61: .get(
62: "controller.command.load.driver.failed", new String[] { className, e.toString() })); //$NON-NLS-1$
63: return;
64: }
65:
66: console.printInfo(ConsoleTranslate.get(
67: "controller.command.load.driver.success", //$NON-NLS-1$
68: className));
69: }
70:
71: /**
72: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
73: */
74: public String getCommandName() {
75: return "load driver"; //$NON-NLS-1$
76: }
77:
78: /**
79: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
80: */
81: public String getCommandDescription() {
82: return ConsoleTranslate
83: .get("controller.command.load.driver.description"); //$NON-NLS-1$
84: }
85:
86: /**
87: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
88: */
89: public String getCommandParameters() {
90: return ConsoleTranslate
91: .get("controller.command.load.driver.params"); //$NON-NLS-1$
92: }
93: }
|