1 22 23 package org.continuent.sequoia.console.text.commands.controller; 24 25 import java.io.BufferedReader ; 26 import java.io.FileReader ; 27 28 import org.continuent.sequoia.common.i18n.ConsoleTranslate; 29 import org.continuent.sequoia.console.text.ConsoleException; 30 import org.continuent.sequoia.console.text.ConsoleLauncher; 31 import org.continuent.sequoia.console.text.commands.ConsoleCommand; 32 import org.continuent.sequoia.console.text.module.AbstractConsoleModule; 33 34 40 public class LoadVirtualDatabase extends ConsoleCommand 41 { 42 47 public LoadVirtualDatabase(AbstractConsoleModule module) 48 { 49 super(module); 50 } 51 52 55 public void parse(String commandText) throws Exception 56 { 57 checkJmxConnectionToController(); 58 59 String filename = null; 60 if (commandText == null || commandText.trim().equals("")) filename = console.readLine(ConsoleTranslate 63 .get("controller.command.load.vdb.input")); else 65 filename = commandText.trim(); 66 if (filename == null) 67 throw new ConsoleException(ConsoleTranslate 68 .get("controller.command.load.vdb.file.null")); FileReader fileReader; 70 fileReader = new FileReader (filename); 71 72 BufferedReader in = new BufferedReader (fileReader); 74 StringBuffer xml = new StringBuffer (); 75 String line; 76 do 77 { 78 line = in.readLine(); 79 if (line != null) 80 xml.append(line); 81 } 82 while (line != null); 83 84 jmxClient.getControllerProxy().addVirtualDatabases(xml.toString()); 86 console.printInfo(ConsoleTranslate.get( 87 "controller.command.load.vdb.success", new String [] {filename, ConsoleLauncher.PRODUCT_NAME})); 89 } 90 91 94 public String getCommandName() 95 { 96 return "load virtualdatabase configuration"; } 98 99 102 public String getCommandDescription() 103 { 104 return ConsoleTranslate.get("controller.command.load.vdb.description"); } 106 107 110 public String getCommandParameters() 111 { 112 return ConsoleTranslate.get("controller.command.load.vdb.params"); } 114 } 115 | Popular Tags |