You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2006/05/12 23:21:58 UTC

svn commit: r405877 - in /geronimo/branches/1.1/modules/upgrade: ./ src/java/org/apache/geronimo/upgrade/ src/test/org/apache/geronimo/upgrade/

Author: djencks
Date: Fri May 12 14:21:58 2006
New Revision: 405877

URL: http://svn.apache.org/viewcvs?rev=405877&view=rev
Log:
GERONIMO-2013 provide a command line upgrade tool

Added:
    geronimo/branches/1.1/modules/upgrade/maven.xml
    geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/CLIUpgrade.java
Modified:
    geronimo/branches/1.1/modules/upgrade/project.properties
    geronimo/branches/1.1/modules/upgrade/project.xml
    geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/Upgrade1_0To1_1.java
    geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java

Added: geronimo/branches/1.1/modules/upgrade/maven.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/upgrade/maven.xml?rev=405877&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/upgrade/maven.xml (added)
+++ geronimo/branches/1.1/modules/upgrade/maven.xml Fri May 12 14:21:58 2006
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+
+    Copyright 2006 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $ -->
+
+<project default="default"
+         xmlns:j="jelly:core"
+         xmlns:define="jelly:define"
+         xmlns:velocity="jelly:velocity">
+
+    <!-- ==================== -->
+    <!-- Default Global Goals -->
+    <!-- ==================== -->
+
+    <goal name="default">
+        <attainGoal name="build"/>
+    </goal>
+
+    <goal name="build">
+        <attainGoal name="jar:install"/>
+    </goal>
+
+    <goal name="rebuild">
+        <attainGoal name="clean"/>
+        <attainGoal name="build"/>
+    </goal>
+
+    <preGoal name="jar:jar">
+
+
+        <j:forEach var="dep" items="${pom.dependencies}">
+            <j:if test="${!dep.artifactId.equals('velocity') and  !dep.artifactId.equals('commons-jelly-tags-velocity')}">
+                <unjar src="${maven.repo.local}/${dep.groupId}/jars/${dep.artifact}" dest="${maven.build.dir}/classes"/>
+            </j:if>
+        </j:forEach>
+    </preGoal>
+
+</project>

Modified: geronimo/branches/1.1/modules/upgrade/project.properties
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/upgrade/project.properties?rev=405877&r1=405876&r2=405877&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/upgrade/project.properties (original)
+++ geronimo/branches/1.1/modules/upgrade/project.properties Fri May 12 14:21:58 2006
@@ -4,3 +4,5 @@
 
 # set eclipse project name (used in eclipse plugin V1.11 onwards)
 maven.eclipse.project.name=${geronimo.maven.eclipse.modules.project.prefix}${pom.artifactId}
+
+maven.jar.mainclass=org.apache.geronimo.upgrade.CLIUpgrade
\ No newline at end of file

Modified: geronimo/branches/1.1/modules/upgrade/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/upgrade/project.xml?rev=405877&r1=405876&r2=405877&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/upgrade/project.xml (original)
+++ geronimo/branches/1.1/modules/upgrade/project.xml Fri May 12 14:21:58 2006
@@ -42,60 +42,13 @@
 
     <dependencies>
         <!-- Module Dependencies -->
-        <dependency>
-            <groupId>geronimo</groupId>
-            <artifactId>geronimo-client-builder</artifactId>
-            <version>${geronimo_version}</version>
-        </dependency>
 
         <dependency>
             <groupId>geronimo</groupId>                 
-            <artifactId>geronimo-connector-builder</artifactId>          
-            <version>${geronimo_version}</version>                     
-        </dependency>
-                                                                                                                             
-        <dependency>
-            <groupId>geronimo</groupId>                 
-            <artifactId>geronimo-j2ee-builder</artifactId>          
-            <version>${geronimo_version}</version>                     
-        </dependency>
-                                                                                                                             
-        <dependency>
-            <groupId>geronimo</groupId>                 
-            <artifactId>geronimo-jetty-builder</artifactId>          
-            <version>${geronimo_version}</version>                     
-        </dependency>
-                                                                                                                             
-        <dependency>
-            <groupId>geronimo</groupId>                 
-            <artifactId>geronimo-naming-builder</artifactId>          
-            <version>${geronimo_version}</version>                     
-        </dependency>
-                                                                                                                             
-        <dependency>
-            <groupId>geronimo</groupId>                 
-            <artifactId>geronimo-security-builder</artifactId>          
-            <version>${geronimo_version}</version>                     
-        </dependency>
-                                                                                                                             
-        <dependency>
-            <groupId>geronimo</groupId>                 
             <artifactId>geronimo-service-builder</artifactId>          
             <version>${geronimo_version}</version>                     
         </dependency>
-                                                                                                                             
-        <dependency>
-            <groupId>geronimo</groupId>                 
-            <artifactId>geronimo-tomcat-builder</artifactId>          
-            <version>${geronimo_version}</version>                     
-        </dependency>
-                                                                                                                             
-        <dependency>
-            <groupId>geronimo</groupId>                 
-            <artifactId>geronimo-web-builder</artifactId>          
-            <version>${geronimo_version}</version>                     
-        </dependency>
-                                                                                                                             
+
         <dependency>
             <groupId>geronimo</groupId>                 
             <artifactId>geronimo-common</artifactId>          
@@ -103,12 +56,6 @@
         </dependency>
 
         <dependency>
-            <groupId>openejb</groupId>                 
-            <artifactId>openejb-builder</artifactId>          
-            <version>${openejb_version}</version>                     
-        </dependency>
-                             
-        <dependency>
             <groupId>xmlbeans</groupId>
             <artifactId>xbean</artifactId>
             <version>${xmlbeans_version}</version>
