activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1033932 - in /activemq/activemq-apollo/trunk: apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/ apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/ apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ apollo-uti...
Date Thu, 11 Nov 2010 13:30:37 GMT
Author: chirino
Date: Thu Nov 11 13:30:37 2010
New Revision: 1033932

URL: http://svn.apache.org/viewvc?rev=1033932&view=rev
Log:
Moved the RichFile stuff into the FileSupport class in the util module.

Modified:
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala
    activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileSupport.scala

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala?rev=1033932&r1=1033931&r2=1033932&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/Apollo.scala
Thu Nov 11 13:30:37 2010
@@ -24,6 +24,7 @@ import org.apache.karaf.shell.console.jl
 import jline.Terminal
 import org.fusesource.jansi.Ansi
 import java.io.{OutputStream, PrintStream, InputStream}
+import org.apache.activemq.apollo.util.FileSupport._
 
 /**
  * <p>
@@ -63,7 +64,7 @@ class Apollo extends Main with Action {
       protected override def isPrintStackTraces = debug
       protected override def welcome = {
         val source = getClass().getResourceAsStream("banner.txt")
-        commands.Helper.copy(source, session.getConsole())
+        copy(source, session.getConsole())
       }
 
       protected override def setSessionProperties = {}

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala?rev=1033932&r1=1033931&r2=1033932&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
Thu Nov 11 13:30:37 2010
@@ -23,6 +23,7 @@ import org.fusesource.jansi.Ansi.Color._
 import org.fusesource.jansi.Ansi.Attribute._
 import Helper._
 import java.io._
+import org.apache.activemq.apollo.util.FileSupport._
 
 object Create {
   val IS_WINDOWS = System.getProperty("os.name").toLowerCase().trim().startsWith("win");

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala?rev=1033932&r1=1033931&r2=1033932&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Helper.scala
Thu Nov 11 13:30:37 2010
@@ -34,47 +34,8 @@ object Helper {
 
   def error(value:Any) = throw new Failure(value.toString)
 
-  def system_dir(name:String) = {
-    val base_value = System.getProperty(name)
-    if( base_value==null ) {
-      error("The the %s system property is not set.".format(name))
-    }
-    val file = new File(base_value)
-    if( !file.isDirectory  ) {
-      error("The the %s system property is not set to valid directory path %s".format(name,
base_value))
-    }
-    file
-  }
-
-
-  class RichFile(file:File) {
-    def / (path:String) = new File(file, path)
-  }
-  implicit def toRichFile(file:File):RichFile = new RichFile(file)
-
   def bold(v:String) = ansi.a(INTENSITY_BOLD).a(v).reset
 
-
-  def copy(in: InputStream, out: OutputStream): Long = {
-    try {
-      var bytesCopied: Long = 0
-      val buffer = new Array[Byte](8192)
-      var bytes = in.read(buffer)
-      while (bytes >= 0) {
-        out.write(buffer, 0, bytes)
-        bytesCopied += bytes
-        bytes = in.read(buffer)
-      }
-      bytesCopied
-    } finally {
-      try { in.close  }  catch { case ignore =>  }
-    }
-  }
-
-  def close(out: OutputStream) = {
-    try { out.close  }  catch { case ignore =>  }
-  }
-
 }
 
 

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala?rev=1033932&r1=1033931&r2=1033932&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Run.scala
Thu Nov 11 13:30:37 2010
@@ -32,7 +32,8 @@ import org.apache.commons.logging.LogFac
 import org.apache.activemq.apollo.broker.{BrokerRegistry, Broker, ConfigStore, FileConfigStore}
 import org.fusesource.hawtdispatch._
 import Helper._
-import org.apache.activemq.apollo.util.{Logging, ServiceControl}
+import org.apache.activemq.apollo.util.{FileSupport, Logging, ServiceControl}
+import FileSupport._
 
 /**
  * The apollo create command

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala?rev=1033932&r1=1033931&r2=1033932&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/test/scala/org/apache/activemq/apollo/cli/ApolloIDERunner.scala
Thu Nov 11 13:30:37 2010
@@ -40,7 +40,7 @@ object ApolloIDERunner  {
  */
 class ApolloIDERunner  {
 
-  import commands.Helper._
+  import org.apache.activemq.apollo.util.FileSupport._
 
   @Test
   def run:Unit = {

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileSupport.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileSupport.scala?rev=1033932&r1=1033931&r2=1033932&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileSupport.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileSupport.scala
Thu Nov 11 13:30:37 2010
@@ -16,7 +16,8 @@
  */
 package org.apache.activemq.apollo.util
 
-import tools.nsc.io.{File, Path, Directory}
+import tools.nsc.io.Path
+import java.io.{OutputStream, InputStream, File}
 
 object FileSupport {
 
@@ -37,12 +38,52 @@ object FileSupport {
     source.toDirectory.list.foreach(createOrCopy)
   }
 
-  def toDirectory(name: String) : Directory = {
-    new Directory(new java.io.File(name))
+  def toDirectory(name: String) = {
+    new tools.nsc.io.Directory(new File(name))
   }
 
-  def toFile(name: String) : File = {
-    new File(new java.io.File(name))
+  def toFile(name: String) = {
+    new tools.nsc.io.File(new File(name))
   }
-  
+
+
+  def system_dir(name:String) = {
+    val base_value = System.getProperty(name)
+    if( base_value==null ) {
+      error("The the %s system property is not set.".format(name))
+    }
+    val file = new File(base_value)
+    if( !file.isDirectory  ) {
+      error("The the %s system property is not set to valid directory path %s".format(name,
base_value))
+    }
+    file
+  }
+
+
+  class RichFile(file:File) {
+    def / (path:String) = new File(file, path)
+  }
+  implicit def toRichFile(file:File):RichFile = new RichFile(file)
+
+
+  def copy(in: InputStream, out: OutputStream): Long = {
+    try {
+      var bytesCopied: Long = 0
+      val buffer = new Array[Byte](8192)
+      var bytes = in.read(buffer)
+      while (bytes >= 0) {
+        out.write(buffer, 0, bytes)
+        bytesCopied += bytes
+        bytes = in.read(buffer)
+      }
+      bytesCopied
+    } finally {
+      try { in.close  }  catch { case ignore =>  }
+    }
+  }
+
+  def close(out: OutputStream) = {
+    try { out.close  }  catch { case ignore =>  }
+  }
+
 }
\ No newline at end of file



Mime
View raw message