1 17 18 package org.apache.geronimo.upgrade; 19 20 import java.io.InputStream ; 21 import java.io.FileInputStream ; 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.io.PrintWriter ; 25 import java.io.FileWriter ; 26 import java.io.Writer ; 27 28 import org.apache.xmlbeans.XmlException; 29 import org.apache.geronimo.gbean.GBeanInfo; 30 import org.apache.geronimo.gbean.GBeanInfoBuilder; 31 32 35 public class UpgradeGBean { 36 37 public void execute(String [] args) throws Exception { 38 if (args == null || args.length == 0 || args.length > 2) { 39 System.out.println("Parameter usage: "); 40 System.out.println("inputPlan outputPlan"); 41 System.out.println("or"); 42 System.out.println("inputPlan"); 43 System.out.println("in which case the output will be in the same location as inputPlan with '.upgraded' appended"); 44 return; 45 } 46 String inputFile = args[0]; 47 String outFile = args.length == 2? args[1]: inputFile + ".upgrade"; 48 execute(inputFile, outFile); 49 } 50 51 public void execute(String infile, String outfile) throws IOException , XmlException { 52 File inFile = new File (infile); 53 if (!inFile.exists() || inFile.isDirectory()) { 54 throw new IOException ("Input file " + inFile + " does not exist"); 55 } 56 InputStream in = new FileInputStream (inFile); 57 File outFile = new File (outfile); 58 Writer out = new FileWriter (outFile); 59 PrintWriter outWriter = new PrintWriter (out); 60 new Upgrade1_0To1_1().upgrade(in, outWriter); 61 outWriter.flush(); 62 outWriter.close(); 63 in.close(); 64 } 65 66 public static void main(String [] args) throws Exception { 67 new UpgradeGBean().execute(args); 68 } 69 70 public static final GBeanInfo GBEAN_INFO; 71 72 static { 73 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(UpgradeGBean.class); 74 infoBuilder.addOperation("execute", new Class [] {String [].class}); 75 infoBuilder.addOperation("execute", new Class [] {String .class, String .class}); 76 GBEAN_INFO = infoBuilder.getBeanInfo(); 77 } 78 79 public static GBeanInfo getGBeanInfo() { 80 return GBEAN_INFO; 81 } 82 } 83 | Popular Tags |