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/05/23 20:25:40 UTC
svn commit: r1126634 - in
/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker:
Broker.scala protocol/ProtocolFactory.scala
Author: chirino
Date: Mon May 23 18:25:39 2011
New Revision: 1126634
URL: http://svn.apache.org/viewvc?rev=1126634&view=rev
Log:
Use reflection to inject optional values so that interfaces are simpler.
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/protocol/ProtocolFactory.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=1126634&r1=1126633&r2=1126634&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 Mon May 23 18:25:39 2011
@@ -305,7 +305,16 @@ class Broker() extends BaseService {
services = (config.services.map { clazz =>
- Broker.class_loader.loadClass(clazz).newInstance().asInstanceOf[Service]
+ val service = Broker.class_loader.loadClass(clazz).newInstance().asInstanceOf[Service]
+
+ // Try to inject the broker via reflection..
+ type BrokerAware = { var broker:Broker }
+ try {
+ service.asInstanceOf[BrokerAware].broker = this
+ } catch { case _ => }
+
+ service
+
}).toList
}
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala?rev=1126634&r1=1126633&r2=1126634&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala Mon May 23 18:25:39 2011
@@ -92,13 +92,17 @@ object ProtocolFilter {
def create_filters(clazzes:List[String], handler:ProtocolHandler) = {
clazzes.map { clazz =>
val filter = Broker.class_loader.loadClass(clazz).newInstance().asInstanceOf[ProtocolFilter]
- filter.protocol_handler = handler
+
+ type ProtocolHandlerAware = { var protocol_handler:ProtocolHandler }
+ try {
+ filter.asInstanceOf[ProtocolHandlerAware].protocol_handler = handler
+ } catch { case _ => }
+
filter
}
}
}
trait ProtocolFilter {
- var protocol_handler:ProtocolHandler = _
def filter[T](command: T):T
}