activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1076356 - in /activemq/activemq-apollo/trunk: apollo-broker/ apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ apollo-dto/src/main/java/org/apache/activemq/apollo/dto/
Date Wed, 02 Mar 2011 19:54:52 GMT
Author: chirino
Date: Wed Mar  2 19:54:51 2011
New Revision: 1076356

URL: http://svn.apache.org/viewvc?rev=1076356&view=rev
Log:
Making the router interface pluggable.

Added:
    activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/RouterDTO.java
Modified:
    activemq/activemq-apollo/trunk/apollo-broker/pom.xml
    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/Router.scala
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala
    activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java

Modified: activemq/activemq-apollo/trunk/apollo-broker/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/pom.xml?rev=1076356&r1=1076355&r2=1076356&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/pom.xml Wed Mar  2 19:54:51 2011
@@ -93,7 +93,7 @@
       <optional>true</optional>
     </dependency>
 
-    <!-- for optional osgi itegration -->
+    <!-- for optional osgi integration -->
     <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>

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=1076356&r1=1076355&r2=1076356&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  2 19:54:51 2011
@@ -96,7 +96,7 @@ object LocalRouter extends Log {
 class LocalRouter(val host:VirtualHost) extends BaseService with Router {
   import LocalRouter._
 
-  protected def dispatch_queue:DispatchQueue = host.dispatch_queue
+  def dispatch_queue:DispatchQueue = host.dispatch_queue
 
   def auto_create_destinations = {
     import OptionSupport._
@@ -698,7 +698,7 @@ class LocalRouter(val host:VirtualHost) 
     queues_by_id.remove(queue.id)
     queue.stop
     if( queue.tune_persistent ) {
-      queue.dispatch_queue ^ {
+      queue.dispatch_queue {
         host.store.remove_queue(queue.id){x=> Unit}
       }
     }

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Router.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Router.scala?rev=1076356&r1=1076355&r2=1076356&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Router.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Router.scala
Wed Mar  2 19:54:51 2011
@@ -24,6 +24,7 @@ import org.apache.activemq.apollo.dto._
 import security.SecurityContext
 import store.StoreUOW
 import util.continuations._
+import ReporterLevel._
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@@ -45,6 +46,54 @@ trait Router extends Service {
 }
 
 /**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+object RouterFactory {
+
+  trait Provider {
+    def create(host:VirtualHost):Router
+    def validate(config: RouterDTO, reporter:Reporter):ReporterLevel
+  }
+
+  val providers = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/router-factory.index",
classOf[Provider])
+
+  def create(host:VirtualHost):Router = {
+    val config = host.config.router;
+    if( config==null ) {
+      return new LocalRouter(host)
+    }
+    providers.singletons.foreach { provider=>
+      val rc = provider.create(host)
+      if( rc!=null ) {
+        return rc
+      }
+    }
+    throw new IllegalArgumentException("Uknonwn store type: "+config.getClass)
+  }
+
+
+  def validate(config: RouterDTO, reporter:Reporter):ReporterLevel = {
+    if( config == null ) {
+      return INFO
+    } else {
+      providers.singletons.foreach { provider=>
+        val rc = provider.validate(config, reporter)
+        if( rc!=null ) {
+          return rc
+        }
+      }
+    }
+    reporter.report(ERROR, "Uknonwn store type: "+config.getClass)
+    ERROR
+  }
+
+}
+
+
+/**
  * An object which produces deliveries to which allows new DeliveryConsumer
  * object to bind so they can also receive those deliveries.
  *

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=1076356&r1=1076355&r2=1076356&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  2 19:54:51 2011
@@ -76,7 +76,7 @@ class VirtualHost(val broker: Broker, va
   override val dispatch_queue:DispatchQueue = createQueue("virtual-host") // getGlobalQueue(DispatchPriority.HIGH).createQueue("virtual-host")
 
   var config:VirtualHostDTO = _
-  val router:Router = new LocalRouter(this)
+  var router:Router = _
 
   var names:List[String] = Nil;
 
@@ -125,6 +125,7 @@ class VirtualHost(val broker: Broker, va
       authorizer = broker.authorizer
     }
 
+    router = RouterFactory.create(this)
     store = StoreFactory.create(config.store)
 
     if( store!=null ) {

Added: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/RouterDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/RouterDTO.java?rev=1076356&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/RouterDTO.java
(added)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/RouterDTO.java
Wed Mar  2 19:54:51 2011
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.apollo.dto;
+
+import org.codehaus.jackson.annotate.JsonTypeInfo;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+@XmlType (name = "router_type")
+@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
+public abstract class RouterDTO {
+}

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=1076356&r1=1076355&r2=1076356&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  2 19:54:51 2011
@@ -76,4 +76,7 @@ public class VirtualHostDTO extends Serv
     @XmlElement(name="authentication")
     public AuthenticationDTO authentication;
 
+    @XmlElement(name="router")
+    public RouterDTO router;
+
 }



Mime
View raw message