openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r980240 - /openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java
Date Wed, 28 Jul 2010 21:38:36 GMT
Author: ppoddar
Date: Wed Jul 28 21:38:36 2010
New Revision: 980240

URL: http://svn.apache.org/viewvc?rev=980240&view=rev
Log:
OPENJPA-1747: correct test case input parameter

Modified:
    openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java

Modified: openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java
URL: http://svn.apache.org/viewvc/openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java?rev=980240&r1=980239&r2=980240&view=diff
==============================================================================
--- openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java
(original)
+++ openjpa/tools/trunk/openjpa-tools/src/main/java/org/apache/openjpa/tools/MigrationTool.java
Wed Jul 28 21:38:36 2010
@@ -46,6 +46,7 @@ import javax.xml.transform.TransformerFa
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.openjpa.lib.util.Files;
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.tools.action.Actions;
 import org.apache.openjpa.tools.util.LogRecordFormatter;
@@ -108,9 +109,8 @@ public class MigrationTool  {
     static final String DEFAULT_ACTIONS      = "META-INF/migration-actions.xml";
     
     private InputStream    _input;
-    private OutputStream   _ouput;
+    private OutputStream   _output;
     private InputStream    _rulebase;
-    
     private Document       _target;
     
     /**
@@ -135,8 +135,8 @@ public class MigrationTool  {
         _formatter = new LogRecordFormatter();
         
     	Properties defaults = new Properties();
-    	defaults.setProperty("output", "System.out");
-    	defaults.setProperty("error",  "System.err");
+    	defaults.setProperty("output", "stdout");
+    	defaults.setProperty("error",  "stderr");
     	defaults.setProperty("actions", DEFAULT_ACTIONS);
     	defaults.setProperty("verbose", "false");
     	
@@ -144,6 +144,8 @@ public class MigrationTool  {
     	options.setFromCmdLine(args);
     	options = options.setInto(this);
         
+        buildRepository(_rulebase);
+
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         factory.setValidating(false);
         factory.setFeature(LOAD_EXTERNAL_DTD, Boolean.FALSE);
@@ -164,8 +166,8 @@ public class MigrationTool  {
         serializer.setOutputProperty(OutputKeys.STANDALONE, "no");
         serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
         serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
-        serializer.transform(new DOMSource(_target), new StreamResult(_ouput));
-        _ouput.close();
+        serializer.transform(new DOMSource(_target), new StreamResult(_output));
+        _output.close();
     }
     
     public void setInput(String input) {
@@ -174,16 +176,12 @@ public class MigrationTool  {
     }
     
     public void setOutput(String output) {
-    	if ("System.out".equals(output)) {
-    		_ouput = System.out;
-    	} else {
-    		_ouput = getOutputStream(output);
-    	}
+    	_output = Files.getOutputStream(output, Thread.currentThread().getContextClassLoader());
     }
     
     public void setError(String errorOutput) throws IOException {
         Handler handler = null;
-        if ("System.err".equals(errorOutput)) {
+        if ("stderr".equals(errorOutput)) {
         	handler = new ConsoleHandler();
         } else if (errorOutput.endsWith("+")) {
             handler = new FileHandler(errorOutput.substring(errorOutput.length()-1), true);
@@ -197,7 +195,6 @@ public class MigrationTool  {
     
     public void setActions(String actions) throws Exception {
     	_rulebase = getInputStream(actions);
-    	buildRepository(_rulebase);
     }
     
     public void setVerbose(boolean verbose) {
@@ -397,13 +394,4 @@ public class MigrationTool  {
             throw new RuntimeException(this + " can not convert [" + v + "] into an input
stream", e);
         }
     }
-    
-    private OutputStream getOutputStream(String v) {
-        try {
-             return new PrintStream(new File(v));
-         } catch (Exception e) {
-             throw new RuntimeException(this + " can not convert " + v + " into an output
file stream", e);
-         }
-     }
-
 }



Mime
View raw message