activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1080035 - in /activemq/activemq-apollo/trunk: apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/ apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/ apollo-broker/src/main/scala/org/apache/activemq/ap...
Date Wed, 09 Mar 2011 22:23:01 GMT
Author: chirino
Date: Wed Mar  9 22:22:59 2011
New Revision: 1080035

URL: http://svn.apache.org/viewvc?rev=1080035&view=rev
Log:
Making it easier to configure segregated console, connection, security, and audit related log messages.

Added:
    activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/LogCategoryDTO.java
      - copied, changed from r1079030, activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreBenchmark.scala
Modified:
    activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStore.scala
    activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreFactory.scala
    activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreBenchmark.scala
    activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreTest.scala
    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/Connection.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/AclAuthorizer.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/CertificateLoginModule.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileGroupLoginModule.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileUserLoginModule.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/GuestLoginModule.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/JaasAuthenticator.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/SecurityContext.scala
    activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStore.scala
    activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreFactory.scala
    activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreTest.scala
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml
    activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties
    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-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java
    activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java
    activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStore.scala
    activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreFactory.scala
    activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreBenchmark.scala
    activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreTest.scala
    activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2Store.scala
    activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreFactory.scala
    activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreBenchmark.scala
    activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreTest.scala
    activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/LoggingTracker.scala

