01: /**
02: * Sequoia: Database clustering technology.
03: * Contact: sequoia@continuent.org
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * Initial developer(s): Damian Arregui
18: * Contributor(s): ______________________.
19: */package org.continuent.sequoia.console.text.commands.dbadmin;
20:
21: import java.util.StringTokenizer;
22:
23: import org.continuent.sequoia.common.i18n.ConsoleTranslate;
24: import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean;
25: import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
26:
27: /**
28: * This class defines an CloseConnection
29: *
30: * @author <a href="mailto:damian.arregui@continuent.com">Damian Arregui </a>
31: * @version 1.0
32: */
33: public class CloseConnection extends AbstractAdminCommand {
34:
35: /**
36: * Creates a new <code>CloseConnection</code> object
37: *
38: * @param module the commands is attached to
39: */
40: public CloseConnection(VirtualDatabaseAdmin module) {
41: super (module);
42: }
43:
44: /**
45: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(String)
46: */
47: public void parse(String commandText) throws Exception {
48: VirtualDatabaseMBean db = jmxClient.getVirtualDatabaseProxy(
49: dbName, user, password);
50:
51: String login = null;
52: String ocid = null;
53: StringTokenizer st = new StringTokenizer(commandText.trim());
54:
55: try {
56: login = st.nextToken();
57: ocid = st.nextToken();
58: } catch (Exception e) {
59: console.printError(getUsage());
60: return;
61: }
62:
63: if (login == null || ocid == null) {
64: console.printError(getUsage());
65: return;
66: }
67:
68: db.closePersistentConnection(login, Long.parseLong(ocid));
69: console
70: .println(ConsoleTranslate
71: .get(
72: "admin.command.close.connection.ok", new Object[] { ocid, login })); //$NON-NLS-1$
73: }
74:
75: /**
76: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
77: */
78: public String getCommandName() {
79: return "close connection"; //$NON-NLS-1$
80: }
81:
82: /**
83: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
84: */
85: public String getCommandDescription() {
86: return ConsoleTranslate
87: .get("admin.command.close.connection.description"); //$NON-NLS-1$
88: }
89:
90: /**
91: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
92: */
93: public String getCommandParameters() {
94: return ConsoleTranslate
95: .get("admin.command.close.connection.params"); //$NON-NLS-1$
96: }
97: }
|