KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2005 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): Emmanuel Cecchet.
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
30 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate;
31 import org.objectweb.cjdbc.common.jmx.mbeans.VirtualDatabaseMBean;
32 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin;
33
34 /**
35  * This class defines an Enable command to enable a backend from its last known
36  * checkpoint.
37  *
38  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
39  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
40  * </a>
41  * @version 1.0
42  */

43 public class Enable extends AbstractAdminCommand
44 {
45
46   /**
47    * Creates a new <code>Enable</code> object
48    *
49    * @param module the command is attached to
50    */

51   public Enable(VirtualDatabaseAdmin module)
52   {
53     super(module);
54   }
55
56   /**
57    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#parse(java.lang.String)
58    */

59   public void parse(String JavaDoc commandText) throws Exception JavaDoc
60   {
61     String JavaDoc backendName = null;
62
63     backendName = commandText.trim();
64
65     if ("".equals(backendName))
66     {
67       console.printError(getUsage());
68       return;
69     }
70     VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(dbName, user,
71         password);
72     if ("*".equals(backendName))
73     {
74       console.println(ConsoleTranslate
75           .get("admin.command.enable.all.with.checkpoint"));
76       ArrayList JavaDoc backendNames = vdjc.getAllBackendNames();
77       for (Iterator JavaDoc iter = backendNames.iterator(); iter.hasNext();)
78       {
79         String JavaDoc backend = (String JavaDoc) iter.next();
80         vdjc.enableBackendFromCheckpoint(backend);
81       }
82     }
83     else
84     {
85       console.println(ConsoleTranslate.get(
86           "admin.command.enable.with.checkpoint", backendName));
87       vdjc.enableBackendFromCheckpoint(backendName);
88     }
89   }
90
91   /**
92    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandName()
93    */

94   public String JavaDoc getCommandName()
95   {
96
97     return "enable";
98   }
99
100   /**
101    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandDescription()
102    */

103   public String JavaDoc getCommandDescription()
104   {
105     return ConsoleTranslate.get("admin.command.enable.description");
106   }
107
108   /**
109    * @see org.objectweb.cjdbc.console.text.commands.ConsoleCommand#getCommandParameters()
110    */

111   public String JavaDoc getCommandParameters()
112   {
113     return ConsoleTranslate.get("admin.command.enable.params");
114   }
115 }
116
Popular Tags