src/org/objectweb/cjdbc/console/text/commands/controller/AddDriver.java

説明を見る。
00001 00025 package org.objectweb.cjdbc.console.text.commands.controller; 00026 00027 import java.io.File; 00028 import java.io.FileInputStream; 00029 import java.io.FileNotFoundException; 00030 import java.io.IOException; 00031 00032 import org.objectweb.cjdbc.common.i18n.ConsoleTranslate; 00033 import org.objectweb.cjdbc.console.text.ConsoleException; 00034 import org.objectweb.cjdbc.console.text.commands.ConsoleCommand; 00035 import org.objectweb.cjdbc.console.text.module.AbstractConsoleModule; 00036 00043 public class AddDriver extends ConsoleCommand 00044 { 00045 00051 public AddDriver(AbstractConsoleModule module) 00052 { 00053 super(module); 00054 } 00055 00059 public void parse(String commandText) throws IOException, ConsoleException 00060 { 00061 String filename = null; 00062 // Get the file name if needed 00063 if (commandText == null || commandText.trim().equals("")) 00064 { 00065 try 00066 { 00067 filename = console.readLine(ConsoleTranslate 00068 .get("controller.command.adddriver.input.filename")); 00069 } 00070 catch (Exception che) 00071 { 00072 } 00073 } 00074 else 00075 filename = commandText.trim(); 00076 00077 if (filename == null || filename.equals("")) 00078 throw new ConsoleException(ConsoleTranslate 00079 .get("controller.command.adddriver.null.filename")); 00080 00081 try 00082 { 00083 // Send the file contents to the controller 00084 jmxClient.getControllerProxy().addDriver(readDriver(filename)); 00085 console.println(ConsoleTranslate.get( 00086 "controller.command.adddriver.file.sent", filename)); 00087 } 00088 catch (FileNotFoundException fnf) 00089 { 00090 throw new ConsoleException(ConsoleTranslate.get( 00091 "controller.command.adddriver.file.not.found", filename)); 00092 } 00093 catch (Exception ioe) 00094 { 00095 throw new ConsoleException(ConsoleTranslate.get( 00096 "controller.command.adddriver.sent.failed", ioe)); 00097 } 00098 } 00099 00100 private byte[] readDriver(String filename) throws FileNotFoundException, 00101 IOException 00102 { 00103 File file; 00104 FileInputStream fileInput = null; 00105 file = new File(filename); 00106 fileInput = new FileInputStream(file); 00107 00108 // Read the file into an array of bytes 00109 long size = file.length(); 00110 if (size > Integer.MAX_VALUE) 00111 throw new IOException(ConsoleTranslate 00112 .get("controller.command.adddriver.file.too.big")); 00113 byte[] bytes = new byte[(int) size]; 00114 int nb = fileInput.read(bytes); 00115 fileInput.close(); 00116 if (nb != size) 00117 throw new IOException(ConsoleTranslate 00118 .get("controller.command.adddriver.file.not.read")); 00119 return bytes; 00120 } 00121 00125 public String getCommandName() 00126 { 00127 return "addDriver"; 00128 } 00129 00133 public String getCommandDescription() 00134 { 00135 return ConsoleTranslate.get("controller.command.adddriver"); 00136 } 00137 00141 public String getCommandParameters() 00142 { 00143 return "<driverPathName>"; 00144 } 00145 00146 }

CJDBCversion1.0.4に対してTue Oct 12 15:15:59 2004に生成されました。 doxygen 1.3.8