[infinispan-commits] Infinispan SVN: r332 - in trunk/core/src: main/resources and 1 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Thu May 21 06:15:51 EDT 2009
Author: mircea.markus
Date: 2009-05-21 06:15:50 -0400 (Thu, 21 May 2009)
New Revision: 332
Modified:
trunk/core/src/main/java/org/infinispan/config/parsing/ConfigFilesConvertor.java
trunk/core/src/main/resources/importConfig.bat
trunk/core/src/main/resources/importConfig.sh
trunk/core/src/test/java/org/infinispan/config/parsing/Jbc2InfinispanTransformerTest.java
Log:
finished config inport work
Modified: trunk/core/src/main/java/org/infinispan/config/parsing/ConfigFilesConvertor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/ConfigFilesConvertor.java 2009-05-20 21:02:48 UTC (rev 331)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/ConfigFilesConvertor.java 2009-05-21 10:15:50 UTC (rev 332)
@@ -83,8 +83,8 @@
}
/**
- * Writes to the <b>os</b> the infinispan 4.x configuration file resulted by transforming configuration file passed in
- * as <b>inputFile</b>. Transformation is performed according to the <b>xsltFile</b>. Both <b>inputFile</b> and he
+ * Writes to the <b>os</b> the infinispan 4.x configuration file resulted by transforming configuration file passed
+ * in as <b>inputFile</b>. Transformation is performed according to the <b>xsltFile</b>. Both <b>inputFile</b> and he
* xslt file are looked up using a {@link org.jboss.cache.util.FileLookup}
*/
public void parse(String inputFile, OutputStream os, String xsltFile) throws Exception {
@@ -97,27 +97,38 @@
}
}
+ private static void help() {
+ System.out.println("Usage:");
+ System.out.println("ConfigFilesConvertor [-source <the file to be transformed>] [-destination <where to store resulting XML>] [-type <the type of the source, possible values being: " + Arrays.asList(SUPPORTED_FORMATS) + " >]");
+ }
+
+
/**
* usage : java org.jboss.cache.config.parsing.ConfigFilesConvertor -Dsource=config-2.x.xml
* -Ddestination=config-3.x.xnl
*/
- public static void main(String[] argv) throws Exception {
- String sourceName = System.getProperty("source");
- if (sourceName == null) {
- System.err.println("Missing property 'source'.");
- System.exit(1);
+ public static void main(String[] args) throws Exception {
+ String sourceName = null, destinationName = null, type = null;
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("-source")) {
+ sourceName = args[++i];
+ continue;
+ }
+ if (args[i].equals("-destination")) {
+ destinationName = args[++i];
+ continue;
+ }
+ if (args[i].equals("-type")) {
+ type = args[++i];
+ continue;
+ }
+ help();
}
- String destinationName = System.getProperty("destination");
- if (destinationName == null) {
- System.err.println("Missing property 'destination'.");
- System.exit(1);
- }
- String type = System.getProperty("type");
- if (type == null) {
- System.err.println("Missing property 'type'.");
- System.exit(1);
- }
+ mustExist(sourceName, "source");
+ mustExist(destinationName, "destination");
+ mustExist(type, "type");
+
List<String> stringList = Arrays.asList(SUPPORTED_FORMATS);
if (!stringList.contains(type)) {
System.err.println("Unsupported transformation type: " + type + ". Supported formats are: " + stringList);
@@ -126,12 +137,20 @@
if (type.equals(JBOSS_CACHE3X)) {
transformFromJbossCache3x(sourceName, destinationName);
}
-
+
System.out.println("---");
System.out.println("New configuration file [" + destinationName + "] successfully created.");
System.out.println("---");
}
+ private static void mustExist(String sourceName, String what) {
+ if (sourceName == null) {
+ System.err.println("Missing '" + what + "', cannot proceed");
+ help();
+ System.exit(1);
+ }
+ }
+
private static void transformFromJbossCache3x(String sourceName, String destinationName) throws Exception {
File oldConfig = new File(sourceName);
if (!oldConfig.exists()) {
Modified: trunk/core/src/main/resources/importConfig.bat
===================================================================
--- trunk/core/src/main/resources/importConfig.bat 2009-05-20 21:02:48 UTC (rev 331)
+++ trunk/core/src/main/resources/importConfig.bat 2009-05-21 10:15:50 UTC (rev 332)
@@ -1,9 +1,5 @@
@echo off
-if "%1a" == "a" goto noParams
-if "%2a" == "a" goto noParams
-if "%3a" == "a" goto noParams
-
setlocal enabledelayedexpansion
set LIB=
@@ -11,14 +7,6 @@
rem echo libs: %LIB%
set CP=%LIB%;..\modules\core\infinispan-core.jar;%CP%
-rem echo cp is %CP%
-java -classpath "%CP%" -Dsource=%1 -Ddestination=%2 -Dtype=%3 org.infinispan.config.parsing.ConfigFilesConvertor
-
-goto fileEnd
-
-:noParams
-echo usage: "%0 <file_to_transform> <destination_file> <source_file_type>"
-echo supported source types are: "JBossCache3x"
-
+java -classpath "%CP%" org.infinispan.config.parsing.ConfigFilesConvertor %1 %2 %3 %4 %5 %6
:fileEnd
\ No newline at end of file
Modified: trunk/core/src/main/resources/importConfig.sh
===================================================================
--- trunk/core/src/main/resources/importConfig.sh 2009-05-20 21:02:48 UTC (rev 331)
+++ trunk/core/src/main/resources/importConfig.sh 2009-05-21 10:15:50 UTC (rev 332)
@@ -1,11 +1,4 @@
#!/bin/bash
-if [ -z $1 ]
-then
- echo Usage:
- echo $0 [source_file] [destination_file] [source_file_type]
- echo supported source types are: "JBossCache3x"
- exit 1;
-fi
if [ -e ../modules/core/lib ]
then
for JAR in ../modules/core/lib/*
@@ -14,5 +7,4 @@
done
fi
CLASSPATH=../modules/core/infinispan-core.jar$CLASSPATH
-echo classpath is $CLASSPATH
-java -classpath $CLASSPATH -Dsource=$1 -Ddestination=$2 -Dtype=$3 org.infinispan.config.parsing.ConfigFilesConvertor
\ No newline at end of file
+java -classpath $CLASSPATH org.infinispan.config.parsing.ConfigFilesConvertor ${*}
\ No newline at end of file
Modified: trunk/core/src/test/java/org/infinispan/config/parsing/Jbc2InfinispanTransformerTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/parsing/Jbc2InfinispanTransformerTest.java 2009-05-20 21:02:48 UTC (rev 331)
+++ trunk/core/src/test/java/org/infinispan/config/parsing/Jbc2InfinispanTransformerTest.java 2009-05-21 10:15:50 UTC (rev 332)
@@ -39,8 +39,6 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
convertor.parse(fileName, baos, XSLT_FILE);
- String baosStr = new String(baos.toByteArray());
-
XmlConfigurationParser newParser = new XmlConfigurationParserImpl();
newParser.initialize(new ByteArrayInputStream(baos.toByteArray()));
GlobalConfiguration globalConfig = newParser.parseGlobalConfiguration();
@@ -121,7 +119,6 @@
ByteArrayOutputStream baos = new ByteArrayOutputStream();
convertor.parse(fileName, baos, XSLT_FILE);
- String baosStr = new String(baos.toByteArray());
}
} finally {
Thread.currentThread().setContextClassLoader(existingCl);
More information about the infinispan-commits
mailing list