activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1052075 - /activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
Date Wed, 22 Dec 2010 21:34:11 GMT
Author: chirino
Date: Wed Dec 22 21:34:11 2010
New Revision: 1052075

URL: http://svn.apache.org/viewvc?rev=1052075&view=rev
Log:
smarter default config generation.

Modified:
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala

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=1052075&r1=1052074&r2=1052075&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
Wed Dec 22 21:34:11 2010
@@ -24,8 +24,8 @@ import org.fusesource.jansi.Ansi.Attribu
 import Helper._
 import java.io._
 import org.apache.activemq.apollo.util.FileSupport._
-import java.util.regex.Matcher
 import java.nio.charset.Charset
+import java.util.regex.{Pattern, Matcher}
 
 object Create {
   val IS_WINDOWS = System.getProperty("os.name").toLowerCase().trim().startsWith("win");
@@ -43,7 +43,7 @@ class Create extends Action {
   var directory:File = _
 
   @option(name = "--host", description = "The host name of the broker")
-  var host:String = "localhost"
+  var host:String = _
 
   @option(name = "--force", description = "Overwrite configuration at destination directory")
   var force = false
@@ -60,6 +60,10 @@ class Create extends Action {
     try {
       println("Creating apollo instance at: %s".format(directory))
 
+      if( host == null ) {
+        host = directory.getName
+      }
+
       val bin = directory / "bin"
       bin.mkdirs
 
@@ -149,8 +153,8 @@ class Create extends Action {
       var content = new String(out.toByteArray, "UTF-8")
 
       if( filter ) {
-        content = content.replaceAll("${host}", Matcher.quoteReplacement(host))
-        content = content.replaceAll("${version}", Matcher.quoteReplacement(version))
+        content = content.replaceAll(Pattern.quote("${host}"), Matcher.quoteReplacement(host))
+        content = content.replaceAll(Pattern.quote("${version}"), Matcher.quoteReplacement(version))
       }
 
       // and then writing out in the new target encoding.



Mime
View raw message