KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > console > text > commands > dbadmin > UpdateDumpPath


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.console.text.commands.dbadmin;
26
27 import java.util.StringTokenizer JavaDoc;
28
29 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate;
30 import org.objectweb.cjdbc.common.jmx.mbeans.VirtualDatabaseMBean;
31 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin;
32
33 /**
34  * This class defines a "update dump path" admin command.
35  *
36  * @author <a HREF="mailto:jeff.mesnil@emicnetworks.com">Jeff Mesnil</a>
37  */

38 public class UpdateDumpPath extends AbstractAdminCommand
39 {
40   
41   /**
42    * Creates an "update backup path" command.
43    *
44    * @param module the command is attached to
45    */

46   public UpdateDumpPath(VirtualDatabaseAdmin module)
47   {
48     super(module);
49   }
50
51   /**
52    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#parse(java.lang.String)
53    */

54   public void parse(String JavaDoc commandText) throws Exception JavaDoc
55   {
56     String JavaDoc dumpName = null;
57     String JavaDoc newPath = null;
58     StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(commandText.trim());
59
60     if (st.countTokens() != 2)
61     {
62       console.printError(getUsage());
63       return;
64     }
65     try
66     {
67       dumpName = st.nextToken();
68       newPath = st.nextToken();
69       if (dumpName == null || newPath == null)
70       {
71         console.printError(getUsage());
72         return;
73       }
74
75       console.println(ConsoleTranslate.get("admin.command.update.dump.path.echo",
76           new String JavaDoc[]{dumpName, newPath}));
77       VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(dbName, user,
78           password);
79       vdjc.updateDumpPath(dumpName, newPath);
80       console.println(ConsoleTranslate.get("admin.command.update.dump.path.done",
81           new String JavaDoc[]{dumpName, newPath}));
82     }
83     catch (Exception JavaDoc e)
84     {
85       console.printError("problem while updating path", e); //TODO I18N
86
}
87   }
88
89   /**
90    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandName()
91    */

92   public String JavaDoc getCommandName()
93   {
94     return "force path";
95   }
96
97   /**
98    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandDescription()
99    */

100   public String JavaDoc getCommandDescription()
101   {
102     return ConsoleTranslate.get("admin.command.update.dump.path.description");
103   }
104
105   /**
106    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandParameters()
107    */

108   public String JavaDoc getCommandParameters()
109   {
110     return ConsoleTranslate.get("admin.command.update.dump.path.parameters");
111   }
112 }
113
Popular Tags