01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright 2005-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): Jeff Mesnil.
19: * Contributor(s): ______________________.
20: */package org.continuent.sequoia.console.text.commands.dbadmin;
21:
22: import org.continuent.sequoia.common.i18n.ConsoleTranslate;
23: import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
24:
25: /**
26: * This class defines the command used to switch to <em>debug mode</em> (i.e.
27: * debug commands are available).
28: *
29: * @author <a href="mailto:jeff.mesnil@emicnetworks.com">Jeff Mesnil</a>
30: * @version 1.0
31: */
32: public class DebugMode extends AbstractAdminCommand {
33:
34: private static final String ON = "on"; //$NON-NLS-1$
35: private static final String OFF = "off"; //$NON-NLS-1$
36:
37: /**
38: * Creates a new <code>DebugMode</code> object
39: *
40: * @param module module that owns this commands
41: */
42: public DebugMode(VirtualDatabaseAdmin module) {
43: super (module);
44: }
45:
46: /**
47: * mbean.hasVirtualDatabase(vdbName)
48: *
49: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
50: */
51: public void parse(String commandText) throws Exception {
52: if (ON.equals(commandText.trim())) {
53: ((VirtualDatabaseAdmin) module).addDebugCommands();
54: console.printInfo(ConsoleTranslate.get("DebugMode.on")); //$NON-NLS-1$
55: } else if (OFF.equals(commandText.trim())) {
56: ((VirtualDatabaseAdmin) module).removeDebugCommands();
57: console.printInfo(ConsoleTranslate.get("DebugMode.off")); //$NON-NLS-1$
58: } else {
59: console.printError(getUsage());
60: }
61: }
62:
63: /**
64: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
65: */
66: public String getCommandName() {
67: return "debug"; //$NON-NLS-1$
68: }
69:
70: /**
71: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
72: */
73: public String getCommandDescription() {
74: return ConsoleTranslate.get("DebugMode.description"); //$NON-NLS-1$
75: }
76:
77: /**
78: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
79: */
80: public String getCommandParameters() {
81: return ConsoleTranslate.get("DebugMode.params"); //$NON-NLS-1$
82: }
83: }
|