@@ -124,15 +71,14 @@
             <groupId>geronimo</groupId>
             <artifactId>geronimo-j2ee-schema</artifactId>
             <version>${pom.currentVersion}</version>
-            <properties>
-                <xmlbeans>true</xmlbeans>
-            </properties>
         </dependency>
+
         <dependency>
             <groupId>geronimo</groupId>
             <artifactId>geronimo-kernel</artifactId>
             <version>${pom.currentVersion}</version>
         </dependency>
+
         <dependency>
             <groupId>mx4j</groupId>
             <artifactId>mx4j</artifactId>

Added: geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/CLIUpgrade.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/CLIUpgrade.java?rev=405877&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/CLIUpgrade.java (added)
+++ geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/CLIUpgrade.java Fri May 12 14:21:58 2006
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.upgrade;
+
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+
+import org.apache.xmlbeans.XmlException;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class CLIUpgrade {
+
+    public void execute(String infile, String outfile) throws IOException, XmlException {
+        File inFile = new File(infile);
+        if (!inFile.exists() || inFile.isDirectory()) {
+            throw new IOException("Input file " + inFile + " does not exist");
+        }
+        InputStream in = new FileInputStream(inFile);
+        File outFile = new File(outfile);
+        OutputStream out = new FileOutputStream(outFile);
+        PrintWriter outWriter = new PrintWriter(out);
+        new Upgrade1_0To1_1().upgrade(in, outWriter);
+        outWriter.flush();
+        outWriter.close();
+        in.close();
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args == null || args.length == 0 || args.length > 2) {
+            System.out.println("Parameter usage: ");
+            System.out.println("inputPlan outputPlan");
+            System.out.println("or");
+            System.out.println("inputPlan");
+            System.out.println("in which case the output will be in the same location as inputPlan with '.upgraded' appended");
+            return;
+        }
+        String inputFile = args[0];
+        String outFile = args.length == 2? args[1]: inputFile + ".upgrade";
+        new CLIUpgrade().execute(inputFile, outFile);
+    }
+}

Modified: geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/Upgrade1_0To1_1.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/Upgrade1_0To1_1.java?rev=405877&r1=405876&r2=405877&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/Upgrade1_0To1_1.java (original)
+++ geronimo/branches/1.1/modules/upgrade/src/java/org/apache/geronimo/upgrade/Upgrade1_0To1_1.java Fri May 12 14:21:58 2006
@@ -82,19 +82,24 @@
     private static final String DEFAULT_VERSION = "1-default";
     private static final QName CLIENT_ENVIRONMENT_QNAME = new QName("http://geronimo.apache.org/xml/ns/deployment-1.1", "client-environment");
     private static final QName SERVER_ENVIRONMENT_QNAME = new QName("http://geronimo.apache.org/xml/ns/deployment-1.1", "server-environment");
-    private static final QName EJB_LINK_QNAME = new QName("http://geronimo.apache.org/xml/ns/naming-1.1", "ejb-link");
     private static final QName PATTERN_QNAME = new QName("http://geronimo.apache.org/xml/ns/naming-1.1", "pattern");
     private static final QName GROUP_QNAME = new QName("http://geronimo.apache.org/xml/ns/naming-1.1", "groupId");
     private static final QName ARTIFACT_QNAME = new QName("http://geronimo.apache.org/xml/ns/naming-1.1", "artifactId");
-    private static final QName VERSION_QNAME = new QName("http://geronimo.apache.org/xml/ns/naming-1.1", "version");
-    private static final QName TYPE_QNAME = new QName("http://geronimo.apache.org/xml/ns/naming-1.1", "type");
     private static final QName MODULE_QNAME = new QName("http://geronimo.apache.org/xml/ns/naming-1.1", "module");
     private static final QName NAME_QNAME = new QName("http://geronimo.apache.org/xml/ns/naming-1.1", "name");
     private static final QName GBEAN_NAME_QNAME = new QName(null, "gbeanName");
-;
 
-    public static void upgrade(InputStream source, Writer target) throws IOException, XmlException {
+    public void upgrade(InputStream source, Writer target) throws IOException, XmlException {
         XmlObject xmlObject = parse(source);
+        xmlObject = upgrade(xmlObject);
+
+        XmlOptions xmlOptions = new XmlOptions();
+        xmlOptions.setSavePrettyPrint();
+        xmlObject.save(target, xmlOptions);
+
+    }
+
+    public XmlObject upgrade(XmlObject xmlObject) throws XmlException {
         XmlCursor cursor = xmlObject.newCursor();
         XmlCursor.TokenType token;
         while ((token = cursor.toNextToken()) != XmlCursor.TokenType.ENDDOC) {
@@ -119,11 +124,7 @@
                 checkInvalid(cursor);
             }
         }
-
-        XmlOptions xmlOptions = new XmlOptions();
-        xmlOptions.setSavePrettyPrint();
-        xmlObject.save(target, xmlOptions);
-
+        return xmlObject;
     }
 
     private static void checkInvalid(XmlCursor cursor) throws XmlException {

Modified: geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java?rev=405877&r1=405876&r2=405877&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java (original)
+++ geronimo/branches/1.1/modules/upgrade/src/test/org/apache/geronimo/upgrade/Upgrade1_0To1_1Test.java Fri May 12 14:21:58 2006
@@ -73,7 +73,7 @@
     private void test(String testName) throws Exception {
         InputStream srcXml = classLoader.getResourceAsStream(testName + ".xml");
         Writer targetXml = new StringWriter();
-        Upgrade1_0To1_1.upgrade(srcXml, targetXml);
+        new Upgrade1_0To1_1().upgrade(srcXml, targetXml);
 
         String targetString = targetXml.toString();
         XmlObject targetXmlObject = XmlObject.Factory.parse(targetString);