You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2010/09/24 10:19:13 UTC

svn commit: r1000756 - in /synapse/branches/2.0/modules: distribution/pom.xml distribution/src/main/assembly/bin.xml distribution/src/main/bin/synapse-config-migrator.sh migrator/src/main/java/org/apache/synapse/migrator/ConfigurationMigrator.java

Author: ruwan
Date: Fri Sep 24 08:19:12 2010
New Revision: 1000756

URL: http://svn.apache.org/viewvc?rev=1000756&view=rev
Log:
Adding the configuration migrator to the distro with a script, need some help from a windows person to write the bat :-(, committing to the branch

Added:
    synapse/branches/2.0/modules/distribution/src/main/bin/synapse-config-migrator.sh
Modified:
    synapse/branches/2.0/modules/distribution/pom.xml
    synapse/branches/2.0/modules/distribution/src/main/assembly/bin.xml
    synapse/branches/2.0/modules/migrator/src/main/java/org/apache/synapse/migrator/ConfigurationMigrator.java

Modified: synapse/branches/2.0/modules/distribution/pom.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.0/modules/distribution/pom.xml?rev=1000756&r1=1000755&r2=1000756&view=diff
==============================================================================
--- synapse/branches/2.0/modules/distribution/pom.xml (original)
+++ synapse/branches/2.0/modules/distribution/pom.xml Fri Sep 24 08:19:12 2010
@@ -51,6 +51,11 @@
             <artifactId>synapse-experimental</artifactId>
             <version>${pom.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.synapse</groupId>
+            <artifactId>synapse-config-migrator</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
 
         <!-- Wrapper jars -->
         <dependency>

Modified: synapse/branches/2.0/modules/distribution/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/synapse/branches/2.0/modules/distribution/src/main/assembly/bin.xml?rev=1000756&r1=1000755&r2=1000756&view=diff
==============================================================================
--- synapse/branches/2.0/modules/distribution/src/main/assembly/bin.xml (original)
+++ synapse/branches/2.0/modules/distribution/src/main/assembly/bin.xml Fri Sep 24 08:19:12 2010
@@ -40,6 +40,7 @@
             <outputDirectory>synapse-${synapse.version}/bin</outputDirectory>
             <includes>
                 <include>synapse.sh</include>
+                <include>synapse-config-migrator.sh</include>
                 <include>ciphertool.sh</include>
                 <include>synapse-daemon.sh</include>
             </includes>
@@ -92,6 +93,13 @@
             </includes>
         </fileSet>
         <fileSet>
+            <directory>../../modules/migrator/src/main/resources</directory>
+            <outputDirectory>synapse-${synapse.version}/resources</outputDirectory>
+            <includes>
+                <include>synapse-configuration-migrator.xslt</include>
+            </includes>
+        </fileSet>
+        <fileSet>
             <directory>src/main/bin</directory>
             <outputDirectory>synapse-${synapse.version}/lib</outputDirectory>
             <includes>
@@ -122,7 +130,7 @@
             <directory>src/main/bin/native</directory>
             <outputDirectory>synapse-${synapse.version}/bin/native</outputDirectory>
             <fileMode>755</fileMode>
-        </fileSet>      
+        </fileSet>
         <fileSet>
             <directory>../../src/site/resources/images</directory>
             <outputDirectory>synapse-${synapse.version}/docs/images</outputDirectory>
@@ -236,9 +244,9 @@
                 <exclude>xerces:xercesImpl:jar</exclude>
                 <exclude>junit:junit:jar</exclude>
                 <exclude>org.apache.mina:mina-core:jar</exclude>
-                <exclude>org.slf4j:slf4j-api:jar</exclude>
-                <exclude>org.slf4j:slf4j-jdk14:jar</exclude>
-                <exclude>org.slf4j:jcl-over-slf4j:jar</exclude>
+                <exclude>org.slf4j:slf4j-api:jar</exclude>
+                <exclude>org.slf4j:slf4j-jdk14:jar</exclude>
+                <exclude>org.slf4j:jcl-over-slf4j:jar</exclude>
                 <exclude>org.slf4j:log4j-over-slf4j:jar</exclude>
                 <exclude>com.oopsconsultancy:xmltask:jar</exclude>
             </excludes>

Added: synapse/branches/2.0/modules/distribution/src/main/bin/synapse-config-migrator.sh
URL: http://svn.apache.org/viewvc/synapse/branches/2.0/modules/distribution/src/main/bin/synapse-config-migrator.sh?rev=1000756&view=auto
==============================================================================
--- synapse/branches/2.0/modules/distribution/src/main/bin/synapse-config-migrator.sh (added)
+++ synapse/branches/2.0/modules/distribution/src/main/bin/synapse-config-migrator.sh Fri Sep 24 08:19:12 2010
@@ -0,0 +1,128 @@
+#!/bin/sh
+
+#   Licensed to the Apache Software Foundation (ASF) under one
+#   or more contributor license agreements.  See the NOTICE file
+#   distributed with this work for additional information
+#   regarding copyright ownership.  The ASF licenses this file
+#   to you 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.
+
+# -----------------------------------------------------------------------------
+#
+# Environment Variable Prequisites
+#
+#   SYNAPSE_HOME   Home of Synapse installation. If not set will use the parent directory
+#
+#   JAVA_HOME      Must point at your Java Development Kit installation.
+#
+# NOTE: Borrowed generously from Apache Tomcat startup scripts.
+
+# if JAVA_HOME is not set we're not happy
+if [ -z "$JAVA_HOME" ]; then
+  echo "You must set the JAVA_HOME variable before running Synapse."
+  exit 1
+fi
+
+# OS specific support.  $var _must_ be set to either true or false.
+cygwin=false
+os400=false
+case "`uname`" in
+CYGWIN*) cygwin=true;;
+OS400*) os400=true;;
+esac
+
+# resolve links - $0 may be a softlink
+PRG="$0"
+
+while [ -h "$PRG" ]; do
+  ls=`ls -ld "$PRG"`
+  link=`expr "$ls" : '.*-> \(.*\)$'`
+  if expr "$link" : '.*/.*' > /dev/null; then
+    PRG="$link"
+  else
+    PRG=`dirname "$PRG"`/"$link"
+  fi
+done
+
+# Get standard environment variables
+PRGDIR=`dirname "$PRG"`
+
+# Only set SYNAPSE_HOME if not already set
+[ -z "$SYNAPSE_HOME" ] && SYNAPSE_HOME=`cd "$PRGDIR/.." ; pwd`
+
+
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin; then
+  [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+  [ -n "$SYNAPSE_HOME" ] && SYNAPSE_HOME=`cygpath --unix "$SYNAPSE_HOME"`
+  [ -n "$AXIS2_HOME" ] && TUNGSTEN_HOME=`cygpath --unix "$SYNAPSE_HOME"`
+  [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For OS400
+if $os400; then
+  # Set job priority to standard for interactive (interactive - 6) by using
+  # the interactive priority - 6, the helper threads that respond to requests
+  # will be running at the same priority as interactive jobs.
+  COMMAND='chgjob job('$JOBNAME') runpty(6)'
+  system $COMMAND
+
+  # Enable multi threading
+  export QIBM_MULTI_THREADED=Y
+fi
+
+# update classpath - add any patches first
+SYNAPSE_CLASSPATH="$SYNAPSE_HOME/lib/patches"
+for f in $SYNAPSE_HOME/lib/patches/*.jar
+do
+  SYNAPSE_CLASSPATH=$SYNAPSE_CLASSPATH:$f
+done
+
+SYNAPSE_CLASSPATH=$SYNAPSE_CLASSPATH:"$SYNAPSE_HOME/lib"
+for f in $SYNAPSE_HOME/lib/*.jar
+do
+  SYNAPSE_CLASSPATH=$SYNAPSE_CLASSPATH:$f
+done
+SYNAPSE_CLASSPATH=$SYNAPSE_HOME/repository/conf:$JAVA_HOME/lib/tools.jar:$SYNAPSE_CLASSPATH:$CLASSPATH
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+  JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
+  SYNAPSE_HOME=`cygpath --absolute --windows "$SYNAPSE_HOME"`
+  AXIS2_HOME=`cygpath --absolute --windows "$SYNAPSE_HOME"`
+  CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+  JAVA_ENDORSED_DIRS=`cygpath --path --windows "$JAVA_ENDORSED_DIRS"`
+fi
+# endorsed dir
+SYNAPSE_ENDORSED=$SYNAPSE_HOME/lib/endorsed
+
+
+# ----- Execute The Requested Command -----------------------------------------
+
+cd $SYNAPSE_HOME
+echo "Starting Synapse/Java ..."
+echo "Using SYNAPSE_HOME:    $SYNAPSE_HOME"
+echo "Using JAVA_HOME:       $JAVA_HOME"
+echo "Using SYNAPSE_XML:     $SYNAPSE_XML"
+
+$JAVA_HOME/bin/java -server -Xms128M -Xmx128M \
+    $TEMP_PROPS \
+    -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XMLGrammarCachingConfiguration \
+    -Djava.endorsed.dirs=$SYNAPSE_ENDORSED \
+    -Djava.io.tmpdir=$SYNAPSE_HOME/work/temp/synapse \
+    -classpath $SYNAPSE_CLASSPATH \
+    org.apache.synapse.migrator.ConfigurationMigrator \
+        $1 \
+        $SYNAPSE_HOME/repository/conf/migrated-synapse.xml \
+        $SYNAPSE_HOME/resources/synapse-configuration-migrator.xslt \

Modified: synapse/branches/2.0/modules/migrator/src/main/java/org/apache/synapse/migrator/ConfigurationMigrator.java
URL: http://svn.apache.org/viewvc/synapse/branches/2.0/modules/migrator/src/main/java/org/apache/synapse/migrator/ConfigurationMigrator.java?rev=1000756&r1=1000755&r2=1000756&view=diff
==============================================================================
--- synapse/branches/2.0/modules/migrator/src/main/java/org/apache/synapse/migrator/ConfigurationMigrator.java (original)
+++ synapse/branches/2.0/modules/migrator/src/main/java/org/apache/synapse/migrator/ConfigurationMigrator.java Fri Sep 24 08:19:12 2010
@@ -29,7 +29,7 @@ import java.io.FileWriter;
 import java.io.IOException;
 
 /**
- * 
+ *
  */
 public class ConfigurationMigrator {
 
@@ -64,8 +64,21 @@ public class ConfigurationMigrator {
         System.out.println("\n[INFO] Migration STARTED");
 
         try {
-            doTransform(arguments[0], MIGRATOR_XSLT_PATH, arguments[1]);
+            if (arguments.length == 2) {
+                System.out.println("[INFO] Migrating the synapse 1.x configuration '"
+                        + arguments[0] + "' into a new 2.x configuration at '" + arguments[1] + "'");
+                doTransform(arguments[0], MIGRATOR_XSLT_PATH, arguments[1]);
+            } else if (arguments.length == 3) {
+                System.out.println("[INFO] Migrating the synapse 1.x configuration '"
+                        + arguments[0] + "' into a new 2.x configuration at '"
+                        + arguments[1] + "' using the XSLT '" + arguments[2] + "'");
+                doTransform(arguments[0], arguments[2], arguments[1]);
+            } else {
+                System.out.println("[ERROR] Invalid arguments provided for migration");
+            }
             System.out.println("[INFO] Migration SUCCESSFULLY COMPLETED");
+            System.out.println("[INFO] Migrated 2.x configuration is available at '"
+                    + arguments[1] + "'");
         } catch (TransformerException e) {
             handleException("Migration FAILED\n\t" + e.toString());
         } catch (IOException e) {