Home » geronimo-2.2-source-release » org.apache.geronimo.upgrade » [javadoc | source]

    1   /**
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   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   /**
   33    * @version $Rev: 486195 $ $Date: 2006-12-12 07:42:02 -0800 (Tue, 12 Dec 2006) $
   34    */
   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   }

Home » geronimo-2.2-source-release » org.apache.geronimo.upgrade » [javadoc | source]