1 24 25 package org.objectweb.cjdbc.console.text.commands.dbadmin; 26 27 import java.util.StringTokenizer ; 28 29 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate; 30 import org.objectweb.cjdbc.common.jmx.mbeans.DatabaseBackendMBean; 31 import org.objectweb.cjdbc.common.jmx.mbeans.VirtualDatabaseMBean; 32 import org.objectweb.cjdbc.console.text.ConsoleException; 33 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin; 34 35 41 public class EnableWrite extends AbstractAdminCommand 42 { 43 44 49 public EnableWrite(VirtualDatabaseAdmin module) 50 { 51 super(module); 52 } 53 54 57 public void parse(String commandText) throws Exception 58 { 59 StringTokenizer st = new StringTokenizer (commandText); 60 if (st.countTokens() != 1) 61 throw new ConsoleException(ConsoleTranslate 62 .get("console.error.invalid.comment.argument")); 63 String backendName = st.nextToken(); 64 console.println(ConsoleTranslate.get("admin.command.enable.write.echo", 65 backendName)); 66 VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(dbName, user, 67 password); 68 DatabaseBackendMBean mbean = jmxClient.getDatabaseBackendProxy(dbName, 69 backendName, user, password); 70 if(vdjc.hasRecoveryLog()) 71 { 72 if(mbean.isWriteEnabled()) 73 return; 74 vdjc.enableBackendFromCheckpoint(backendName); 75 } 76 else 77 { 78 mbean.enableWrite(); 79 } 80 81 82 } 83 84 87 public String getCommandName() 88 { 89 return "enableWrite"; 90 } 91 92 95 public String getCommandDescription() 96 { 97 return ConsoleTranslate.get("admin.command.enable.write"); 98 } 99 100 103 public String getCommandParameters() 104 { 105 return "<backendName>"; 106 } 107 108 } 109 | Popular Tags |