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/01/30 05:07:32 UTC
svn commit: r1065181 - in /activemq/activemq-apollo/trunk: ./ apollo-bdb/
apollo-broker/
apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/
apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/osgi/
apollo-broker/src/main/scala/o...
Author: chirino
Date: Sun Jan 30 04:07:31 2011
New Revision: 1065181
URL: http://svn.apache.org/viewvc?rev=1065181&view=rev
Log:
big class finder refactor so we can work better inside OSGi.
Added:
activemq/activemq-apollo/trunk/apollo-karaf/
activemq/activemq-apollo/trunk/apollo-karaf/pom.xml
- copied, changed from r1065180, activemq/activemq-apollo/trunk/apollo-bdb/pom.xml
activemq/activemq-apollo/trunk/apollo-karaf/src/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/OSGI-INF/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/OSGI-INF/blueprint/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/OSGI-INF/blueprint/broker.xml
activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/features.xml
- copied, changed from r1065180, activemq/activemq-apollo/trunk/apollo-karaf-feature/src/main/resources/features.xml
activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/apache/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/apache/activemq/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/apache/activemq/apollo/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/apache/activemq/apollo/karaf/
activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/apache/activemq/apollo/karaf/BrokerService.scala
activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinderActivator.scala
Removed:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/osgi/Activator.scala
activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/JavaClassFinder.java
Modified:
activemq/activemq-apollo/trunk/apollo-bdb/pom.xml
activemq/activemq-apollo/trunk/apollo-broker/pom.xml
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/QueueBinding.scala
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/MultiProtocol.scala
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/ProtocolFactory.scala
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/StoreFactory.scala
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServerFactory.scala
activemq/activemq-apollo/trunk/apollo-cassandra/pom.xml
activemq/activemq-apollo/trunk/apollo-cli/pom.xml
activemq/activemq-apollo/trunk/apollo-dto/pom.xml
activemq/activemq-apollo/trunk/apollo-hawtdb/pom.xml
activemq/activemq-apollo/trunk/apollo-jdbm2/pom.xml
activemq/activemq-apollo/trunk/apollo-karaf-feature/src/main/resources/features.xml
activemq/activemq-apollo/trunk/apollo-stomp/pom.xml
activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/perf/StompBrokerPerfTest.scala
activemq/activemq-apollo/trunk/apollo-tcp/pom.xml
activemq/activemq-apollo/trunk/apollo-transport/pom.xml
activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/DiscoveryAgentFactory.java
activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/ProtocolCodecFactory.java
activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/TransportFactory.java
activemq/activemq-apollo/trunk/apollo-util/pom.xml
activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala
activemq/activemq-apollo/trunk/pom.xml
Modified: activemq/activemq-apollo/trunk/apollo-bdb/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-bdb/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-bdb/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-bdb/pom.xml Sun Jan 30 04:07:31 2011
@@ -34,6 +34,10 @@
<name>${project.artifactId}</name>
+ <properties>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
+ </properties>
+
<dependencies>
<dependency>
Modified: activemq/activemq-apollo/trunk/apollo-broker/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/pom.xml Sun Jan 30 04:07:31 2011
@@ -35,7 +35,7 @@
<name>${project.artifactId}</name>
<properties>
- <apollo.osgi.host></apollo.osgi.host>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
</properties>
<dependencies>
@@ -154,16 +154,6 @@
<build>
<plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-Activator>org.apache.activemq.apollo.broker.osgi.ApolloActivator</Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
-
<!-- Generate a test jar for the test cases in this package -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
@@ -178,7 +168,7 @@
<plugin>
<groupId>org.fusesource.hawtbuf</groupId>
- <artifactId>hawtbuf-proto</artifactId>
+ <artifactId>hawtbuf-protoc</artifactId>
<version>${hawtbuf-version}</version>
<configuration>
<type>alt</type>
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=1065181&r1=1065180&r2=1065181&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 Jan 30 04:07:31 2011
@@ -46,19 +46,13 @@ object BrokerFactory {
def createBroker(brokerURI:String):Broker
}
- def discover = {
- val finder = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/broker-factory.index")
- finder.new_instances
- }
-
- var providers = discover
-
+ val providers = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/broker-factory.index",classOf[Provider])
def createBroker(uri:String):Broker = {
if( uri == null ) {
return null
}
- providers.foreach { provider=>
+ providers.singletons.foreach { provider=>
val broker = provider.createBroker(uri)
if( broker!=null ) {
return broker;
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/QueueBinding.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/QueueBinding.scala?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/QueueBinding.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/QueueBinding.scala Sun Jan 30 04:07:31 2011
@@ -37,15 +37,10 @@ object QueueBinding {
def create(binding_dto:DestinationDTO):QueueBinding
}
- def discover = {
- val finder = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/binding-factory.index")
- finder.new_instances
- }
-
- var providers = discover
+ val providers = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/binding-factory.index",classOf[Provider])
def create(binding_kind:AsciiBuffer, binding_data:Buffer):QueueBinding = {
- providers.foreach { provider=>
+ providers.singletons.foreach { provider=>
val rc = provider.create(binding_kind, binding_data)
if( rc!=null ) {
return rc
@@ -54,7 +49,7 @@ object QueueBinding {
throw new IllegalArgumentException("Invalid binding type: "+binding_kind);
}
def create(binding_dto:DestinationDTO):QueueBinding = {
- providers.foreach { provider=>
+ providers.singletons.foreach { provider=>
val rc = provider.create(binding_dto)
if( rc!=null ) {
return rc
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/MultiProtocol.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/MultiProtocol.scala?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/MultiProtocol.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/protocol/MultiProtocol.scala Sun Jan 30 04:07:31 2011
@@ -35,7 +35,7 @@ import org.fusesource.hawtdispatch._
*/
class MultiProtocolFactory extends ProtocolFactory.Provider {
- def all_protocols: Array[Protocol] = ((ProtocolFactory.providers.map(_.create())).filter(_.isIdentifiable)).toArray
+ def all_protocols: Array[Protocol] = ((ProtocolFactory.provider.singletons.map(_.create())).filter(_.isIdentifiable)).toArray
def create() = {
new MultiProtocol(()=>all_protocols)
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=1065181&r1=1065180&r2=1065181&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 Sun Jan 30 04:07:31 2011
@@ -37,15 +37,10 @@ object ProtocolFactory {
def create(config:String):Protocol
}
- def discover = {
- val finder = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/protocol-factory.index")
- finder.new_instances
- }
-
- var providers = discover
+ val provider = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/protocol-factory.index",classOf[Provider])
def get(name:String):Option[Protocol] = {
- providers.foreach { provider=>
+ provider.singletons.foreach { provider=>
val rc = provider.create(name)
if( rc!=null ) {
return Some(rc)
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/StoreFactory.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/StoreFactory.scala?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/StoreFactory.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/StoreFactory.scala Sun Jan 30 04:07:31 2011
@@ -33,18 +33,13 @@ object StoreFactory {
def validate(config: StoreDTO, reporter:Reporter):ReporterLevel
}
- def discover = {
- val finder = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/store-factory.index")
- finder.new_instances
- }
-
- var providers = discover
+ val providers = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/store-factory.index", classOf[Provider])
def create(config:StoreDTO):Store = {
if( config == null ) {
return null
}
- providers.foreach { provider=>
+ providers.singletons.foreach { provider=>
val rc = provider.create(config)
if( rc!=null ) {
return rc
@@ -58,7 +53,7 @@ object StoreFactory {
if( config == null ) {
return INFO
} else {
- providers.foreach { provider=>
+ providers.singletons.foreach { provider=>
val rc = provider.validate(config, reporter)
if( rc!=null ) {
return rc
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServer.scala Sun Jan 30 04:07:31 2011
@@ -40,6 +40,9 @@ trait WebServer extends Service
object JettyWebServerFactory extends WebServerFactory.Provider {
+ // So that the factory class does not load, if we can not load jetty.
+ private val LOAD_JETTY = classOf[LoginService]
+
def create(broker:Broker): WebServer = new JettyWebServer(broker)
def validate(config: WebAdminDTO, reporter: Reporter): ReporterLevel.ReporterLevel = {
@@ -54,7 +57,6 @@ object JettyWebServerFactory extends Web
object JettyWebServer extends Log {
- val LOAD_JETTY = classOf[LoginService]
val webapp = {
import FileSupport._
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServerFactory.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServerFactory.scala?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServerFactory.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/web/WebServerFactory.scala Sun Jan 30 04:07:31 2011
@@ -35,18 +35,13 @@ object WebServerFactory {
def validate(config: WebAdminDTO, reporter:Reporter):ReporterLevel
}
- def discover = {
- val finder = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/web-server-factory.index")
- finder.new_instances
- }
-
- var providers = discover
+ val providers = new ClassFinder[Provider]("META-INF/services/org.apache.activemq.apollo/web-server-factory.index",classOf[Provider])
def create(broker:Broker):WebServer = {
if( broker == null ) {
return null
}
- providers.foreach { provider=>
+ providers.singletons.foreach { provider=>
val rc = provider.create(broker)
if( rc!=null ) {
return rc
@@ -60,7 +55,7 @@ object WebServerFactory {
if( config == null ) {
return INFO
} else {
- providers.foreach { provider=>
+ providers.singletons.foreach { provider=>
val rc = provider.validate(config, reporter)
if( rc!=null ) {
return rc
Modified: activemq/activemq-apollo/trunk/apollo-cassandra/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cassandra/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cassandra/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-cassandra/pom.xml Sun Jan 30 04:07:31 2011
@@ -34,6 +34,10 @@
<name>${project.artifactId}</name>
+ <properties>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
+ </properties>
+
<repositories>
<repository>
<id>shorrockin Maven 2 Repository</id>
Modified: activemq/activemq-apollo/trunk/apollo-cli/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/pom.xml Sun Jan 30 04:07:31 2011
@@ -31,6 +31,10 @@
<name>${project.artifactId}</name>
+ <properties>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
+ </properties>
+
<dependencies>
<!-- Scala Support -->
@@ -108,18 +112,7 @@
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>apollo-hawtdb</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <!--<dependency>-->
- <!--<groupId>org.apache.activemq</groupId>-->
- <!--<artifactId>apollo-cassandra</artifactId>-->
- <!--<version>1.0-SNAPSHOT</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
+
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>apollo-bdb</artifactId>
Modified: activemq/activemq-apollo/trunk/apollo-dto/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-dto/pom.xml Sun Jan 30 04:07:31 2011
@@ -34,20 +34,12 @@
<name>${project.artifactId}</name>
<properties>
- <apollo.osgi.host></apollo.osgi.host>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
</properties>
-
+
<dependencies>
- <dependency>
- <groupId>stax</groupId>
- <artifactId>stax-api</artifactId>
- <version>${stax-api-version}</version>
- </dependency>
- <dependency>
- <groupId>stax</groupId>
- <artifactId>stax</artifactId>
- <version>${stax-version}</version>
- </dependency>
+
+
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
Modified: activemq/activemq-apollo/trunk/apollo-hawtdb/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-hawtdb/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-hawtdb/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-hawtdb/pom.xml Sun Jan 30 04:07:31 2011
@@ -34,6 +34,10 @@
<name>${project.artifactId}</name>
+ <properties>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
+ </properties>
+
<dependencies>
<dependency>
@@ -127,7 +131,7 @@
<plugin>
<groupId>org.fusesource.hawtbuf</groupId>
- <artifactId>hawtbuf-proto</artifactId>
+ <artifactId>hawtbuf-protoc</artifactId>
<version>${hawtbuf-version}</version>
<configuration>
<type>alt</type>
Modified: activemq/activemq-apollo/trunk/apollo-jdbm2/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jdbm2/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jdbm2/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-jdbm2/pom.xml Sun Jan 30 04:07:31 2011
@@ -33,6 +33,9 @@
<packaging>bundle</packaging>
<name>${project.artifactId}</name>
+ <properties>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
+ </properties>
<dependencies>
Modified: activemq/activemq-apollo/trunk/apollo-karaf-feature/src/main/resources/features.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-karaf-feature/src/main/resources/features.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-karaf-feature/src/main/resources/features.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-karaf-feature/src/main/resources/features.xml Sun Jan 30 04:07:31 2011
@@ -17,60 +17,49 @@
limitations under the License.
-->
<features>
-
- <!-- the default modules include the jdbm, stomp, and the web admin. -->
- <feature name='apollo' version='${pom.version}'>
- <feature version='${pom.version}'>apollo-jdbm</feature>
- <feature version='${pom.version}'>apollo-stomp</feature>
- <!-- <feature version='${pom.version}'>apollo-web</feature> -->
- </feature>
- <feature name='apollo-broker' version='${pom.version}'>
+ <feature name='apollo' version='${pom.version}'>
<bundle>mvn:org.apache.activemq/apollo-broker/${pom.version}</bundle>
- <bundle>mvn:org.apache.activemq/apollo-cli/${pom.version}</bundle>
+ <!-- <bundle>mvn:org.apache.activemq/apollo-cli/${pom.version}</bundle> -->
<bundle>mvn:org.apache.activemq/apollo-dto/${pom.version}</bundle>
<bundle>mvn:org.apache.activemq/apollo-selector/${pom.version}</bundle>
<bundle>mvn:org.apache.activemq/apollo-transport/${pom.version}</bundle>
<bundle>mvn:org.apache.activemq/apollo-util/${pom.version}</bundle>
+ <bundle>mvn:org.apache.activemq/apollo-karaf/${pom.version}</bundle>
<!-- external dependencies -->
<bundle>wrap:mvn:org.scala-lang/scala-library/${scala-version}</bundle>
<bundle>mvn:org.fusesource.hawtbuf/hawtbuf/${hawtbuf-version}</bundle>
- <bundle>wrap:mvn:org.fusesource.hawtbuf/hawtbuf-proto/${hawtbuf-version}</bundle>
- <bundle>wrap:mvn:org.fusesource.hawtdispatch/hawtdispatch/${hawtdispatch-version}</bundle>
- <bundle>wrap:mvn:org.fusesource.hawtdispatch/hawtdispatch-scala/${hawtdispatch-version}</bundle>
+ <bundle>mvn:org.fusesource.hawtbuf/hawtbuf-proto/${hawtbuf-version}</bundle>
+ <bundle>mvn:org.fusesource.hawtdispatch/hawtdispatch/${hawtdispatch-version}</bundle>
+ <bundle>mvn:org.fusesource.hawtdispatch/hawtdispatch-scala/${hawtdispatch-version}</bundle>
<bundle>mvn:org.codehaus.jackson/jackson-core-asl/${jackson-version}</bundle>
<bundle>mvn:org.codehaus.jackson/jackson-mapper-asl/${jackson-version}</bundle>
+ <bundle>mvn:org.apache.activemq/activemq-jaas/${activemq-version}</bundle>
+
<bundle>wrap:mvn:org.jasypt/jasypt/${jasypt-version}</bundle>
- <bundle>wrap:mvn:org.apache.activemq/activemq-jaas/${activemq-version}</bundle>
<bundle>wrap:mvn:org.yaml/snakeyaml/${snakeyaml-version}</bundle>
+
+ <!-- These could be optional.. but lets just default it to simplify -->
+ <bundle>mvn:org.apache.activemq/apollo-tcp/${pom.version}</bundle>
+ <bundle>mvn:org.apache.activemq/apollo-stomp/${pom.version}</bundle>
+
</feature>
- <!-- optional stores -->
+ <!-- optional features -->
<feature name='apollo-jdbm' version='${pom.version}'>
- <feature version='${pom.version}'>apollo-broker</feature>
- <bundle>wrap:mvn:org.apache.activemq/apollo-jdbm2/${pom.version}</bundle>
+ <bundle>mvn:org.apache.activemq/apollo-jdbm2/${pom.version}</bundle>
+ <bundle>mvn:org.fusesource.jdbm/jdbm/${jdbm-version}</bundle>
</feature>
+
<feature name='apollo-bdb' version='${pom.version}'>
- <feature version='${pom.version}'>apollo-broker</feature>
- <bundle>wrap:mvn:org.apache.activemq/apollo-bdb/${pom.version}</bundle>
- </feature>
-
- <!-- optional transports -->
- <feature name='apollo-tcp' version='${pom.version}'>
- <feature version='${pom.version}'>apollo-broker</feature>
- <bundle>mvn:org.apache.activemq/apollo-tcp/${pom.version}</bundle>
- </feature>
-
- <!-- optional protocols -->
- <feature name='apollo-stomp' version='${pom.version}'>
- <feature version='${pom.version}'>apollo-tcp</feature>
- <bundle>mvn:org.apache.activemq/apollo-stomp/${pom.version}</bundle>
+ <feature version='${pom.version}'>apollo</feature>
+ <bundle>mvn:org.apache.activemq/apollo-bdb/${pom.version}</bundle>
+ <bundle>wrap:mvn:com.sleepycat/je/${bdb-version}</bundle>
</feature>
- <!-- optional web admin -->
<feature name='apollo-web' version='${pom.version}'>
- <feature version='${pom.version}'>apollo-broker</feature>
+ <feature version='${pom.version}'>apollo</feature>
<bundle>mvn:org.apache.activemq/apollo-web/${pom.version}/slim</bundle>
<bundle>mvn:org.apache.activemq/apollo-web/${pom.version}/war/slim</bundle>
Copied: activemq/activemq-apollo/trunk/apollo-karaf/pom.xml (from r1065180, activemq/activemq-apollo/trunk/apollo-bdb/pom.xml)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-karaf/pom.xml?p2=activemq/activemq-apollo/trunk/apollo-karaf/pom.xml&p1=activemq/activemq-apollo/trunk/apollo-bdb/pom.xml&r1=1065180&r2=1065181&rev=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-bdb/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-karaf/pom.xml Sun Jan 30 04:07:31 2011
@@ -15,57 +15,42 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
<parent>
<groupId>org.apache.activemq</groupId>
<artifactId>apollo-scala</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../apollo-scala</relativePath>
</parent>
-
+
<groupId>org.apache.activemq</groupId>
- <artifactId>apollo-bdb</artifactId>
+ <artifactId>apollo-karaf</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
-
+
<name>${project.artifactId}</name>
+ <description>Karaf Integration</description>
- <dependencies>
-
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>apollo-broker</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>com.sleepycat</groupId>
- <artifactId>je</artifactId>
- <version>${bdb-version}</version>
- </dependency>
+ <properties>
+ <!--<apollo.osgi.activator>org.apache.activemq.apollo.broker.osgi.BrokerService</apollo.osgi.activator>-->
+ </properties>
+ <dependencies>
- <!-- Since we implement a jade template to display the BDB status -->
<dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>apollo-web</artifactId>
- <version>1.0-SNAPSHOT</version>
- <type>jar</type>
- <classifier>slim</classifier>
- <optional>true</optional>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${osgi-version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>${servlet-api-version}</version>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>${osgi-version}</version>
<scope>provided</scope>
</dependency>
- <!-- Scala Support -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
@@ -79,61 +64,31 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
-
- <!-- Testing Dependencies -->
- <dependency>
- <groupId>org.scalatest</groupId>
- <artifactId>scalatest</artifactId>
- <version>${scalatest-version}</version>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>apollo-broker</artifactId>
+ <artifactId>apollo-stomp</artifactId>
<version>1.0-SNAPSHOT</version>
- <type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>apollo-util</artifactId>
+ <artifactId>apollo-jdbm2</artifactId>
<version>1.0-SNAPSHOT</version>
- <type>test-jar</type>
- <scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- <version>${junit-version}</version>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all-server</artifactId>
+ <version>${jetty-version}</version>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>${slf4j-version}</version>
- <scope>test</scope>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-web</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <type>jar</type>
+ <classifier>slim</classifier>
</dependency>
-
+
</dependencies>
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.fusesource.scalate</groupId>
- <artifactId>maven-scalate-plugin</artifactId>
- <version>${scalate-version}</version>
- <executions>
- <execution>
- <goals>
- <goal>precompile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-
</project>
Added: activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/OSGI-INF/blueprint/broker.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/OSGI-INF/blueprint/broker.xml?rev=1065181&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/OSGI-INF/blueprint/broker.xml (added)
+++ activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/OSGI-INF/blueprint/broker.xml Sun Jan 30 04:07:31 2011
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<blueprint
+ xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+ xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
+
+ <cm:property-placeholder persistent-id="org.apache.activemq.apollo" update-strategy="reload">
+ <cm:default-properties>
+ <cm:property name="apollo.base" value="."/>
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <reference id="configAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
+
+ <bean id="broker" class="org.apache.activemq.apollo.karaf.BrokerService"
+ init-method="start" destroy-method="stop">
+ <property name="context" ref="blueprintBundleContext"/>
+ <property name="basedir" value="${apollo.base}"/>
+ <property name="configAdmin" ref="configAdmin"/>
+ </bean>
+
+
+</blueprint>
\ No newline at end of file
Copied: activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/features.xml (from r1065180, activemq/activemq-apollo/trunk/apollo-karaf-feature/src/main/resources/features.xml)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/features.xml?p2=activemq/activemq-apollo/trunk/apollo-karaf/src/main/resources/features.xml&p1=activemq/activemq-apollo/trunk/apollo-karaf-feature/src/main/resources/features.xml&r1=1065180&r2=1065181&rev=1065181&view=diff
==============================================================================
(empty)
Added: activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/apache/activemq/apollo/karaf/BrokerService.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/apache/activemq/apollo/karaf/BrokerService.scala?rev=1065181&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/apache/activemq/apollo/karaf/BrokerService.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-karaf/src/main/scala/org/apache/activemq/apollo/karaf/BrokerService.scala Sun Jan 30 04:07:31 2011
@@ -0,0 +1,170 @@
+/**
+ * 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.karaf
+
+import org.osgi.framework._
+import java.net.URL
+import org.apache.activemq.apollo.broker.{Broker, ConfigStore, FileConfigStore}
+import org.fusesource.hawtdispatch._
+import org.apache.activemq.apollo.util.FileSupport._
+import java.lang.{Class, String}
+import scala.reflect.BeanProperty
+import org.apache.activemq.apollo.dto.{XmlCodec, BrokerDTO}
+import java.io.{FileInputStream, File}
+import org.osgi.service.cm.ConfigurationAdmin
+import java.util.{Properties, Enumeration}
+import org.apache.activemq.apollo.broker.security.EncryptionSupport
+import collection.JavaConversions._
+import org.apache.activemq.apollo.util.{ServiceControl, Log, LoggingReporter}
+
+class BrokerService extends Log {
+
+ @BeanProperty
+ var context: BundleContext = _
+
+ @BeanProperty
+ var basedir: File = _
+
+ @BeanProperty
+ var config:BrokerDTO = _
+
+ @BeanProperty
+ var configAdmin:ConfigurationAdmin = _
+
+ var broker:Broker = _
+
+ def start(): Unit = this.synchronized {
+ try {
+
+ // this makes jaxb happy
+ Thread.currentThread().setContextClassLoader(JaxbClassLoader(context))
+
+ // in case the config gets injected.
+ if( config == null ) {
+
+ // val base = system_dir("apollo.base")
+ val apollo_xml = basedir / "etc" / "apollo.xml"
+
+ if (!apollo_xml.exists) {
+ error("Apollo configuration file'%s' does not exist.".format(apollo_xml));
+ return;
+ }
+
+ // Load the configs and start the brokers up.
+ info("Loading configuration file '%s'.", apollo_xml);
+
+ val props = new Properties()
+ props.putAll(System.getProperties)
+ props.put("apollo.base", basedir.getCanonicalPath)
+ val cmProps = configAdmin.getConfiguration("org.apache.activemq.apollo").getProperties
+ if( cmProps!=null ) {
+ cmProps.keySet.foreach { key =>
+ props.put(key.asInstanceOf[String], cmProps.get(key).asInstanceOf[String])
+ }
+ }
+ config = XmlCodec.unmarshalBrokerDTO(new FileInputStream(apollo_xml), props)
+ }
+
+ debug("Starting broker");
+ broker = new Broker()
+ broker.configure(config, LoggingReporter(this))
+ broker.tmp = basedir / "tmp"
+ broker.tmp.mkdirs
+ broker.start(^{
+ info("Apollo started");
+ })
+
+ } catch {
+ case e: Throwable =>
+ error(e)
+ }
+ }
+
+ def stop(): Unit = this.synchronized {
+ if( broker!=null ) {
+ ServiceControl.stop(broker, "Apollo shutdown")
+ info("Apollo stopped");
+ }
+ }
+
+}
+
+// We need to setup a context class loader because apollo allows
+// optional/plugin modules to dynamically add to the JAXB context.
+case class JaxbClassLoader(context: BundleContext) extends ClassLoader(classOf[JaxbClassLoader].getClassLoader) {
+
+ def wait_for_start(bundle:Bundle):Option[Bundle] = {
+ var i=0
+ while(true) {
+ i+=1
+ bundle.getState match {
+ case Bundle.UNINSTALLED=> return None
+ case Bundle.RESOLVED=> return Some(bundle)
+ case Bundle.ACTIVE=> return Some(bundle)
+ case _ =>
+ Thread.sleep(100)
+ if( (i%50)==0 ) {
+ println("Waiting on bundle: "+bundle.getSymbolicName);
+ }
+ }
+ }
+ None
+ }
+
+ val bundles = context.getBundles.flatMap { bundle =>
+ if (bundle.getEntry("META-INF/services/org.apache.activemq.apollo/xml-packages.index")!=null ) {
+ wait_for_start(bundle)
+ } else {
+ None
+ }
+ }
+
+ override def findClass(name: String): Class[_] = {
+ // try to find the class in one of the bundles.
+ bundles.foreach{ bundle:Bundle =>
+ try {
+ return bundle.loadClass(name)
+ } catch {
+ case e:ClassNotFoundException => // ignore.
+ }
+ }
+ super.findClass(name)
+ }
+
+ override def findResource(name: String): URL = {
+ bundles.foreach{ bundle =>
+ val rc = bundle.getResource(name)
+ if( rc!=null ) {
+ return rc
+ }
+ }
+ null
+ }
+
+ override def findResources(name: String): Enumeration[URL] = {
+ val list = new java.util.Vector[URL]
+ bundles.foreach{ bundle =>
+ val rc = bundle.getResources(name)
+ if( rc!=null ) {
+ rc.foreach{ x=>
+ list.add( x.asInstanceOf[URL] )
+ }
+ }
+ }
+ list.elements
+ }
+}
\ No newline at end of file
Modified: activemq/activemq-apollo/trunk/apollo-stomp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/pom.xml Sun Jan 30 04:07:31 2011
@@ -33,6 +33,9 @@
<packaging>bundle</packaging>
<name>${project.artifactId}</name>
+ <properties>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
+ </properties>
<dependencies>
@@ -84,18 +87,6 @@
<scope>test</scope>
</dependency>
- <!--<dependency>-->
- <!--<groupId>org.apache.activemq</groupId>-->
- <!--<artifactId>apollo-cassandra</artifactId>-->
- <!--<version>1.0-SNAPSHOT</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>apollo-hawtdb</artifactId>
- <version>1.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>apollo-bdb</artifactId>
Modified: activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/perf/StompBrokerPerfTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/perf/StompBrokerPerfTest.scala?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/perf/StompBrokerPerfTest.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/perf/StompBrokerPerfTest.scala Sun Jan 30 04:07:31 2011
@@ -20,20 +20,11 @@ import _root_.org.apache.activemq.apollo
import java.io.File
import org.apache.activemq.apollo.dto.BrokerDTO
import org.apache.activemq.apollo.broker.store.bdb.dto.BDBStoreDTO
-import org.apache.activemq.apollo.broker.store.hawtdb.dto.HawtDBStoreDTO
class BasicNonPersistentTest extends BasicScenarios with StompScenario {
override def description = "Using the STOMP protocol over TCP"
}
-class BasicHawtDBTest extends BasicScenarios with PersistentScenario with HawtDBScenario with StompScenario {
- override def description = "Using the STOMP protocol over TCP persistent to the HawtDB store"
-}
-
-class DeepQueueHawtDBTest extends BasicScenarios with LargeInitialDB with HawtDBScenario with StompScenario {
- override def description = "Using the STOMP protocol over TCP persisting to the HawtDB store that contains 1M messages in a queue."
-}
-
class BasicBDBTest extends BasicScenarios with PersistentScenario with BDBScenario with StompScenario {
override def description = "Using the STOMP protocol over TCP persistent to the BerkleyDB store"
}
@@ -50,17 +41,6 @@ trait StompScenario extends BrokerPerfSu
override def getRemoteProtocolName() = "stomp"
}
-trait HawtDBScenario extends PersistentScenario {
- override def createBrokerConfig(name: String, bindURI: String, connectUri: String): BrokerDTO = {
- val rc = super.createBrokerConfig(name, bindURI, connectUri)
- val store = new HawtDBStoreDTO
- storeDirectory = new File(new File(test_data_dir, getClass.getName), name)
- store.directory = storeDirectory
- rc.virtual_hosts.get(0).store = store
- rc
- }
-}
-
trait BDBScenario extends PersistentScenario {
override def createBrokerConfig(name: String, bindURI: String, connectUri: String): BrokerDTO = {
val rc = super.createBrokerConfig(name, bindURI, connectUri)
Modified: activemq/activemq-apollo/trunk/apollo-tcp/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-tcp/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-tcp/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-tcp/pom.xml Sun Jan 30 04:07:31 2011
@@ -32,6 +32,9 @@
<packaging>bundle</packaging>
<name>${project.artifactId}</name>
+ <properties>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
+ </properties>
<dependencies>
Modified: activemq/activemq-apollo/trunk/apollo-transport/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-transport/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-transport/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-transport/pom.xml Sun Jan 30 04:07:31 2011
@@ -34,7 +34,7 @@
<name>${project.artifactId}</name>
<properties>
- <apollo.osgi.host></apollo.osgi.host>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderExportingActivator</apollo.osgi.activator>
</properties>
<dependencies>
Modified: activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/DiscoveryAgentFactory.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/DiscoveryAgentFactory.java?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/DiscoveryAgentFactory.java (original)
+++ activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/DiscoveryAgentFactory.java Sun Jan 30 04:07:31 2011
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.apollo.transport;
-import org.apache.activemq.apollo.util.JavaClassFinder;
+import org.apache.activemq.apollo.util.ClassFinder;
import java.util.List;
@@ -26,18 +26,13 @@ public class DiscoveryAgentFactory {
public DiscoveryAgent create(String uri) throws Exception;
}
- static public List<Provider> providers;
-
- static {
- JavaClassFinder<Provider> finder = new JavaClassFinder<Provider>("META-INF/services/org.apache.activemq.apollo/discovery-agent-factory.index");
- providers = finder.new_instances();
- }
+ public static final ClassFinder<Provider> providers = new ClassFinder<Provider>("META-INF/services/org.apache.activemq.apollo/discovery-agent-factory.index", Provider.class);
/**
* Creates a DiscoveryAgent
*/
public static DiscoveryAgent create(String uri) throws Exception {
- for( Provider provider : providers) {
+ for( Provider provider : providers.jsingletons()) {
DiscoveryAgent rc = provider.create(uri);
if( rc!=null ) {
return rc;
Modified: activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/ProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/ProtocolCodecFactory.java?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/ProtocolCodecFactory.java (original)
+++ activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/ProtocolCodecFactory.java Sun Jan 30 04:07:31 2011
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.apollo.transport;
-import org.apache.activemq.apollo.util.JavaClassFinder;
+import org.apache.activemq.apollo.util.ClassFinder;
import org.fusesource.hawtbuf.Buffer;
import java.util.HashMap;
@@ -57,20 +57,17 @@ public class ProtocolCodecFactory {
}
- static public HashMap<String, Provider> providers = new HashMap<String, Provider>();
-
- static {
- JavaClassFinder<Provider> finder = new JavaClassFinder<Provider>("META-INF/services/org.apache.activemq.apollo/protocol-codec-factory.index");
- for( Provider provider: finder.new_instances() ) {
- providers.put(provider.protocol(), provider);
- }
- }
-
+ public static final ClassFinder<Provider> providers = new ClassFinder<Provider>("META-INF/services/org.apache.activemq.apollo/protocol-codec-factory.index", Provider.class);
/**
* Gets the provider.
*/
public static ProtocolCodecFactory.Provider get(String name) {
- return providers.get(name);
+ for( Provider provider: providers.jsingletons() ) {
+ if( name.equals(provider.protocol()) ) {
+ return provider;
+ }
+ }
+ return null;
}
Modified: activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/TransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/TransportFactory.java?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/TransportFactory.java (original)
+++ activemq/activemq-apollo/trunk/apollo-transport/src/main/java/org/apache/activemq/apollo/transport/TransportFactory.java Sun Jan 30 04:07:31 2011
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.apollo.transport;
-import org.apache.activemq.apollo.util.JavaClassFinder;
+import org.apache.activemq.apollo.util.ClassFinder;
import java.util.List;
@@ -31,18 +31,13 @@ public class TransportFactory {
public Transport connect(String location) throws Exception;
}
- static public List<Provider> providers;
-
- static {
- JavaClassFinder<Provider> finder = new JavaClassFinder<Provider>("META-INF/services/org.apache.activemq.apollo/transport-factory.index");
- providers = finder.new_instances();
- }
+ public static final ClassFinder<Provider> providers = new ClassFinder<Provider>("META-INF/services/org.apache.activemq.apollo/transport-factory.index", Provider.class);
/**
* Creates a client transport.
*/
public static Transport connect(String location) throws Exception {
- for( Provider provider : providers) {
+ for( Provider provider : providers.jsingletons()) {
Transport rc = provider.connect(location);
if( rc!=null ) {
return rc;
@@ -55,7 +50,7 @@ public class TransportFactory {
* Creates a transport server.
*/
public static TransportServer bind(String location) throws Exception {
- for( Provider spi : providers) {
+ for( Provider spi : providers.jsingletons()) {
TransportServer rc = spi.bind(location);
if( rc!=null ) {
return rc;
Modified: activemq/activemq-apollo/trunk/apollo-util/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-util/pom.xml Sun Jan 30 04:07:31 2011
@@ -35,7 +35,7 @@
<name>${project.artifactId}</name>
<properties>
- <apollo.osgi.host></apollo.osgi.host>
+ <apollo.osgi.activator>org.apache.activemq.apollo.util.ClassFinderImportingActivator</apollo.osgi.activator>
</properties>
<repositories>
@@ -87,7 +87,14 @@
<version>3.1.0</version>
<optional>true</optional>
</dependency>
-
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinder.scala Sun Jan 30 04:07:31 2011
@@ -19,97 +19,65 @@ package org.apache.activemq.apollo.util
import java.io.InputStream
import java.util.Properties
import scala.collection.mutable.ListBuffer
-import java.net.URL
+import collection.JavaConversions._
object ClassFinder extends Log {
trait Loader {
- def getResources(path:String):java.util.Enumeration[URL]
- def loadClass(name:String):Class[_]
+ def discover[T](path:String, clazz: Class[T])( callback: List[T]=>Unit )
}
- case class ClassLoaderLoader(cl:ClassLoader) extends Loader {
- def getResources(path:String) = cl.getResources(path)
- def loadClass(name:String) = cl.loadClass(name)
- }
-
- def standalone_loader():Array[Loader] = {
- Array(ClassLoaderLoader(Thread.currentThread.getContextClassLoader))
- }
-
- var default_loaders = ()=>standalone_loader
-}
-
-import ClassFinder._
-
-
-/**
- * <p>
- * Used to discover classes using the META-INF discovery trick.
- * </p>
- *
- * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
- */
-class ClassFinder[T](val path:String, val loaders: ()=>Array[Loader]) {
-
- def this(path:String) = this(path, default_loaders)
-// def this(path:String, loaders:Array[ClassLoader]) = this(path, ()=>{loaders.map(ClassLoaderLoader _) })
-
- def findArray(): Array[Class[T]] = find.toArray
-
- def find(): List[Class[T]] = {
- var classes = List[Class[T]]()
- loaders().foreach { loader=>
-
- val resources = loader.getResources(path)
- var classNames: List[String] = Nil
- while(resources.hasMoreElements) {
- val url = resources.nextElement;
- val p = loadProperties(url.openStream)
- val enum = p.keys
- while (enum.hasMoreElements) {
- classNames = classNames ::: enum.nextElement.asInstanceOf[String] :: Nil
+ case class ClassLoaderLoader(loaders: Seq[ClassLoader]) extends Loader {
+ def discover[T](path: String, clazz: Class[T])(callback: (List[T]) => Unit) = {
+ val classes = ListBuffer[Class[_]]()
+ loaders.foreach { loader=>
+ val resources = loader.getResources(path)
+ val classNames = ListBuffer[String]()
+ while(resources.hasMoreElements) {
+ val p = loadProperties(resources.nextElement.openStream)
+ p.keys.foreach { next =>
+ classNames += next.asInstanceOf[String]
+ }
+ }
+ classNames.distinct.foreach { name=>
+ try {
+ classes += loader.loadClass(name)
+ } catch {
+ case e:Throwable =>
+ debug(e, "Could not load class %s", name)
+ }
}
}
- classNames = classNames.distinct
+ val singltons = classes.flatMap(x=> instantiate(clazz, x) ).distinct
+ callback( singltons.toList )
+ }
+ }
- classes :::= classNames.flatMap { name=>
+ def instantiate[T](target:Class[T], clazz:Class[_]) = {
+ try {
+ Some(target.cast(clazz.newInstance))
+ } catch {
+ case e: Throwable =>
+ // It may be a scala object.. check for a module class
try {
- Some(loader.loadClass(name).asInstanceOf[Class[T]])
+ val moduleField = clazz.getClassLoader.loadClass(clazz.getName + "$").getDeclaredField("MODULE$")
+ Some(moduleField.get(null).asInstanceOf[T])
} catch {
- case e:Throwable =>
- debug(e, "Could not load class %s", name)
+ case e2: Throwable =>
+ debug(e, "Could create an instance of the class")
None
}
- }
}
-
- return classes.distinct
}
- def new_instances() = {
- val t = ListBuffer[T]()
- find.foreach {clazz =>
- try {
- t += clazz.newInstance.asInstanceOf[T]
- } catch {
- case e: Throwable =>
- // It may be a scala object.. check for a module class
- try {
- val moduleField = clazz.getClassLoader.loadClass(clazz.getName + "$").getDeclaredField("MODULE$")
- val instance = moduleField.get(null).asInstanceOf[T]
- t += instance
- } catch {
- case e2: Throwable =>
- debug(e, "Could not load the class")
- }
- }
- }
- t.toList
+ def standalone_loader() = {
+ ClassLoaderLoader(Array(Thread.currentThread.getContextClassLoader))
}
- private def loadProperties(is:InputStream):Properties = {
+ var default_loader:Loader = standalone_loader
+
+ def loadProperties(is:InputStream):Properties = {
if( is==null ) {
return null;
}
@@ -128,4 +96,35 @@ class ClassFinder[T](val path:String, va
}
}
}
+}
+
+
+
+/**
+ * <p>
+ * Used to discover classes using the META-INF discovery trick.
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+class ClassFinder[T](val path:String, val clazz: Class[T]) {
+
+ import ClassFinder._
+
+ @volatile
+ var singletons = List[T]()
+ var on_change = ()=>{}
+
+ var loader:Loader=default_loader
+
+ loader.discover(path, clazz) { x=>
+ singletons = x
+ on_change()
+ }
+
+ def jsingletons = {
+ import collection.JavaConversions._
+ asJavaList(singletons)
+ }
+
}
\ No newline at end of file
Added: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinderActivator.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinderActivator.scala?rev=1065181&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinderActivator.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/ClassFinderActivator.scala Sun Jan 30 04:07:31 2011
@@ -0,0 +1,173 @@
+/**
+ * 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.util
+
+import org.osgi.framework._
+import java.lang.String
+import java.lang.ref._
+import java.lang.ref.WeakReference
+import collection.JavaConversions._
+import scala.collection.mutable.ListBuffer
+import java.util.Properties
+
+/**
+ * An OSGi bundle activator for Apollo which tracks Apollo extension
+ * modules.
+ */
+object ClassFinderImportingActivator extends Log with ClassFinder.Loader {
+
+ private var bundleContext: BundleContext = null
+
+ case class DiscoverRequest[T](path: String, clazz: Class[T], callback: (List[T]) => Unit)
+
+ //
+ // Used the track the GC's of the DiscoverRequests
+ //
+ val queue = new ReferenceQueue[DiscoverRequest[_]]()
+
+ //
+ // A service listener which un-registers when the DiscoverRequest gets GCed.
+ //
+ class DiscoverServiceListener[T](request:DiscoverRequest[T]) extends WeakReference[DiscoverRequest[T]](request, queue) with org.osgi.framework.ServiceListener {
+ val path = request.path
+ var classes = Set[T]()
+
+ def serviceChanged(event: ServiceEvent): Unit = this.synchronized {
+ val request = get
+ if( request==null ) {
+ dain_queue
+ return;
+ }
+
+ val found = cast(request, event.getServiceReference).getOrElse(return)
+
+ val original_size = classes.size
+ if( event.getType == ServiceEvent.UNREGISTERING ) {
+ classes -= found
+ } else {
+ classes += found
+ }
+
+ // if the set changed, then notify the callback.
+ if( original_size!= classes.size) {
+ request.callback(classes.toList)
+ }
+ }
+
+ this.synchronized {
+ bundleContext.addServiceListener(this, filter)
+ classes = Option(bundleContext.getServiceReferences(null, filter)).getOrElse(Array()).flatMap { ref =>
+ cast(request, ref)
+ }.toSet
+ request.callback(classes.toList)
+ }
+
+
+ def filter: String = "(finder_resource=" + path + ")"
+
+ def cast(request:DiscoverRequest[T], ref:ServiceReference):Option[T] = {
+ try {
+ Some(request.clazz.cast(bundleContext.getService(ref)))
+ } catch {
+ case _ => None
+ }
+ }
+
+ }
+
+
+ def dain_queue:Unit = {
+ var rc = queue.poll
+ while( rc!=null ) {
+ val dsl: DiscoverServiceListener[_] = rc.asInstanceOf[DiscoverServiceListener[_]]
+ bundleContext.removeServiceListener(dsl)
+ rc = queue.poll
+ }
+ }
+
+
+ def discover[T](path: String, clazz: Class[T])(callback: (List[T]) => Unit) = {
+ dain_queue
+ new DiscoverServiceListener(DiscoverRequest(path, clazz, callback))
+ }
+
+ // Change the default loaders used by the ClassFinder so
+ // that it can find classes using osgi
+ ClassFinder.default_loader = ClassFinderImportingActivator
+
+}
+
+class ClassFinderImportingActivator extends BundleActivator {
+
+ import ClassFinderImportingActivator._
+
+ def start(bc: BundleContext): Unit = this.synchronized{
+ debug("activating")
+ bundleContext = bc
+ debug("activated")
+ }
+
+ def stop(bc: BundleContext): Unit = this.synchronized{
+ debug("deactivating")
+
+ bundleContext = null
+ debug("deactivated")
+ }
+
+}
+object ClassFinderExportingActivator extends Log
+
+class ClassFinderExportingActivator extends BundleActivator {
+
+ import ClassFinderExportingActivator._
+
+ var service_path_base = "META-INF/services/org.apache.activemq.apollo/"
+
+ def start(bc: BundleContext): Unit = this.synchronized{
+ val bundle = bc.getBundle
+ val paths = bundle.getEntryPaths(service_path_base)
+
+ if( paths!=null ){
+ paths.foreach { case path:String =>
+ if(!path.endsWith("/xml-packages.index")) {
+ val url = bundle.getEntry(path)
+ val classNames = ListBuffer[String]()
+ val p = ClassFinder.loadProperties(url.openStream)
+ p.keys.foreach { next=>
+ classNames += next.asInstanceOf[String]
+ }
+
+ classNames.distinct.foreach { name=>
+ try {
+ ClassFinder.instantiate(classOf[Object], bundle.loadClass(name)).foreach { service =>
+ val p = new Properties
+ p.put("finder_resource", path)
+ bc.registerService(service.getClass.getName, service, p)
+ }
+ } catch {
+ case e:Throwable =>
+ debug(e, "Could not load class %s", name)
+ }
+ }
+ }
+ }
+ }
+ }
+
+ def stop(bc: BundleContext): Unit = this.synchronized{
+ }
+}
\ No newline at end of file
Modified: activemq/activemq-apollo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/pom.xml?rev=1065181&r1=1065180&r2=1065181&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/pom.xml (original)
+++ activemq/activemq-apollo/trunk/pom.xml Sun Jan 30 04:07:31 2011
@@ -96,10 +96,10 @@
<xbean-version>3.4</xbean-version>
<felix-version>1.0.0</felix-version>
- <hawtdispatch-version>1.1</hawtdispatch-version>
- <hawtbuf-version>1.3</hawtbuf-version>
+ <hawtdispatch-version>1.2-SNAPSHOT</hawtdispatch-version>
+ <hawtbuf-version>1.4-SNAPSHOT</hawtbuf-version>
- <jdbm-version>2.0.0</jdbm-version>
+ <jdbm-version>2.0.1-SNAPSHOT</jdbm-version>
<bdb-version>4.1.6</bdb-version>
<jasypt-version>1.6</jasypt-version>
@@ -112,9 +112,6 @@
<jersey-version>1.5-ea03</jersey-version>
<snakeyaml-version>1.7</snakeyaml-version>
- <karaf-version>2.1.99-SNAPSHOT</karaf-version>
- <features-maven-plugin-version>2.1.0</features-maven-plugin-version>
-
<!-- maven plugin versions -->
<maven-scala-plugin-version>2.15.0</maven-scala-plugin-version>
<maven-surefire-plugin-version>2.4.3</maven-surefire-plugin-version>
@@ -126,6 +123,10 @@
<cascal-version>1.3-SNAPSHOT</cascal-version>
<hawtdb-version>1.6-SNAPSHOT</hawtdb-version>
+ <!-- osgi stuff -->
+ <osgi-version>4.2.0</osgi-version>
+ <karaf-version>2.1.2</karaf-version>
+ <features-maven-plugin-version>2.1.0</features-maven-plugin-version>
<maven-bundle-plugin-version>2.3.0-SNAPSHOT</maven-bundle-plugin-version>
<apollo.osgi.export.pkg>{local-packages}</apollo.osgi.export.pkg>
<apollo.osgi.name>${project.groupId}.${project.artifactId}</apollo.osgi.name>
@@ -133,8 +134,8 @@
<apollo.osgi.export>${apollo.osgi.export.pkg};version=${project.version};-noimport:=true</apollo.osgi.export>
<apollo.osgi.private>!*</apollo.osgi.private>
<apollo.osgi.dynamic></apollo.osgi.dynamic>
- <apollo.osgi.host>org.apache.activemq.apollo-broker</apollo.osgi.host>
-
+ <apollo.osgi.host></apollo.osgi.host>
+ <apollo.osgi.activator></apollo.osgi.activator>
</properties>
<prerequisites>
@@ -175,6 +176,7 @@
<module>apollo-cli</module>
<module>apollo-website</module>
<module>apollo-distro</module>
+ <module>apollo-karaf</module>
</modules>
<scm>
@@ -395,6 +397,7 @@
<Fragment-Host>${apollo.osgi.host}</Fragment-Host>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-SymbolicName>${apollo.osgi.name}</Bundle-SymbolicName>
+ <Bundle-Activator>${apollo.osgi.activator}</Bundle-Activator>
<Export-Package>${apollo.osgi.export}</Export-Package>
<Import-Package>${apollo.osgi.import}</Import-Package>
<Private-Package>${apollo.osgi.private}</Private-Package>