Modified: activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStore.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStore.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStore.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStore.scala Wed Mar  9 22:22:59 2011
@@ -37,15 +37,6 @@ object BDBStore extends Log {
   val DATABASE_LOCKED_WAIT_DELAY = 10 * 1000;
 
   /**
-   * Creates a default a configuration object.
-   */
-  def defaultConfig() = {
-    val rc = new BDBStoreDTO
-    rc.directory = new File("activemq-data")
-    rc
-  }
-
-  /**
    * Validates a configuration object.
    */
   def validate(config: BDBStoreDTO, reporter:Reporter):ReporterLevel = {
@@ -60,7 +51,7 @@ object BDBStore extends Log {
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-class BDBStore extends DelayingStoreSupport {
+class BDBStore(var config:BDBStoreDTO) extends DelayingStoreSupport {
 
   import BDBStore._
 
@@ -69,10 +60,9 @@ class BDBStore extends DelayingStoreSupp
 
   var write_executor:ExecutorService = _
   var read_executor:ExecutorService = _
-  var config:BDBStoreDTO = defaultConfig
   val client = new BDBClient(this)
 
-  override def toString = "bdb store"
+  override def toString = "bdb store at "+config.directory
 
   def flush_delay = config.flush_delay.getOrElse(100)
   
@@ -104,7 +94,6 @@ class BDBStore extends DelayingStoreSupp
   }
 
   protected def _start(on_completed: Runnable) = {
-    info("Starting bdb store at: '%s'", config.directory)
     write_executor = Executors.newFixedThreadPool(1, new ThreadFactory(){
       def newThread(r: Runnable) = {
         val rc = new Thread(r, "bdb store io write")
@@ -132,7 +121,6 @@ class BDBStore extends DelayingStoreSupp
   protected def _stop(on_completed: Runnable) = {
     new Thread() {
       override def run = {
-        info("Stopping BDB store at: '%s'", config.directory)
         write_executor.shutdown
         write_executor.awaitTermination(60, TimeUnit.SECONDS)
         write_executor = null

Modified: activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreFactory.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreFactory.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreFactory.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-bdb/src/main/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreFactory.scala Wed Mar  9 22:22:59 2011
@@ -37,18 +37,20 @@ import ReporterLevel._
 class BDBStoreFactory extends StoreFactory.Provider {
 
   def create(config: StoreDTO) = {
-    if( config.isInstanceOf[BDBStoreDTO]) {
-      new BDBStore
-    } else {
-      null
+    config match {
+      case config:BDBStoreDTO =>
+        new BDBStore(config)
+      case _ =>
+        null
     }
   }
 
    def validate(config: StoreDTO, reporter:Reporter):ReporterLevel = {
-     if( config.isInstanceOf[BDBStoreDTO]) {
-       BDBStore.validate(config.asInstanceOf[BDBStoreDTO], reporter)
-     } else {
-       null
+     config match {
+       case config:BDBStoreDTO =>
+         BDBStore.validate(config, reporter)
+       case _ =>
+         null
      }
    }
 }

Modified: activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreBenchmark.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreBenchmark.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreBenchmark.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreBenchmark.scala Wed Mar  9 22:22:59 2011
@@ -16,9 +16,10 @@
  */
 package org.apache.activemq.apollo.broker.store.bdb
 
+import dto.BDBStoreDTO
 import org.apache.activemq.apollo.broker.store.StoreBenchmarkSupport
 import org.apache.activemq.apollo.broker.store.Store
-
+import org.apache.activemq.apollo.util.FileSupport._
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@@ -26,7 +27,11 @@ import org.apache.activemq.apollo.broker
 class BDBStoreBenchmark extends StoreBenchmarkSupport {
 
   def create_store(flushDelay:Long):Store = {
-    val rc = new BDBStore
+    val rc = new BDBStore({
+      val rc = new BDBStoreDTO
+      rc.directory = basedir / "activemq-data"
+      rc
+    })
     rc.config.flush_delay = flushDelay
     rc
   }

Modified: activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreTest.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreTest.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/BDBStoreTest.scala Wed Mar  9 22:22:59 2011
@@ -16,7 +16,9 @@
  */
 package org.apache.activemq.apollo.broker.store.bdb
 
+import dto.BDBStoreDTO
 import org.apache.activemq.apollo.broker.store.{Store, StoreFunSuiteSupport}
+import org.apache.activemq.apollo.util.FileSupport._
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@@ -24,7 +26,11 @@ import org.apache.activemq.apollo.broker
 class BDBStoreTest extends StoreFunSuiteSupport {
 
   def create_store(flushDelay:Long):Store = {
-    val rc = new BDBStore
+    val rc = new BDBStore({
+      val rc = new BDBStoreDTO
+      rc.directory = basedir / "activemq-data"
+      rc
+    })
     rc.config.flush_delay = flushDelay
     rc
   }

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=1080035&r1=1080034&r2=1080035&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 Wed Mar  9 22:22:59 2011
@@ -23,7 +23,6 @@ import org.fusesource.hawtbuf._
 import AsciiBuffer._
 import collection.JavaConversions
 import JavaConversions._
-import org.apache.activemq.apollo.dto.BrokerDTO
 import java.util.concurrent.atomic.AtomicLong
 import org.apache.activemq.apollo.util._
 import ReporterLevel._
@@ -33,6 +32,7 @@ import org.apache.activemq.apollo.broker
 import collection.mutable.{HashSet, LinkedHashMap}
 import scala.util.Random
 import FileSupport._
+import org.apache.activemq.apollo.dto.{LogCategoryDTO, BrokerDTO}
 
 /**
  * <p>
@@ -216,6 +216,11 @@ class Broker() extends BaseService {
 
   var web_server:WebServer = _
 
+  var audit_log:Log = _
+  var security_log:Log  = _
+  var connection_log:Log = _
+  var console_log:Log = _
+
   override def toString() = "broker: "+id
 
 
@@ -251,18 +256,26 @@ class Broker() extends BaseService {
 
     // create the runtime objects from the config
     {
+      import OptionSupport._
       init_dispatch_queue(dispatch_queue)
 
+      // Configure the logging categories...
+      val log_category = config.log_category.getOrElse(new LogCategoryDTO)
+      val base_category = "org.apache.activemq.apollo.log."
+      security_log = Log(log_category.security.getOrElse(base_category+"security"))
+      audit_log = Log(log_category.audit.getOrElse(base_category+"audit"))
+      connection_log = Log(log_category.connection.getOrElse(base_category+"connection"))
+      console_log = Log(log_category.console.getOrElse(base_category+"console"))
+
       if( config.key_storage!=null ) {
         key_storage = new KeyStorage
         key_storage.config = config.key_storage
       }
 
 
-      import OptionSupport._
       if( config.authentication != null && config.authentication.enabled.getOrElse(true) ) {
-        authenticator = new JaasAuthenticator(config.authentication)
-        authorizer = new AclAuthorizer(config.authentication.acl_principal_kinds().toList)
+        authenticator = new JaasAuthenticator(config.authentication, security_log)
+        authorizer = new AclAuthorizer(config.authentication.acl_principal_kinds().toList, security_log)
       }
 
       default_virtual_host = null
@@ -280,18 +293,20 @@ class Broker() extends BaseService {
           virtual_hosts_by_hostname += ascii(name)->host
         }
       }
+
       for (c <- config.connectors) {
         val connector = new AcceptingConnector(this, c.id)
         connector.configure(c, LoggingReporter(VirtualHost))
         connectors ::= connector
       }
+
     }
 
     BrokerRegistry.add(this)
 
     // Start up the virtual hosts
-    val first_tracker = new LoggingTracker("broker startup", dispatch_queue)
-    val second_tracker = new LoggingTracker("broker startup", dispatch_queue)
+    val first_tracker = new LoggingTracker("broker startup", console_log, dispatch_queue)
+    val second_tracker = new LoggingTracker("broker startup", console_log, dispatch_queue)
 
     Option(config.web_admin).foreach{ web_admin=>
       WebServerFactory.create(this) match {
@@ -319,7 +334,7 @@ class Broker() extends BaseService {
 
 
   def _stop(on_completed:Runnable): Unit = {
-    val tracker = new LoggingTracker("broker shutdown", dispatch_queue)
+    val tracker = new LoggingTracker("broker shutdown", console_log, dispatch_queue)
 
     // Stop accepting connections..
     connectors.foreach( x=>

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connection.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connection.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connection.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connection.scala Wed Mar  9 22:22:59 2011
@@ -99,13 +99,13 @@ class BrokerConnection(var connector: Co
   override def toString = "id: "+id.toString
 
   protected override  def _start(on_completed:Runnable) = {
-    info("Client connected from: %s", transport.getRemoteAddress)
+    connector.broker.connection_log.info("Client connected from: %s", transport.getRemoteAddress)
     protocol_handler.set_connection(this);
     super._start(on_completed)
   }
 
   protected override def _stop(on_completed:Runnable) = {
-    info("Client disconnected from: %s", transport.getRemoteAddress)
+    connector.broker.connection_log.info("Client disconnected from: %s", transport.getRemoteAddress)
     connector.stopped(this)
     super._stop(on_completed)
   }

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Connector.scala Wed Mar  9 22:22:59 2011
@@ -120,8 +120,9 @@ class AcceptingConnector(val broker:Brok
         }
       }
 
-      // We may need to stop acepting connections..
       if(at_connection_limit) {
+        // We stop accepting connections at this point.
+        info("Connection limit reached. Clients connected: %d", connections.size)
         transport_server.suspend
       }
     }
@@ -163,7 +164,7 @@ class AcceptingConnector(val broker:Brok
       }
     }
     transport_server.start(^{
-      info("Accepting connections at: "+config.bind)
+      broker.console_log.info("Accepting connections at: "+config.bind)
       on_completed.run
     })
   }
@@ -171,8 +172,8 @@ class AcceptingConnector(val broker:Brok
 
   override def _stop(on_completed:Runnable): Unit = {
     transport_server.stop(^{
-      info("Stopped connector at: "+config.bind)
-      val tracker = new LoggingTracker(toString, dispatch_queue)
+      broker.console_log.info("Stopped connector at: "+config.bind)
+      val tracker = new LoggingTracker(toString, broker.console_log, dispatch_queue)
       connections.valuesIterator.foreach { connection=>
         tracker.stop(connection)
       }

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala Wed Mar  9 22:22:59 2011
@@ -423,7 +423,7 @@ class LocalRouter(val host:VirtualHost) 
   /////////////////////////////////////////////////////////////////////////////
 
   protected def _start(on_completed: Runnable) = {
-    val tracker = new LoggingTracker("router startup", dispatch_queue)
+    val tracker = new LoggingTracker("router startup", host.console_log, dispatch_queue)
     if( host.store!=null ) {
       val task = tracker.task("list_queues")
       host.store.list_queues { queue_keys =>
@@ -462,7 +462,7 @@ class LocalRouter(val host:VirtualHost) 
   }
 
   protected def _stop(on_completed: Runnable) = {
-    val tracker = new LoggingTracker("router shutdown", dispatch_queue)
+    val tracker = new LoggingTracker("router shutdown", host.console_log, dispatch_queue)
     queues_by_id.valuesIterator.foreach { queue=>
       tracker.stop(queue)
     }

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala Wed Mar  9 22:22:59 2011
@@ -30,9 +30,9 @@ import collection.JavaConversions
 import java.util.concurrent.atomic.AtomicLong
 import org.apache.activemq.apollo.util.OptionSupport._
 import org.apache.activemq.apollo.util.path.{Path, PathParser}
-import org.apache.activemq.apollo.dto.{TopicDTO, QueueDTO, DestinationDTO, VirtualHostDTO}
 import security.{AclAuthorizer, JaasAuthenticator, Authenticator, Authorizer}
 import org.apache.activemq.apollo.broker.store.{ZeroCopyBufferAllocator, Store, StoreFactory}
+import org.apache.activemq.apollo.dto._
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@@ -88,6 +88,11 @@ class VirtualHost(val broker: Broker, va
   var authenticator:Authenticator = _
   var authorizer:Authorizer = _
 
+  var audit_log:Log = _
+  var security_log:Log  = _
+  var connection_log:Log = _
+  var console_log:Log = _
+
   override def toString = if (config==null) "virtual-host" else "virtual-host: "+config.id
 
   /**
@@ -107,13 +112,20 @@ class VirtualHost(val broker: Broker, va
 
   override protected def _start(on_completed:Runnable):Unit = {
 
-    val tracker = new LoggingTracker("virtual host startup", dispatch_queue)
+    // Configure the logging categories...
+    val log_category = config.log_category.getOrElse(new LogCategoryDTO)
+    security_log = Option(log_category.security).map(Log(_)).getOrElse(broker.security_log)
+    audit_log = Option(log_category.audit).map(Log(_)).getOrElse(broker.audit_log)
+    connection_log = Option(log_category.connection).map(Log(_)).getOrElse(broker.connection_log)
+    console_log = Option(log_category.console).map(Log(_)).getOrElse(broker.console_log)
+
+    val tracker = new LoggingTracker("virtual host startup", console_log, dispatch_queue)
 
     if( config.authentication != null ) {
       if( config.authentication.enabled.getOrElse(true) ) {
         // Virtual host has it's own settings.
-        authenticator = new JaasAuthenticator(config.authentication)
-        authorizer = new AclAuthorizer(config.authentication.acl_principal_kinds().toList)
+        authenticator = new JaasAuthenticator(config.authentication, security_log)
+        authorizer = new AclAuthorizer(config.authentication.acl_principal_kinds().toList, security_log)
       } else {
         // Don't use security on this host.
         authenticator = null
@@ -129,8 +141,8 @@ class VirtualHost(val broker: Broker, va
     store = StoreFactory.create(config.store)
 
     if( store!=null ) {
-      store.configure(config.store, LoggingReporter(VirtualHost))
       val task = tracker.task("store startup")
+      console_log.info("Starting store: "+store)
       store.start {
         {
           val task = tracker.task("store get last queue key")
@@ -151,12 +163,13 @@ class VirtualHost(val broker: Broker, va
             }
           }
         }
+        console_log.info("Store started")
         task.run
       }
     }
 
     tracker.callback {
-      val tracker = new LoggingTracker("virtual host startup", dispatch_queue)
+      val tracker = new LoggingTracker("virtual host startup", console_log, dispatch_queue)
       tracker.start(router)
       tracker.callback(on_completed)
     }
@@ -166,7 +179,7 @@ class VirtualHost(val broker: Broker, va
 
   override protected def _stop(on_completed:Runnable):Unit = {
 
-    val tracker = new LoggingTracker("virtual host shutdown", dispatch_queue)
+    val tracker = new LoggingTracker("virtual host shutdown", console_log, dispatch_queue)
     tracker.stop(router);
     if( store!=null ) {
       tracker.stop(store);

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/JettyWebServer.scala Wed Mar  9 22:22:59 2011
@@ -211,7 +211,7 @@ class JettyWebServer(val broker:Broker) 
 
       val localPort = connector.getLocalPort
       def url = "http://"+host+":" + localPort + prefix
-      info("Administration interface available at: "+url)
+      broker.console_log.info("Administration interface available at: "+url)
       on_completed.run
     }
   }

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/AclAuthorizer.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/AclAuthorizer.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/AclAuthorizer.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/AclAuthorizer.scala Wed Mar  9 22:22:59 2011
@@ -20,8 +20,6 @@ import org.apache.activemq.apollo.broker
 import org.apache.activemq.apollo.dto._
 import org.apache.activemq.apollo.util.Log
 
-object AclAuthorizer extends Log
-
 /**
  * <p>
  * Authorizes based on the acl configuration found in
@@ -30,30 +28,31 @@ object AclAuthorizer extends Log
  *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-class AclAuthorizer(val default_kinds:List[String]) extends Authorizer {
+class AclAuthorizer(val default_kinds:List[String], val log:Log) extends Authorizer {
+
   import collection.JavaConversions._
-  import AclAuthorizer._
+  import log._
 
   def is_in(ctx: SecurityContext, allowed:java.util.List[PrincipalDTO]):Boolean = {
     ctx.is_allowed(allowed.toList, default_kinds)
   }
 
-  def log_on_failure(ctx: SecurityContext, action: String, resource: =>String)(func: =>Boolean):Boolean = {
+  def log_result(ctx: SecurityContext, action: String, resource: =>String)(func: =>Boolean):Boolean = {
     val rc = func
     if( !rc ) {
-      debug("Authorization failed: '%s' does not have %s access on %s", ctx.user, action, resource)
+      info("authorization failed: action:%s, resource:%s, address: %s, principles: %s", action, resource, ctx.remote_address, ctx.principles.map(_.allow).mkString(",  ") )
     }
     rc
   }
 
-  def can_admin(ctx: SecurityContext, broker: Broker) = log_on_failure(ctx, "administration", "broker") {
+  def can_admin(ctx: SecurityContext, broker: Broker) = log_result(ctx, "administration", "broker") {
     broker.config.acl==null  || is_in(ctx, broker.config.acl.admins)
   }
 
   def can_connect_to(ctx: SecurityContext, host: VirtualHost, connector:Connector):Boolean = {
-    log_on_failure(ctx, "connect", "host "+host.names) {
+    log_result(ctx, "connect", "host "+host.names) {
       host.config.acl==null || is_in(ctx, host.config.acl.connects)
-    } && log_on_failure(ctx, "connect", "connector "+connector.config.id) {
+    } && log_result(ctx, "connect", "connector "+connector.config.id) {
       connector.config.acl==null || is_in(ctx, connector.config.acl.connects)
     }
   }
@@ -62,16 +61,19 @@ class AclAuthorizer(val default_kinds:Li
     dest.acl==null || is_in(ctx, func(dest.acl))
   }
 
-  def can_send_to(ctx: SecurityContext, host: VirtualHost, dest: TopicDTO) = log_on_failure(ctx, "send to", "topic "+dest.name) {
+
+  def name(dest: TopicDTO) = Option(dest.name).getOrElse("**")
+
+  def can_send_to(ctx: SecurityContext, host: VirtualHost, dest: TopicDTO) = log_result(ctx, "send", "topic "+name(dest)) {
     can_dest(ctx, host, dest)(_.sends)
   }
-  def can_receive_from(ctx: SecurityContext, host: VirtualHost, dest: TopicDTO) = log_on_failure(ctx, "receive from", "topic "+dest.name) {
+  def can_receive_from(ctx: SecurityContext, host: VirtualHost, dest: TopicDTO) = log_result(ctx, "receive", "topic "+name(dest)) {
     can_dest(ctx, host, dest)(_.receives)
   }
-  def can_destroy(ctx: SecurityContext, host: VirtualHost, dest: TopicDTO) = log_on_failure(ctx, "destroy", "topic "+dest.name) {
+  def can_destroy(ctx: SecurityContext, host: VirtualHost, dest: TopicDTO) = log_result(ctx, "destroy", "topic "+name(dest)) {
     can_dest(ctx, host, dest)(_.destroys)
   }
-  def can_create(ctx: SecurityContext, host: VirtualHost, dest: TopicDTO) = log_on_failure(ctx, "create", "topic "+dest.name) {
+  def can_create(ctx: SecurityContext, host: VirtualHost, dest: TopicDTO) = log_result(ctx, "create", "topic "+name(dest)) {
     can_dest(ctx, host, dest)(_.creates)
   }
 
@@ -79,23 +81,25 @@ class AclAuthorizer(val default_kinds:Li
     queue.acl==null || is_in(ctx, func(queue.acl))
   }
 
-  def can_send_to(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_on_failure(ctx, "send to", "queue "+queue.name) {
+  def name(dest: QueueDTO) = Option(dest.name).getOrElse("**")
+
+  def can_send_to(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_result(ctx, "send", "queue "+name(queue)) {
     can_queue(ctx, host, queue)(_.sends)
   }
 
-  def can_receive_from(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_on_failure(ctx, "receive from", "queue "+queue.name) {
+  def can_receive_from(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_result(ctx, "receive", "queue "+name(queue)) {
     can_queue(ctx, host, queue)(_.receives)
   }
 
-  def can_destroy(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_on_failure(ctx, "destroy", "queue "+queue.name) {
+  def can_destroy(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_result(ctx, "destroy", "queue "+name(queue)) {
     can_queue(ctx, host, queue)(_.destroys)
   }
 
-  def can_create(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_on_failure(ctx, "create", "queue "+queue.name) {
+  def can_create(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_result(ctx, "create", "queue "+name(queue)) {
     can_queue(ctx, host, queue)(_.creates)
   }
 
-  def can_consume_from(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_on_failure(ctx, "consume from", "queue "+queue.name) {
+  def can_consume_from(ctx: SecurityContext, host: VirtualHost, queue: QueueDTO) = log_result(ctx, "consume", "queue "+name(queue)) {
     can_queue(ctx, host, queue)(_.consumes)
   }
 

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/CertificateLoginModule.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/CertificateLoginModule.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/CertificateLoginModule.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/CertificateLoginModule.scala Wed Mar  9 22:22:59 2011
@@ -38,9 +38,10 @@ import java.util.LinkedList
  *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-object CertificateLoginModule extends Log {
+object CertificateLoginModule {
   val LOGIN_CONFIG = "java.security.auth.login.config"
   val FILE_OPTION = "dn_file"
+  val DEFAULT_LOG = Log(getClass)
 }
 
 /**
@@ -53,6 +54,9 @@ class CertificateLoginModule {
 
   import CertificateLoginModule._
 
+  val log = JaasAuthenticator.broker_log.getOrElse(DEFAULT_LOG)
+  import log._
+
   var callback_handler: CallbackHandler = _
   var subject: Subject = _
 

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileGroupLoginModule.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileGroupLoginModule.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileGroupLoginModule.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileGroupLoginModule.scala Wed Mar  9 22:22:59 2011
@@ -48,11 +48,12 @@ import FileSupport._
 import java.util.regex.Pattern
 import java.util.{LinkedList, Properties}
 
-object FileGroupLoginModule extends Log {
+object FileGroupLoginModule {
   val LOGIN_CONFIG = "java.security.auth.login.config"
   val FILE_OPTION = "file"
   val MATCH_OPTION = "match"
   val SEPARATOR_OPTION = "separator"
+  val DEFAULT_LOG = Log(getClass)
 }
 
 /**
@@ -67,6 +68,8 @@ object FileGroupLoginModule extends Log 
 class FileGroupLoginModule extends LoginModule {
 
   import FileGroupLoginModule._
+  val log = JaasAuthenticator.broker_log.getOrElse(DEFAULT_LOG)
+  import log._
 
   private var separator: String = _
   private var match_kind: String = _

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileUserLoginModule.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileUserLoginModule.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileUserLoginModule.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/FileUserLoginModule.scala Wed Mar  9 22:22:59 2011
@@ -37,9 +37,10 @@ import java.{util => ju}
 import org.apache.activemq.apollo.util.{FileSupport, Log}
 import FileSupport._
 
-object FileUserLoginModule extends Log {
+object FileUserLoginModule {
   val LOGIN_CONFIG = "java.security.auth.login.config"
   val FILE_OPTION = "file"
+  val DEFAULT_LOG = Log(getClass)
 }
 
 /**
@@ -53,6 +54,8 @@ object FileUserLoginModule extends Log {
 class FileUserLoginModule extends LoginModule {
 
   import FileUserLoginModule._
+  val log = JaasAuthenticator.broker_log.getOrElse(DEFAULT_LOG)
+  import log._
 
   private var subject: Subject = _
   private var callback_handler: CallbackHandler = _

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/GuestLoginModule.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/GuestLoginModule.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/GuestLoginModule.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/GuestLoginModule.scala Wed Mar  9 22:22:59 2011
@@ -31,9 +31,10 @@ import java.{util => ju}
 import org.apache.activemq.apollo.util.Log
 import org.apache.activemq.jaas.{GroupPrincipal, UserPrincipal}
 
-object GuestLoginModule extends Log {
+object GuestLoginModule {
   val USER_OPTION = "user"
   val GROUP_OPTION = "group"
+  val DEFAULT_LOG = Log(getClass)
 }
 
 /**
@@ -48,6 +49,8 @@ object GuestLoginModule extends Log {
 class GuestLoginModule extends LoginModule {
 
   import GuestLoginModule._
+  val log = JaasAuthenticator.broker_log.getOrElse(DEFAULT_LOG)
+  import log._
 
   private var subject: Subject = _
   private var callback_handler: CallbackHandler = _

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/JaasAuthenticator.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/JaasAuthenticator.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/JaasAuthenticator.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/JaasAuthenticator.scala Wed Mar  9 22:22:59 2011
@@ -25,10 +25,11 @@ import javax.security.auth.callback.Pass
 import javax.security.auth.callback.UnsupportedCallbackException
 
 import org.apache.activemq.jaas._
-import org.apache.activemq.apollo.util.OptionSupport._
 import org.apache.activemq.apollo.broker.Broker.BLOCKABLE_THREAD_POOL
 import org.fusesource.hawtdispatch._
 import org.apache.activemq.apollo.dto.{PrincipalDTO, AuthenticationDTO}
+import org.apache.activemq.apollo.util.Log
+import collection.JavaConversions._
 
 /**
  * <p>
@@ -36,10 +37,23 @@ import org.apache.activemq.apollo.dto.{P
  *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
+object JaasAuthenticator extends Log {
 
-class JaasAuthenticator(val config: AuthenticationDTO) extends Authenticator {
+  val _log = new ThreadLocal[Log]()
+  def broker_log = Option(_log.get())
 
-  val jass_realm = config.domain.getOrElse("apollo")
+}
+
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+class JaasAuthenticator(val config: AuthenticationDTO, val log:Log) extends Authenticator {
+
+  val jass_realm = Option(config.domain).getOrElse("apollo")
   val user_principal_kinds = config.user_principal_kinds()
 
   /*
@@ -66,6 +80,7 @@ class JaasAuthenticator(val config: Auth
   def _authenticate(security_ctx: SecurityContext): Boolean = {
     val original = Thread.currentThread().getContextClassLoader()
     Thread.currentThread().setContextClassLoader(getClass.getClassLoader())
+    JaasAuthenticator._log.set(log)
     try {
 
       security_ctx.login_context = new LoginContext(jass_realm, new CallbackHandler {
@@ -74,7 +89,7 @@ class JaasAuthenticator(val config: Auth
             callback =>
               callback match {
                 case x: NameCallback => x.setName(security_ctx.user)
-                case x: PasswordCallback => x.setPassword(security_ctx.password.getOrElse("").toCharArray)
+                case x: PasswordCallback => x.setPassword(Option(security_ctx.password).getOrElse("").toCharArray)
                 case x: CertificateCallback => x.setCertificates(security_ctx.certificates)
                 case _ => throw new UnsupportedCallbackException(callback)
               }
@@ -87,8 +102,10 @@ class JaasAuthenticator(val config: Auth
       true
     } catch {
       case x: Exception =>
+        log.info("authentication failed. address:%s, reason:%s ", security_ctx.remote_address, x.getMessage)
         false
     } finally {
+      JaasAuthenticator._log.remove
       Thread.currentThread().setContextClassLoader(original)
     }
   }

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/SecurityContext.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/SecurityContext.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/SecurityContext.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/SecurityContext.scala Wed Mar  9 22:22:59 2011
@@ -36,11 +36,11 @@ class SecurityContext {
   var user:String = _
   var password:String = _
   var certificates = Array[X509Certificate]()
+  var remote_address:String = _
 
   var login_context:LoginContext = _
 
   private var _principles = Set[PrincipalDTO]()
-
   private var _subject:Subject = _
 
   def subject = _subject

Modified: activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStore.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStore.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStore.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStore.scala Wed Mar  9 22:22:59 2011
@@ -38,15 +38,6 @@ import scala.util.continuations._
 object CassandraStore extends Log {
 
   /**
-   * Creates a default a configuration object.
-   */
-  def defaultConfig() = {
-    val rc = new CassandraStoreDTO
-    rc.hosts.add("localhost:9160")
-    rc
-  }
-
-  /**
    * Validates a configuration object.
    */
   def validate(config: CassandraStoreDTO, reporter:Reporter):ReporterLevel = {
@@ -61,7 +52,7 @@ object CassandraStore extends Log {
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-class CassandraStore extends DelayingStoreSupport with Logging {
+class CassandraStore(var config:CassandraStoreDTO) extends DelayingStoreSupport with Logging {
 
   import CassandraStore._
   override protected def log = CassandraStore
@@ -69,12 +60,11 @@ class CassandraStore extends DelayingSto
   var next_msg_key = new AtomicLong(1)
 
   val client = new CassandraClient()
-  var config:CassandraStoreDTO = defaultConfig
   var blocking:ExecutorService = null
 
   def flush_delay = config.flush_delay.getOrElse(100)
 
-  override def toString = "cassandra store"
+  override def toString = "cassandra store at "+config.hosts.toList.mkString(", ")
 
   protected def get_next_msg_key = next_msg_key.getAndIncrement
 
@@ -109,7 +99,6 @@ class CassandraStore extends DelayingSto
   }
 
   protected def _start(on_completed: Runnable) = {
-    info("Starting cassandra store at: '%s'", config.hosts.toList.mkString(", "))
     blocking = Executors.newFixedThreadPool(20, new ThreadFactory(){
       def newThread(r: Runnable) = {
         val rc = new Thread(r, "cassandra client")
@@ -136,7 +125,6 @@ class CassandraStore extends DelayingSto
   }
 
   protected def _stop(on_completed: Runnable) = {
-    info("Stopping cassandra store at: '%s'", config.hosts.toList.mkString(", "))
     blocking.shutdown
     new Thread("casandra client shutdown") {
       override def run = {

Modified: activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreFactory.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreFactory.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreFactory.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-cassandra/src/main/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreFactory.scala Wed Mar  9 22:22:59 2011
@@ -37,18 +37,20 @@ import org.apache.activemq.apollo.dto.St
 class CassandraStoreFactory extends StoreFactory.Provider {
 
   def create(config: StoreDTO) = {
-    if( config.isInstanceOf[CassandraStoreDTO]) {
-      new CassandraStore
-    } else {
-      null
+    config match {
+      case config:CassandraStoreDTO =>
+        new CassandraStore(config)
+      case _ =>
+        null
     }
   }
 
    def validate(config: StoreDTO, reporter:Reporter):ReporterLevel = {
-     if( config.isInstanceOf[CassandraStoreDTO]) {
-       CassandraStore.validate(config.asInstanceOf[CassandraStoreDTO], reporter)
-     } else {
-       null
+     config match {
+       case config:CassandraStoreDTO =>
+         CassandraStore.validate(config, reporter)
+       case _ =>
+         null
      }
    }
 }

Modified: activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreTest.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreTest.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/CassandraStoreTest.scala Wed Mar  9 22:22:59 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.apollo.broker.store.cassandra
 
+import dto.CassandraStoreDTO
 import org.apache.activemq.apollo.broker.store._
 
 /**
@@ -24,7 +25,11 @@ import org.apache.activemq.apollo.broker
 class CassandraStoreTest extends StoreFunSuiteSupport with CassandraServerMixin {
 
   def create_store(flushDelay:Long):Store = {
-    val rc = new CassandraStore
+    val rc = new CassandraStore({
+      val rc = new CassandraStoreDTO
+      rc.hosts.add("localhost:9160")
+      rc
+    })
     rc.config.flush_delay = flushDelay
     rc
   }

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/apollo.xml Wed Mar  9 22:22:59 2011
@@ -32,6 +32,9 @@
     <admin allow="admins"/>
   </acl>
 
+  <log_category console="console" security="security" connection="connection" audit="audit"/>
+
+
   <web_admin host="127.0.0.1" port="61680"/>
 
   <virtual_host id="${host}">

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/resources/org/apache/activemq/apollo/cli/commands/etc/log4j.properties Wed Mar  9 22:22:59 2011
@@ -18,18 +18,21 @@
 #
 # Setup the default logging levels
 #
-log4j.rootLogger=WARN, console, logfile
-log4j.logger.org.eclipse.jetty.plus.jaas=ERROR
-log4j.logger.org.apache.activemq.apollo=INFO
+log4j.rootLogger=ERROR
+log4j.logger.org.apache.activemq.apollo=INFO, apollo
+
+log4j.logger.console=INFO, console, apollo
+log4j.logger.security=INFO, security
+log4j.logger.connection=INFO, connection
 
 #
 # Uncomment one of the following to enable debug logging
 #
-# log4j.logger.org.apache.activemq.apollo=DEBUG
 # log4j.logger.org.apache.activemq.apollo.broker=DEBUG
+# log4j.logger.org.apache.activemq.apollo.broker.store=DEBUG
+# log4j.logger.org.apache.activemq.apollo.stomp=DEBUG
 # log4j.logger.org.apache.activemq.apollo.web=DEBUG
 # log4j.logger.org.apache.activemq.apollo.cli=DEBUG
-# log4j.logger.org.apache.activemq.apollo.broker.store.hawtdb=DEBUG
 
 # Console Settings
 log4j.appender.console=org.apache.log4j.ConsoleAppender
@@ -38,10 +41,26 @@ log4j.appender.console.layout.Conversion
 log4j.appender.console.threshold=INFO
 
 # File Settings
-log4j.appender.logfile=org.apache.log4j.RollingFileAppender
-log4j.appender.logfile.file=${apollo.base}/log/apollo.log
-log4j.appender.logfile.maxFileSize=5MB
-log4j.appender.logfile.maxBackupIndex=5
-log4j.appender.logfile.append=true
-log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
-log4j.appender.logfile.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
+log4j.appender.apollo=org.apache.log4j.RollingFileAppender
+log4j.appender.apollo.file=${apollo.base}/log/apollo.log
+log4j.appender.apollo.maxFileSize=5MB
+log4j.appender.apollo.maxBackupIndex=5
+log4j.appender.apollo.append=true
+log4j.appender.apollo.layout=org.apache.log4j.PatternLayout
+log4j.appender.apollo.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
+
+log4j.appender.connection=org.apache.log4j.RollingFileAppender
+log4j.appender.connection.file=${apollo.base}/log/connection.log
+log4j.appender.connection.maxFileSize=5MB
+log4j.appender.connection.maxBackupIndex=5
+log4j.appender.connection.append=true
+log4j.appender.connection.layout=org.apache.log4j.PatternLayout
+log4j.appender.connection.layout.ConversionPattern=%d %m%n
+
+log4j.appender.security=org.apache.log4j.RollingFileAppender
+log4j.appender.security.file=${apollo.base}/log/security.log
+log4j.appender.security.maxFileSize=5MB
+log4j.appender.security.maxBackupIndex=5
+log4j.appender.security.append=true
+log4j.appender.security.layout=org.apache.log4j.PatternLayout
+log4j.appender.security.layout.ConversionPattern=%d %m%n

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=1080035&r1=1080034&r2=1080035&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 Wed Mar  9 22:22:59 2011
@@ -22,15 +22,15 @@ import org.apache.activemq.apollo.broker
 import org.fusesource.hawtdispatch._
 import org.apache.activemq.apollo.util.FileSupport._
 import org.apache.activemq.apollo.cli.Apollo
-import org.apache.activemq.apollo.util.{Logging, LoggingReporter}
+import org.apache.activemq.apollo.util.{Log, LoggingReporter}
 import org.apache.felix.service.command.CommandSession
 
 /**
  * The apollo run command
  */
 @command(scope="apollo", name = "run", description = "runs the broker instance")
-class Run extends Action with Logging {
-
+class Run extends Action {
+  
   @option(name = "--conf", description = "The Apollo configuration file.")
   var conf: File = _
 
@@ -78,20 +78,17 @@ class Run extends Action with Logging {
       Apollo.print_banner(session.getConsole)
 
       // Load the configs and start the brokers up.
-      info("Loading configuration file '%s'.", conf);
+      session.getConsole.print("Loading configuration file '%s'.", conf);
+
       val store = new FileConfigStore
       store.file = conf
       ConfigStore() = store
       store.start
-      val config = store.load(true)
 
-      debug("Starting broker");
       val broker = new Broker()
-      broker.configure(config, LoggingReporter(log))
+      broker.config = store.load(true)
       broker.tmp = tmp
-      broker.start(^{
-        info("Broker started");
-      })
+      broker.start()
 
       // wait forever...  broker will system exit.
       this.synchronized {

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=1080035&r1=1080034&r2=1080035&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 Wed Mar  9 22:22:59 2011
@@ -78,10 +78,7 @@ class StoreExport extends Action {
         error("Could not create the store.")
       }
 
-      store.configure(vh.store, LoggingReporter(StoreExport))
       ServiceControl.start(store, "store startup")
-
-
       using( new ZipOutputStream(new FileOutputStream(dest))) { out=>
         out.setMethod(ZipEntry.DEFLATED)
         out.setLevel(9)

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=1080035&r1=1080034&r2=1080035&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 Wed Mar  9 22:22:59 2011
@@ -79,7 +79,6 @@ class StoreImport extends Action {
         error("Could not create the store.")
       }
 
-      store.configure(vh.store, LoggingReporter(StoreImport))
       ServiceControl.start(store, "store startup")
 
       val zip = new ZipFile(dest)

Modified: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java (original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java Wed Mar  9 22:22:59 2011
@@ -70,6 +70,8 @@ public class BrokerDTO {
     @XmlElement(name="authentication")
     public AuthenticationDTO authentication;
 
+    @XmlElement(name="log_category")
+    public LogCategoryDTO log_category;
 
     public Boolean sticky_dispatching;
 }

Copied: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/LogCategoryDTO.java (from r1079030, activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreBenchmark.scala)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/LogCategoryDTO.java?p2=activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/LogCategoryDTO.java&p1=activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreBenchmark.scala&r1=1079030&r2=1080035&rev=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreBenchmark.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/LogCategoryDTO.java Wed Mar  9 22:22:59 2011
@@ -14,21 +14,30 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.activemq.apollo.broker.store.jdbm2
-
-import org.apache.activemq.apollo.broker.store.StoreBenchmarkSupport
-import org.apache.activemq.apollo.broker.store.Store
+package org.apache.activemq.apollo.dto;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-class JDBM2StoreBenchmark extends StoreBenchmarkSupport {
+@XmlRootElement(name="log_category")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class LogCategoryDTO {
+
+    @XmlAttribute
+    public String console;
+
+    @XmlAttribute
+    public String audit;
+
+    @XmlAttribute
+    public String connection;
 
-  def create_store(flushDelay:Long):Store = {
-    val rc = new JDBM2Store
-    rc.config.flush_delay = flushDelay
-    rc
-  }
+    @XmlAttribute
+    public String security;
 
-}
+}
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java (original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java Wed Mar  9 22:22:59 2011
@@ -79,4 +79,6 @@ public class VirtualHostDTO extends Serv
     @XmlElementRef
     public RouterDTO router;
 
+    @XmlElement(name="log_category")
+    public LogCategoryDTO log_category;
 }

Modified: activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStore.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStore.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStore.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStore.scala Wed Mar  9 22:22:59 2011
@@ -37,15 +37,6 @@ object HawtDBStore extends Log {
   val DATABASE_LOCKED_WAIT_DELAY = 10 * 1000;
 
   /**
-   * Creates a default a configuration object.
-   */
-  def defaultConfig() = {
-    val rc = new HawtDBStoreDTO
-    rc.directory = new File("activemq-data")
-    rc
-  }
-
-  /**
    * Validates a configuration object.
    */
   def validate(config: HawtDBStoreDTO, reporter:Reporter):ReporterLevel = {
@@ -60,7 +51,7 @@ object HawtDBStore extends Log {
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-class HawtDBStore extends DelayingStoreSupport {
+class HawtDBStore(var config:HawtDBStoreDTO) extends DelayingStoreSupport {
 
   import HawtDBStore._
 
@@ -69,13 +60,12 @@ class HawtDBStore extends DelayingStoreS
 
   var executor_pool:ExecutorService = _
   val schedule_version = new AtomicInteger()
-  var config:HawtDBStoreDTO = defaultConfig
   val client = new HawtDBClient(this)
 
   val load_source = createSource(new ListEventAggregator[(Long, (Option[MessageRecord])=>Unit)](), dispatch_queue)
   load_source.setEventHandler(^{drain_loads});
 
-  override def toString = "hawtdb store"
+  override def toString = "hawtdb store at "+config.directory
 
   def flush_delay = config.flush_delay.getOrElse(100)
   
@@ -105,7 +95,6 @@ class HawtDBStore extends DelayingStoreS
   }
 
   protected def _start(on_completed: Runnable) = {
-    info("Starting hawtdb store at: '%s'", config.directory)
     executor_pool = Executors.newFixedThreadPool(1, new ThreadFactory(){
       def newThread(r: Runnable) = {
         val rc = new Thread(r, "hawtdb store client")
@@ -153,7 +142,6 @@ class HawtDBStore extends DelayingStoreS
   }
 
   protected def _stop(on_completed: Runnable) = {
-    info("Stopping hawtdb store at: '%s'", config.directory)
     schedule_version.incrementAndGet
     new Thread() {
       override def run = {

Modified: activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreFactory.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreFactory.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreFactory.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-hawtdb/src/main/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreFactory.scala Wed Mar  9 22:22:59 2011
@@ -37,18 +37,20 @@ import ReporterLevel._
 class HawtDBStoreFactory extends StoreFactory.Provider {
 
   def create(config: StoreDTO) = {
-    if( config.isInstanceOf[HawtDBStoreDTO]) {
-      new HawtDBStore
-    } else {
-      null
+    config match {
+      case config:HawtDBStoreDTO =>
+        new HawtDBStore(config)
+      case _ =>
+        null
     }
   }
 
    def validate(config: StoreDTO, reporter:Reporter):ReporterLevel = {
-     if( config.isInstanceOf[HawtDBStoreDTO]) {
-       HawtDBStore.validate(config.asInstanceOf[HawtDBStoreDTO], reporter)
-     } else {
-       null
+     config match {
+       case config:HawtDBStoreDTO =>
+         HawtDBStore.validate(config, reporter)
+       case _ =>
+         null
      }
    }
 }

Modified: activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreBenchmark.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreBenchmark.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreBenchmark.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreBenchmark.scala Wed Mar  9 22:22:59 2011
@@ -16,8 +16,10 @@
  */
 package org.apache.activemq.apollo.broker.store.hawtdb
 
+import dto.HawtDBStoreDTO
 import org.apache.activemq.apollo.broker.store.StoreBenchmarkSupport
 import org.apache.activemq.apollo.broker.store.Store
+import org.apache.activemq.apollo.util.FileSupport._
 
 
 /**
@@ -26,7 +28,11 @@ import org.apache.activemq.apollo.broker
 class HawtDBStoreBenchmark extends StoreBenchmarkSupport {
 
   def create_store(flushDelay:Long):Store = {
-    val rc = new HawtDBStore
+    val rc = new HawtDBStore({
+      val rc = new HawtDBStoreDTO
+      rc.directory = basedir / "activemq-data"
+      rc
+    })
     rc.config.flush_delay = flushDelay
     rc
   }

Modified: activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreTest.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreTest.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/HawtDBStoreTest.scala Wed Mar  9 22:22:59 2011
@@ -16,7 +16,9 @@
  */
 package org.apache.activemq.apollo.broker.store.hawtdb
 
+import dto.HawtDBStoreDTO
 import org.apache.activemq.apollo.broker.store.{Store, StoreFunSuiteSupport}
+import org.apache.activemq.apollo.util.FileSupport._
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@@ -24,7 +26,11 @@ import org.apache.activemq.apollo.broker
 class HawtDBStoreTest extends StoreFunSuiteSupport {
 
   def create_store(flushDelay:Long):Store = {
-    val rc = new HawtDBStore
+    val rc = new HawtDBStore({
+      val rc = new HawtDBStoreDTO
+      rc.directory = basedir / "activemq-data"
+      rc
+    })
     rc.config.flush_delay = flushDelay
     rc
   }

Modified: activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2Store.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2Store.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2Store.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2Store.scala Wed Mar  9 22:22:59 2011
@@ -38,15 +38,6 @@ object JDBM2Store extends Log {
   val DATABASE_LOCKED_WAIT_DELAY = 10 * 1000;
 
   /**
-   * Creates a default a configuration object.
-   */
-  def defaultConfig() = {
-    val rc = new JDBM2StoreDTO
-    rc.directory = new File("activemq-data")
-    rc
-  }
-
-  /**
    * Validates a configuration object.
    */
   def validate(config: JDBM2StoreDTO, reporter:Reporter):ReporterLevel = {
@@ -61,7 +52,7 @@ object JDBM2Store extends Log {
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-class JDBM2Store extends DelayingStoreSupport {
+class JDBM2Store(var config:JDBM2StoreDTO) extends DelayingStoreSupport {
 
   import JDBM2Store._
 
@@ -69,10 +60,9 @@ class JDBM2Store extends DelayingStoreSu
   var next_msg_key = new AtomicLong(1)
 
   var executor:ExecutorService = _
-  var config:JDBM2StoreDTO = defaultConfig
   val client = new JDBM2Client(this)
 
-  override def toString = "jdbm2 store"
+  override def toString = "jdbm2 store at "+config.directory
 
   def flush_delay = config.flush_delay.getOrElse(100)
   
@@ -104,7 +94,6 @@ class JDBM2Store extends DelayingStoreSu
   }
 
   protected def _start(on_completed: Runnable) = {
-    info("Starting jdbm2 store at: '%s'", config.directory)
     executor = Executors.newFixedThreadPool(1, new ThreadFactory(){
       def newThread(r: Runnable) = {
         val rc = new Thread(r, "jdbm2 store io write")
@@ -126,7 +115,6 @@ class JDBM2Store extends DelayingStoreSu
   protected def _stop(on_completed: Runnable) = {
     new Thread() {
       override def run = {
-        info("Stopping jdbm2 store at: '%s'", config.directory)
         executor.shutdown
         executor.awaitTermination(60, TimeUnit.SECONDS)
         executor = null

Modified: activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreFactory.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreFactory.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreFactory.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-jdbm2/src/main/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreFactory.scala Wed Mar  9 22:22:59 2011
@@ -24,10 +24,6 @@ import ReporterLevel._
 
 /**
  * <p>
- * Hook to use a HawtDBStore when a HawtDBStoreDTO is
- * used in a broker configuration.
- * </p>
- * <p>
  * This class is discovered using the following resource file:
  * <code>META-INF/services/org.apache.activemq.apollo/stores</code>
  * </p>
@@ -37,18 +33,20 @@ import ReporterLevel._
 class JDBM2StoreFactory extends StoreFactory.Provider {
 
   def create(config: StoreDTO) = {
-    if( config.isInstanceOf[JDBM2StoreDTO]) {
-      new JDBM2Store
-    } else {
-      null
+    config match {
+      case config:JDBM2StoreDTO =>
+        new JDBM2Store(config)
+      case _ =>
+        null
     }
   }
 
    def validate(config: StoreDTO, reporter:Reporter):ReporterLevel = {
-     if( config.isInstanceOf[JDBM2StoreDTO]) {
-       JDBM2Store.validate(config.asInstanceOf[JDBM2StoreDTO], reporter)
-     } else {
-       null
+     config match {
+       case config:JDBM2StoreDTO =>
+         JDBM2Store.validate(config, reporter)
+       case _ =>
+         null
      }
    }
 }

Modified: activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreBenchmark.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreBenchmark.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreBenchmark.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreBenchmark.scala Wed Mar  9 22:22:59 2011
@@ -16,8 +16,10 @@
  */
 package org.apache.activemq.apollo.broker.store.jdbm2
 
+import dto.JDBM2StoreDTO
 import org.apache.activemq.apollo.broker.store.StoreBenchmarkSupport
 import org.apache.activemq.apollo.broker.store.Store
+import org.apache.activemq.apollo.util.FileSupport._
 
 
 /**
@@ -26,7 +28,11 @@ import org.apache.activemq.apollo.broker
 class JDBM2StoreBenchmark extends StoreBenchmarkSupport {
 
   def create_store(flushDelay:Long):Store = {
-    val rc = new JDBM2Store
+    val rc = new JDBM2Store({
+      val rc = new JDBM2StoreDTO
+      rc.directory = basedir / "activemq-data"
+      rc
+    })
     rc.config.flush_delay = flushDelay
     rc
   }

Modified: activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreTest.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreTest.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/JDBM2StoreTest.scala Wed Mar  9 22:22:59 2011
@@ -16,7 +16,9 @@
  */
 package org.apache.activemq.apollo.broker.store.jdbm2
 
+import dto.JDBM2StoreDTO
 import org.apache.activemq.apollo.broker.store.{Store, StoreFunSuiteSupport}
+import org.apache.activemq.apollo.util.FileSupport._
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@@ -24,7 +26,11 @@ import org.apache.activemq.apollo.broker
 class JDBM2StoreTest extends StoreFunSuiteSupport {
 
   def create_store(flushDelay:Long):Store = {
-    val rc = new JDBM2Store
+    val rc = new JDBM2Store({
+      val rc = new JDBM2StoreDTO
+      rc.directory = basedir / "activemq-data"
+      rc
+    })
     rc.config.flush_delay = flushDelay
     rc
   }

Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompProtocolHandler.scala Wed Mar  9 22:22:59 2011
@@ -517,6 +517,8 @@ class StompProtocolHandler extends Proto
         security_context.certificates = Option(t.getPeerX509Certificates).getOrElse(Array[X509Certificate]())
       case _ => None
     }
+
+    security_context.remote_address = connection.transport.getRemoteAddress
     security_context.user = get(headers, LOGIN).map(decode_header _).getOrElse(null)
     security_context.password = get(headers, PASSCODE).map(decode_header _).getOrElse(null)
 

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Logging.scala Wed Mar  9 22:22:59 2011
@@ -27,6 +27,13 @@ import java.util.concurrent.atomic.Atomi
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
 object Log {
+
+  def apply(clazz:Class[_]):Log = apply(clazz.getName.stripSuffix("$"))
+
+  def apply(name:String):Log = new Log {
+    override val log = LoggerFactory.getLogger(name)
+  }
+
   val exception_id_generator = new AtomicLong(System.currentTimeMillis)
   def next_exception_id = exception_id_generator.incrementAndGet.toHexString
 }
@@ -171,19 +178,11 @@ trait Log {
 }
 
 /**
- * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
- */
-class NamedLog(name:String) extends Log {
-  def this(clazz:Class[_]) = this(clazz.getName.stripSuffix("$"))
-  override val log = LoggerFactory.getLogger(name)
-}
-
-/**
  * A Logging trait you can mix into an implementation class without affecting its public API
  */
 trait Logging {
 
-  protected def log: Log = new NamedLog(getClass)
+  protected def log: Log = Log(getClass)
 
   protected def error(message: => String, args:Any*)= log.error(message, args : _*)
   protected def error(e: Throwable, message: => String, args:Any*)= log.error(e, message, args: _*)

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/LoggingTracker.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/LoggingTracker.scala?rev=1080035&r1=1080034&r2=1080035&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/LoggingTracker.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/LoggingTracker.scala Wed Mar  9 22:22:59 2011
@@ -16,8 +16,6 @@
  */
 package org.apache.activemq.apollo.util
 
-import java.util.concurrent.{CountDownLatch, TimeUnit}
-import java.util.HashSet
 import org.fusesource.hawtdispatch._
 import org.fusesource.hawtdispatch.{TaskTracker, DispatchQueue}
 
@@ -29,14 +27,14 @@ import org.fusesource.hawtdispatch.{Task
  *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-class LoggingTracker(name:String, parent:DispatchQueue=globalQueue) extends TaskTracker(name, parent) with Logging {
+class LoggingTracker(name:String, val log:Log=Log(classOf[LoggingTracker]), parent:DispatchQueue=globalQueue) extends TaskTracker(name, parent) {
+  assert(log!=null)
+  import log._
 
   timeout = 1000;
 
-  override protected def log = LoggingTracker
-
   override protected def onTimeout(duration:Long, tasks: List[String]):Long = {
-    info("%s is taking a long time (%d seconds). Waiting on %s", name, (duration/1000), tasks)
+    info("%s is taking a long time (%d seconds). Waiting on %s", name, (duration/1000), tasks.mkString(", "))
     timeout
   }
 
@@ -49,11 +47,3 @@ class LoggingTracker(name:String, parent
   }
 
 }
-
-object LoggingTracker extends Log {
-  def apply[R](name:String, parent:DispatchQueue=globalQueue)(func: (LoggingTracker)=>Unit ) = {
-    val t = new LoggingTracker(name, parent)
-    func(t)
-    t.await
-  }
-}



Mime
View raw message