KickJava   Java API By Example, From Geeks To Geeks.

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


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): Nicolas Modrzyk
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.console.text.commands.dbadmin;
26
27 import java.util.ArrayList JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.StringTokenizer JavaDoc;
30
31 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate;
32 import org.objectweb.cjdbc.common.jmx.mbeans.VirtualDatabaseMBean;
33 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin;
34
35 /**
36  * This class defines a Disable
37  *
38  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
39  * @version 1.0
40  */

41 public class Disable extends AbstractAdminCommand
42 {
43   /**
44    * Creates a new <code>Disable.java</code> object
45    *
46    * @param module the command is attached to
47    */

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

56   public void parse(String JavaDoc commandText) throws Exception JavaDoc
57   {
58     String JavaDoc backendName = null;
59
60     StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(commandText);
61     if (st.countTokens() != 1)
62     {
63       console.printError(getUsage());
64       return;
65     }
66     try
67     {
68       backendName = st.nextToken();
69     }
70     catch (Exception JavaDoc e)
71     {
72       console.printError(getUsage());
73       return;
74     }
75
76     VirtualDatabaseMBean vjdc = jmxClient.getVirtualDatabaseProxy(dbName, user,
77         password);
78     if ("*".equals(backendName))
79     {
80       console.println(ConsoleTranslate
81           .get("admin.command.disable.backend.all.with.checkpoint"));
82       ArrayList JavaDoc backendNames = vjdc.getAllBackendNames();
83       for (Iterator JavaDoc iter = backendNames.iterator(); iter.hasNext();)
84       {
85         String JavaDoc backend = (String JavaDoc) iter.next();
86         vjdc.disableBackendWithCheckpoint(backend);
87       }
88     }
89     else
90     {
91       vjdc.disableBackendWithCheckpoint(backendName);
92       console.println(ConsoleTranslate.get(
93           "admin.command.disable.backend.with.checkpoint", backendName));
94     }
95   }
96
97   /**
98    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandParameters()
99    */

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

108   public String JavaDoc getCommandName()
109   {
110     return "disable";
111   }
112
113   /**
114    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandDescription()
115    */

116   public String JavaDoc getCommandDescription()
117   {
118     return ConsoleTranslate.get("admin.command.disable.backend.description");
119   }
120
121 }
122
Popular Tags