You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2011/06/12 19:10:43 UTC

svn commit: r1134946 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/ apollo-cli/ apollo-cli/src/main/scala/org/apache/activemq/apollo/...

Author: chirino
Date: Sun Jun 12 17:10:42 2011
New Revision: 1134946

URL: http://svn.apache.org/viewvc?rev=1134946&view=rev
Log:
Fixes https://issues.apache.org/jira/browse/APLO-40 : You can now edit all the apollo configuration files via the web interface.  Log configuration files are automatically reloaded when changed.

Removed:
    activemq/activemq-apollo/trunk/apollo-broker/src/test/scala/org/apache/activemq/apollo/broker/ConfigStoreTest.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloListener.scala
Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
    activemq/activemq-apollo/trunk/apollo-cli/pom.xml
    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/Run.scala
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreExport.scala
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreImport.scala
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileCache.scala

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala?rev=1134946&r1=1134945&r2=1134946&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala Sun Jun 12 17:10:42 2011
@@ -195,10 +195,10 @@ class Broker() extends BaseService {
   var web_server:WebServer = _
 
   var config_log:Log = Log(new MemoryLogger(Broker.log))
-  var audit_log:Log = _
-  var security_log:Log  = _
-  var connection_log:Log = _
-  var console_log:Log = _
+  var audit_log:Log = Broker.log
+  var security_log:Log  = Broker.log
+  var connection_log:Log = Broker.log
+  var console_log:Log = Broker.log
   var services = List[Service]()
 
   override def toString() = "broker: "+id

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala?rev=1134946&r1=1134945&r2=1134946&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala Sun Jun 12 17:10:42 2011
@@ -16,192 +16,44 @@
  */
 package org.apache.activemq.apollo.broker
 
-import org.apache.activemq.apollo.dto.{XmlCodec, BrokerDTO}
-import org.fusesource.hawtdispatch._
-import org.fusesource.hawtbuf.{ByteArrayInputStream, ByteArrayOutputStream}
+import org.fusesource.hawtbuf.ByteArrayInputStream
 import security.EncryptionSupport
-import XmlCodec._
 import org.apache.activemq.apollo.util._
-import java.util.Arrays
 import FileSupport._
 import java.util.Properties
-import java.io.{FileOutputStream, FileInputStream, File}
-import java.util.concurrent.{ThreadFactory, TimeUnit, ExecutorService, Executors}
-import org.springframework.core.style.DefaultToStringStyler
-
-object ConfigStore {
-
-  var store:ConfigStore = null
-
-  def apply():ConfigStore = store
-
-  def update(value:ConfigStore) = store=value
-
-}
-
-/**
- * <p>
- * Defines an interface to access and update persistent broker configurations.
- * </p>
- *
- * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
- */
-trait ConfigStore {
-
-  def read(): String
-  def write(value:String): Unit
-
-  def load(eval:Boolean): BrokerDTO
-
-  def store(config:BrokerDTO): Unit
-
-  def can_write:Boolean
-
-  def start:Unit
-
-  def stop:Unit
-
-  var on_update: (BrokerDTO)=>Unit = { dto => }
-
-}
-
-object FileConfigStore extends Log
+import java.io.{FileInputStream, File}
+import org.apache.activemq.apollo.dto.{XmlCodec, BrokerDTO}
 
 /**
  * <p>
- * A simple ConfigStore implementation which only support one broker configuration
- * stored in an XML file.
  * </p>
  *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-class FileConfigStore(var file:File = new File("activemq.xml")) extends ConfigStore {
-  import FileConfigStore._
-
-  case class StoredBrokerModel(data:Array[Byte], last_modified:Long)
-
-  file = file.getCanonicalFile
-
-  @volatile
-  var latest:StoredBrokerModel = null
-
-  @volatile
-  var running = false
-
-  val dispatch_queue = createQueue("config store")
-
-  def start = {
-    running = true
-    if( !file.exists ) {
-      try {
-        // try to create a default version of the file.
-        store((new Broker).config)
-      } catch {
-        case e:Throwable =>
-      }
-      if( !file.exists ) {
-        throw new Exception("The '%s' configuration file does not exist.".format(file.getPath))
-      }
-    }
-    latest = read(file)
-    schedual_next_update_check
-  }
-
-  def stop = {
-    running = false
-  }
-
-  def load(eval:Boolean) = {
-    unmarshall(read(file).data, eval)
-  }
-
-  def read() = {
-    new String(read(file).data)
-  }
-
-  def can_write:Boolean = file.canWrite
-
-  def store(config:BrokerDTO):Unit = {
-    val data = marshall(config)
-    latest = write(StoredBrokerModel(data, 0))
-  }
-
-  def write(value:String) = {
-    val m = StoredBrokerModel(value.getBytes, 0)
-    unmarshall(m.data)
-    latest = write(m)
-  }
-
-  private def schedual_next_update_check:Unit = dispatch_queue.after(1, TimeUnit.SECONDS) {
-    if( running ) {
-      val last_modified = latest.last_modified
-      val latestData = latest.data
-      Broker.BLOCKABLE_THREAD_POOL {
-        try {
-          val l = file.lastModified
-          if( l != last_modified ) {
-            val config = read(file)
-            if ( !Arrays.equals(latestData, config.data) ) {
-              on_update(unmarshall(config.data, true))
-            }
-            latest = config
-          }
-          schedual_next_update_check
-        }
-        catch {
-          case e:Exception =>
-          // error reading the file..  could be that someone is
-          // in the middle of updating the file.
-        }
-      }
-    }
-  }
+object ConfigStore {
 
-  private def read(file: File) ={
-    val data = IOHelper.readBytes(file)
-    val config = unmarshall(data) // validates the xml
-    StoredBrokerModel(data, file.lastModified)
+  def load(file:File) = {
+    XmlCodec.decode(classOf[BrokerDTO], new FileInputStream(file), config_properties(file))
   }
 
-  private  def write(config:StoredBrokerModel) = {
-
-    // backup the config file...
-    if(file.exists()) {
-      using(new FileInputStream(file)) { in =>
-        using(new FileOutputStream(file.getParentFile / ("~"+file.getName))) { out =>
-          copy(in, out)
-        }
-      }
-    }
-
-    IOHelper.writeBinaryFile(file, config.data)
-    config.copy(last_modified = file.lastModified)
+  def load_xml(in:Array[Byte]) = {
+    XmlCodec.decode(classOf[BrokerDTO], new ByteArrayInputStream(in), config_properties(null))
   }
 
-
-  def unmarshall(in:Array[Byte], evalProps:Boolean=false) = {
-    if (evalProps) {
-
-      val props = new Properties()
-      props.putAll(System.getProperties)
+  def config_properties(file:File): Properties = {
+    val props = new Properties()
+    props.putAll(System.getProperties)
+    if( file!=null ) {
       val prop_file = file.getParentFile / (file.getName + ".properties")
-      if( prop_file.exists() ) {
-        FileSupport.using(new FileInputStream(prop_file)) { is=>
-          val p = new Properties
-          p.load(new FileInputStream(prop_file))
-          props.putAll( EncryptionSupport.decrypt( p ))
+      if (prop_file.exists()) {
+        FileSupport.using(new FileInputStream(prop_file)) {
+          is =>
+            val p = new Properties
+            p.load(new FileInputStream(prop_file))
+            props.putAll(EncryptionSupport.decrypt(p))
         }
       }
-
-      decode(classOf[BrokerDTO], new ByteArrayInputStream(in), props)
-    } else {
-      decode(classOf[BrokerDTO], new ByteArrayInputStream(in))
     }
-  }
-
-  def marshall(in:BrokerDTO) = {
-    val baos = new ByteArrayOutputStream
-    encode(in, baos, true)
-    baos.toByteArray
+    props
   }
 }

Modified: activemq/activemq-apollo/trunk/apollo-cli/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/pom.xml?rev=1134946&r1=1134945&r2=1134946&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/pom.xml Sun Jun 12 17:10:42 2011
@@ -86,7 +86,13 @@
       <type>exe</type>
       <scope>test</scope>
     </dependency>
-    
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.16</version>
+    </dependency>
+
     <!-- Testing Dependencies -->
     <dependency>
       <groupId>org.scalatest</groupId>

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=1134946&r1=1134945&r2=1134946&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 Sun Jun 12 17:10:42 2011
@@ -24,7 +24,9 @@ import org.fusesource.jansi.Ansi
 import org.apache.activemq.apollo.util.FileSupport._
 import org.apache.felix.service.command.CommandSession
 import org.apache.felix.gogo.runtime.CommandProcessorImpl
-import java.io.{File, PrintStream, InputStream}
+import org.apache.activemq.apollo.util.FileSupport.RichFile._
+import java.util.logging.LogManager
+import java.io.{FileInputStream, File, PrintStream, InputStream}
 
 /**
  * <p>
@@ -34,6 +36,24 @@ import java.io.{File, PrintStream, Input
  */
 object Apollo {
   def main(args: Array[String]) = {
+
+    if( System.getProperty("java.util.logging.config.file") == null ) {
+      val home = System.getProperty("apollo.home")
+      var jul_config = new File(home) / "etc" / "jul.properties"
+
+      val base = System.getProperty("apollo.base")
+      if ( base !=null ) {
+        val file = new File(base) / "etc" / "jul.properties"
+        if  ( file.exists()  ) {
+          jul_config = file
+        }
+      }
+
+      using(new FileInputStream(jul_config)) { is =>
+        LogManager.getLogManager.readConfiguration(is)
+      }
+    }
+
     Ansi.ansi()
     new Apollo().run(args)
   }

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=1134946&r1=1134945&r2=1134946&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 Sun Jun 12 17:10:42 2011
@@ -17,25 +17,21 @@
 package org.apache.activemq.apollo.cli.commands
 
 import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument, Command => command}
-import java.io.File
-import org.apache.activemq.apollo.broker.{Broker, ConfigStore, FileConfigStore}
+import org.apache.activemq.apollo.broker.{Broker, ConfigStore}
 import org.apache.activemq.apollo.util.FileSupport._
 import org.apache.activemq.apollo.cli.Apollo
 import org.apache.felix.service.command.CommandSession
-import org.apache.activemq.apollo.util.ServiceControl
 import org.fusesource.hawtdispatch._
+import org.apache.activemq.apollo.util.{FileMonitor, ServiceControl}
+import org.apache.log4j.PropertyConfigurator
+import java.io.{FileInputStream, File}
+import java.util.logging.LogManager
 
 /**
  * The apollo run command
  */
 @command(scope="apollo", name = "run", description = "runs the broker instance")
 class Run extends Action {
-  
-  @option(name = "--conf", description = "The Apollo configuration file.")
-  var conf: File = _
-
-  @option(name = "--tmp", description = "A temp directory.")
-  var tmp: File = _
 
   def system_dir(name:String) = {
     val base_value = System.getProperty(name)
@@ -53,27 +49,28 @@ class Run extends Action {
 
     try {
 
+      val home = system_dir("apollo.home")
       val base = system_dir("apollo.base")
+      val etc: File = base / "etc"
 
-      if( conf == null ) {
-        conf = base / "etc" / "apollo.xml"
-      }
+      val log4j_config = etc / "log4j.properties"
+      PropertyConfigurator.configure(log4j_config.getCanonicalPath)
+
+      val conf = etc / "apollo.xml"
 
       if( !conf.exists ) {
         sys.error("Configuration file'%s' does not exist.\n\nTry creating a broker instance using the 'apollo create' command.".format(conf));
       }
 
       if( System.getProperty("java.security.auth.login.config")==null ) {
-        val login_config = conf.getParentFile / "login.config"
+        val login_config = etc / "login.config"
         if( login_config.exists ) {
           System.setProperty("java.security.auth.login.config", login_config.getCanonicalPath)
         }
       }
 
-      if( tmp == null ) {
-        tmp = base / "tmp"
-        tmp.mkdirs
-      }
+      val tmp = base / "tmp"
+      tmp.mkdirs
 
       Apollo.print_banner(session.getConsole)
 
@@ -81,26 +78,40 @@ class Run extends Action {
       session.getConsole.println("Loading configuration file '%s'.".format(conf))
 
       val broker = new Broker()
-      val store = new FileConfigStore
+      broker.config = ConfigStore.load(conf)
+      broker.tmp = tmp
+      broker.start()
 
-      ConfigStore() = store
-      store.file = conf
-      store.on_update = { config =>
-        broker.dispatch_queue {
-          broker.console_log.info("Reloading configuration file '%s'.".format(conf))
-          broker.update(config, ^{
-            broker.console_log.info("Reload completed.")
-          })
-        }
+      val broker_config_monitor = new FileMonitor(conf,broker.dispatch_queue {
+        broker.console_log.info("Reloading configuration file '%s'.".format(conf))
+        broker.update(ConfigStore.load(conf), ^{
+        })
+      })
+      val log4j_config_monitor = new FileMonitor(log4j_config, {
+        PropertyConfigurator.configure(log4j_config.getCanonicalPath)
+      })
+
+      var jul_config = etc / "jul.properties"
+      val jul_config_monitor = if ( jul_config.exists()) {
+        new FileMonitor(jul_config, {
+          broker.console_log.
+          using(new FileInputStream(jul_config)) { is =>
+            LogManager.getLogManager.readConfiguration(is)
+          }
+        })
+      } else {
+        null
       }
-      store.start
 
-      broker.config = store.load(true)
-      broker.tmp = tmp
-      broker.start()
+      if(jul_config_monitor!=null) jul_config_monitor.start
+      log4j_config_monitor.start
+      broker_config_monitor.start
 
       Runtime.getRuntime.addShutdownHook(new Thread(){
         override def run: Unit = {
+          if(jul_config_monitor!=null) ServiceControl.stop(jul_config_monitor, "stopping config monitor")
+          ServiceControl.stop(log4j_config_monitor, "stopping config monitor")
+          ServiceControl.stop(broker_config_monitor, "stopping config monitor")
           ServiceControl.stop(broker, "stopping broker")
         }
       })

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreExport.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreExport.scala?rev=1134946&r1=1134945&r2=1134946&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreExport.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreExport.scala Sun Jun 12 17:10:42 2011
@@ -18,7 +18,6 @@ package org.apache.activemq.apollo.cli.c
  */
 import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument, Command => command}
 import org.apache.activemq.apollo.util.FileSupport._
-import org.apache.activemq.apollo.broker.FileConfigStore
 import org.apache.activemq.apollo.dto.VirtualHostDTO
 import org.apache.activemq.apollo.util._
 import java.util.zip.{ZipEntry, ZipOutputStream}
@@ -26,6 +25,7 @@ import org.apache.activemq.apollo.broker
 import java.io.{OutputStream, FileOutputStream, File}
 import scala.util.continuations._
 import org.apache.felix.service.command.CommandSession
+import org.apache.activemq.apollo.broker.ConfigStore
 
 /**
  * The apollo stop command
@@ -59,7 +59,7 @@ class StoreExport extends Action {
         error("Configuration file'%s' does not exist.\n\nTry creating a broker instance using the 'apollo create' command.".format(conf));
       }
 
-      val config = new FileConfigStore(conf).load(true)
+      val config = ConfigStore.load(conf)
 
       val hosts = collection.JavaConversions.collectionAsScalaIterable(config.virtual_hosts).toArray
       val vho:Option[VirtualHostDTO] = if( host==null ) {

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreImport.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreImport.scala?rev=1134946&r1=1134945&r2=1134946&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreImport.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/StoreImport.scala Sun Jun 12 17:10:42 2011
@@ -18,14 +18,14 @@ package org.apache.activemq.apollo.cli.c
  */
 import org.apache.felix.gogo.commands.{Action, Option => option, Argument => argument, Command => command}
 import org.apache.activemq.apollo.util.FileSupport._
-import org.apache.activemq.apollo.broker.FileConfigStore
 import org.apache.activemq.apollo.dto.VirtualHostDTO
 import org.apache.activemq.apollo.util._
 import org.apache.activemq.apollo.broker.store.{StreamManager, StoreFactory}
 import scala.util.continuations._
-import java.util.zip.{ZipFile, ZipEntry, ZipOutputStream}
-import java.io.{InputStream, OutputStream, FileOutputStream, File}
+import java.util.zip.ZipFile
+import java.io.{InputStream, File}
 import org.apache.felix.service.command.CommandSession
+import org.apache.activemq.apollo.broker.ConfigStore
 
 
 /**
@@ -60,7 +60,7 @@ class StoreImport extends Action {
         error("Configuration file'%s' does not exist.\n\nTry creating a broker instance using the 'apollo create' command.".format(conf));
       }
 
-      val config = new FileConfigStore(conf).load(true)
+      val config = ConfigStore.load(conf)
 
       val hosts = collection.JavaConversions.collectionAsScalaIterable(config.virtual_hosts).toArray
       val vho:Option[VirtualHostDTO] = if( host==null ) {

Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo?rev=1134946&r1=1134945&r2=1134946&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo Sun Jun 12 17:10:42 2011
@@ -102,17 +102,12 @@ if [ ! -x "$JAVACMD" ] ; then
 fi
 
 CLASSPATH="${APOLLO_HOME}/lib/apollo-boot.jar"
-if [ ! -z "$APOLLO_BASE" ] ; then
-  CLASSPATH="${APOLLO_BASE}/etc:${CLASSPATH}"
-fi
 
 BOOTDIRS="${APOLLO_HOME}/lib"
 if [ ! -z "$APOLLO_BASE" ] ; then
   BOOTDIRS="${APOLLO_BASE}/lib:${BOOTDIRS}"
 fi
 
-JUL_CONFIG_FILE="${APOLLO_HOME}/etc/jul.properties"
-
 # For Cygwin, switch paths to Windows format before running java
 if $cygwin; then
   APOLLO_HOME=`cygpath --windows "$APOLLO_HOME"`
@@ -122,7 +117,6 @@ if $cygwin; then
   JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
   CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
   CYGHOME=`cygpath --windows "$HOME"`
-  JUL_CONFIG_FILE=`cygpath --windows "$JUL_CONFIG_FILE"`
 fi
 
 JVM_FLAGS="${JVM_FLAGS--server -Xmx1G}"
@@ -143,7 +137,6 @@ fi
 
 JVM_FLAGS="${JVM_FLAGS} ${JMX_OPTS--Dcom.sun.management.jmxremote}"
 
-SYSTEM_PROPS="-Djava.util.logging.config.file=${JUL_CONFIG_FILE}"
 SYSTEM_PROPS="${SYSTEM_PROPS} -Dapollo.home=${APOLLO_HOME}"
 if [ ! -z "$APOLLO_BASE" ] ; then
   SYSTEM_PROPS="${SYSTEM_PROPS} -Dapollo.base=${APOLLO_BASE}"

Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd?rev=1134946&r1=1134945&r2=1134946&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/bin/apollo.cmd Sun Jun 12 17:10:42 2011
@@ -48,7 +48,6 @@ echo.
 :RUN_JAVA
 
 set CLASSPATH=%APOLLO_HOME%\lib\apollo-boot.jar
-if NOT "x%APOLLO_BASE%" == "x" set CLASSPATH=%APOLLO_BASE%\etc;%CLASSPATH%
 
 set BOOTDIRS=%APOLLO_HOME%\lib
 if NOT "x%APOLLO_BASE%" == "x" set BOOTDIRS=%APOLLO_BASE%\lib:%BOOTDIRS%
@@ -71,12 +70,8 @@ if "%JMX_OPTS%" == "" set JMX_OPTS=-Dcom
 rem set JMX_OPTS=-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
 set JVM_FLAGS=%JVM_FLAGS% %JMX_OPTS%
 
-set JUL_CONFIG_FILE=%APOLLO_HOME%\etc\jul.properties
-
-
 set JVM_FLAGS=%JVM_FLAGS% -Dapollo.home="%APOLLO_HOME%"
 if NOT "x%APOLLO_BASE%" == "x" set JVM_FLAGS=%JVM_FLAGS% -Dapollo.base="%APOLLO_BASE%"
-set JVM_FLAGS=%JVM_FLAGS% -Djava.util.logging.config.file="%JUL_CONFIG_FILE%"
 set JVM_FLAGS=%JVM_FLAGS% -classpath "%CLASSPATH%"
 
 "%_JAVACMD%" %JVM_FLAGS% org.apache.activemq.apollo.boot.Boot "%BOOTDIRS%" org.apache.activemq.apollo.cli.Apollo %*

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileCache.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileCache.scala?rev=1134946&r1=1134945&r2=1134946&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileCache.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/FileCache.scala Sun Jun 12 17:10:42 2011
@@ -21,7 +21,57 @@ import java.lang.Long
 import org.fusesource.hawtdispatch._
 import scala.Some
 import java.util.concurrent.{TimeUnit, ConcurrentHashMap}
+import java.util.Arrays
+import org.apache.activemq.apollo.util.FileSupport._
 
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+class FileMonitor(file:File, change_listener: =>Unit) extends BaseService {
+
+  val dispatch_queue = createQueue("monitor: "+file)
+
+  var last_data = Array[Byte]()
+  var last_modified = 0L
+  var state_ver = 0
+
+  protected def _stop(on_completed: Runnable) = {
+    state_ver+=1
+  }
+
+  protected def _start(on_completed: Runnable) = {
+    last_data = file.read_bytes
+    last_modified = file.lastModified()
+    state_ver+=1
+    update_check(state_ver)
+  }
+
+  private def update_check(ver:Int):Unit = {
+    if( ver == state_ver ) {
+      try {
+        val modified = file.lastModified
+        if( modified != last_modified ) {
+          val new_data = file.read_bytes
+          if ( !Arrays.equals(last_data, new_data) ) {
+            change_listener
+          }
+          last_modified = modified
+          last_data = new_data
+        }
+      } catch {
+        case e:Exception =>
+        // error reading the file..  could be that someone is
+        // in the middle of updating the file.
+      }
+      dispatch_queue.after(1, TimeUnit.SECONDS) {
+        update_check(ver)
+      }
+    }
+  }
+}
 
 /**
  * <p>