1 24 25 package org.objectweb.cjdbc.console.text.commands.dbadmin; 26 27 import java.io.BufferedWriter ; 28 import java.io.File ; 29 import java.io.FileWriter ; 30 import java.util.StringTokenizer ; 31 32 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate; 33 import org.objectweb.cjdbc.common.jmx.mbeans.VirtualDatabaseMBean; 34 import org.objectweb.cjdbc.console.text.module.VirtualDatabaseAdmin; 35 36 42 public class GetBackendSchema extends AbstractAdminCommand 43 { 44 45 50 public GetBackendSchema(VirtualDatabaseAdmin module) 51 { 52 super(module); 53 } 54 55 58 public void parse(String commandText) throws Exception 59 { 60 61 StringTokenizer st = new StringTokenizer (commandText); 62 int tokens = st.countTokens(); 63 if (tokens < 1) 64 { 65 console.printError(getUsage()); 66 return; 67 } 68 69 String backendName = st.nextToken(); 70 String fileName = null; 71 if (tokens >= 2) 72 { 73 fileName = st.nextToken().trim(); 74 } 75 76 VirtualDatabaseMBean vdjc = jmxClient.getVirtualDatabaseProxy(dbName, user, 77 password); 78 79 if (fileName == null) 80 { 81 console.println(vdjc.getBackendSchema(backendName)); 83 } 84 else 85 { 86 console.println(ConsoleTranslate.get( 87 "admin.command.get.backend.schema.echo", new String []{backendName, 88 fileName})); 89 File f = new File (fileName); 91 BufferedWriter writer = new BufferedWriter (new FileWriter (f)); 92 writer.write(vdjc.getBackendSchema(backendName)); 93 writer.flush(); 94 writer.close(); 95 } 96 97 } 98 99 102 public String getCommandName() 103 { 104 return "get backend schema"; 105 } 106 107 110 public String getCommandDescription() 111 { 112 return ConsoleTranslate.get("admin.command.get.backend.schema.description"); 113 } 114 115 118 public String getCommandParameters() 119 { 120 return ConsoleTranslate.get("admin.command.get.backend.schema.params"); 121 } 122 123 } | Popular Tags |