activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r961099 - in /activemq/sandbox/activemq-apollo-actor: ./ activemq-jaxb/ activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/ activemq-jaxb/src/main/scala/ activemq-jaxb/src/main/scala/org/ activemq-jaxb/src/main/scala/org/apache/ ac...
Date Wed, 07 Jul 2010 03:53:57 GMT
Author: chirino
Date: Wed Jul  7 03:53:56 2010
New Revision: 961099

URL: http://svn.apache.org/viewvc?rev=961099&view=rev
Log:
converting jaxb module to scala

Added:
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/AsciiBufferAdapter.java
      - copied, changed from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/AsciiBufferAdapter.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/BrokerConfig.java
      - copied, changed from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/KahaDBStoreConfig.java
      - copied, changed from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/KahaDBStoreXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/MemoryStoreConfig.java
      - copied, changed from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/MemoryStoreXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/PropertiesReader.java
      - copied, changed from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/PropertiesReader.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/StoreXml.java
      - copied, changed from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/StoreXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/VirtualHostConfig.java
      - copied, changed from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/VirtualHostXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/XmlBrokerFactory.scala
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/package-info.java
      - copied, changed from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/package-info.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/org/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/org/apache/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/org/apache/activemq/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/org/apache/activemq/apollo/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/org/apache/activemq/apollo/jaxb/
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
      - copied, changed from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
Removed:
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/AsciiBufferAdapter.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/JAXBBrokerFactory.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/KahaDBStoreXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/MemoryStoreXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/PropertiesReader.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/StoreXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/VirtualHostXml.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/package-info.java
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-jaxb/pom.xml
    activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala
    activemq/sandbox/activemq-apollo-actor/pom.xml

Modified: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/pom.xml?rev=961099&r1=961098&r2=961099&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/pom.xml (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/pom.xml Wed Jul  7 03:53:56 2010
@@ -20,7 +20,7 @@
 
   <parent>
     <groupId>org.apache.activemq</groupId>
-    <artifactId>activemq-project</artifactId>
+    <artifactId>activemq-scala</artifactId>
     <version>6.0-SNAPSHOT</version>
   </parent>
 
@@ -68,6 +68,21 @@
       <version>4.0.0</version>
     </dependency>
 
+    <!-- Scala Support -->
+    <dependency>
+      <groupId>org.scala-lang</groupId>
+      <artifactId>scala-library</artifactId>
+      <scope>compile</scope>
+      <version>${scala-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.scala-lang</groupId>
+      <artifactId>scala-compiler</artifactId>
+      <version>${scala-version}</version>
+      <scope>compile</scope>
+      <optional>true</optional>
+    </dependency>
+
     <!-- Testing Dependencies -->    
     <dependency>
       <groupId>junit</groupId>
@@ -76,12 +91,17 @@
       <version>${junit-version}</version>
     </dependency>
     <dependency>
+      <groupId>org.scalatest</groupId>
+      <artifactId>scalatest</artifactId>
+      <version>${scalatest-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
       <scope>test</scope>
       <version>${log4j-version}</version>
     </dependency>
-
   </dependencies>
 
   <build>

Copied: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/AsciiBufferAdapter.java
(from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/AsciiBufferAdapter.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/AsciiBufferAdapter.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/AsciiBufferAdapter.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/AsciiBufferAdapter.java&r1=961098&r2=961099&rev=961099&view=diff
==============================================================================
    (empty)

Copied: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/BrokerConfig.java
(from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/BrokerConfig.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/BrokerConfig.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java&r1=961098&r2=961099&rev=961099&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/BrokerXml.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/BrokerConfig.java
Wed Jul  7 03:53:56 2010
@@ -25,65 +25,28 @@ import javax.xml.bind.annotation.XmlAttr
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.apache.activemq.apollo.broker.Broker;
-import org.apache.activemq.transport.TransportFactory;
-import org.apache.activemq.transport.TransportServer;
-
 @XmlRootElement(name="broker")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class BrokerXml {
+public class BrokerConfig {
 	
 	@XmlAttribute(name="name")
-	String name;
+	public String name;
 	
     @XmlElement(name="virtual-host")
-    private List<VirtualHostXml> virtualHosts = new ArrayList<VirtualHostXml>();
+    public List<VirtualHostConfig> virtualHosts = new ArrayList<VirtualHostConfig>();
     @XmlElement(name="transport-server")
-    private List<String> transportServers = new ArrayList<String>();
+    public List<String> transportServers = new ArrayList<String>();
     @XmlElement(name="connect-uri")
-    private List<String> connectUris = new ArrayList<String>();
-
-
-    public BrokerXml() {
-    }
-
-    public BrokerXml(Broker broker) {
-    }
-
+    public List<String> connectUris = new ArrayList<String>();
 
-	public Broker createMessageBroker() throws Exception {
-		Broker rc = new Broker();
-		for (VirtualHostXml element : virtualHosts) {
-			rc.addVirtualHost(element.createVirtualHost(this));
-		}
-		for (String element : transportServers) {
-			TransportServer server;
-			try {
-				server = TransportFactory.bind(element);
-			} catch (Exception e) {
-				throw new Exception("Unable to bind transport server '"+element+" due to: "+e.getMessage(),
e);
-			}
-			rc.transportServers().add(server);
-		}
-		for (String element : connectUris) {
-			rc.connectUris().add(element);
-		}
-		
-		return rc;
-	}
-	
-	public VirtualHostXml getDefaultVirtualHost() {
-		return null;
-	}
 
-	public List<VirtualHostXml> getVirtualHosts() {
+	public List<VirtualHostConfig> getVirtualHosts() {
 		return virtualHosts;
 	}
-	public void setVirtualHosts(List<VirtualHostXml> virtualHosts) {
+	public void setVirtualHosts(List<VirtualHostConfig> virtualHosts) {
 		this.virtualHosts = virtualHosts;
 	}
 
-
 	public List<String> getTransportServers() {
 		return transportServers;
 	}
@@ -99,4 +62,11 @@ public class BrokerXml {
 		this.connectUris = connectUris;
 	}
 
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
 }

Copied: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/KahaDBStoreConfig.java
(from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/KahaDBStoreXml.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/KahaDBStoreConfig.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/KahaDBStoreConfig.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/KahaDBStoreXml.java&r1=961098&r2=961099&rev=961099&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/KahaDBStoreXml.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/KahaDBStoreConfig.java
Wed Jul  7 03:53:56 2010
@@ -28,7 +28,7 @@ import org.apache.activemq.broker.store.
 
 @XmlRootElement(name="kahadb-store")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class KahaDBStoreXml extends StoreXml {
+public class KahaDBStoreConfig extends StoreXml {
 
 	@XmlAttribute(name="checkpoint-interval", required=false)
 	private Long checkpointInterval;

Copied: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/MemoryStoreConfig.java
(from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/MemoryStoreXml.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/MemoryStoreConfig.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/MemoryStoreConfig.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/MemoryStoreXml.java&r1=961098&r2=961099&rev=961099&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/MemoryStoreXml.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/MemoryStoreConfig.java
Wed Jul  7 03:53:56 2010
@@ -25,7 +25,7 @@ import org.apache.activemq.broker.store.
 
 @XmlRootElement(name="memory-store")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class MemoryStoreXml extends StoreXml {
+public class MemoryStoreConfig extends StoreXml {
 
 	public Store createStore() {
 		return new MemoryStore();

Copied: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/PropertiesReader.java
(from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/PropertiesReader.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/PropertiesReader.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/PropertiesReader.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/PropertiesReader.java&r1=961098&r2=961099&rev=961099&view=diff
==============================================================================
    (empty)

Copied: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/StoreXml.java
(from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/StoreXml.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/StoreXml.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/StoreXml.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/StoreXml.java&r1=961098&r2=961099&rev=961099&view=diff
==============================================================================
    (empty)

Copied: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/VirtualHostConfig.java
(from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/VirtualHostXml.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/VirtualHostConfig.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/VirtualHostConfig.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/VirtualHostXml.java&r1=961098&r2=961099&rev=961099&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/VirtualHostXml.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/VirtualHostConfig.java
Wed Jul  7 03:53:56 2010
@@ -29,24 +29,14 @@ import org.apache.activemq.apollo.broker
 
 @XmlRootElement(name = "virtual-host")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class VirtualHostXml {
+public class VirtualHostConfig {
 	
     @XmlElement(name="host-name", required=true)
-    private ArrayList<String> hostNames = new ArrayList<String>();
+    public ArrayList<String> hostNames = new ArrayList<String>();
 
     @XmlElementRef   
-    private StoreXml store;
+    public StoreXml store;
     
-	public VirtualHost createVirtualHost(BrokerXml brokerXml) throws Exception {
-		VirtualHost rc = new VirtualHost();
-		rc.setNamesArray(hostNames);
-		if( store != null ) {
-            BrokerDatabase database = new BrokerDatabase();
-            database.setVirtualHost(rc);
-            database.setStore(store.createStore());
-            rc.setDatabase(database);
-		}
-		return rc;
-	}
+
 
 }

Added: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/XmlBrokerFactory.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/XmlBrokerFactory.scala?rev=961099&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/XmlBrokerFactory.scala
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/XmlBrokerFactory.scala
Wed Jul  7 03:53:56 2010
@@ -0,0 +1,97 @@
+/**
+ * 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.jaxb
+
+import java.io.IOException
+import javax.xml.bind.JAXBContext
+import javax.xml.stream.XMLInputFactory
+import org.apache.activemq.apollo.broker.Broker
+import org.apache.activemq.apollo.broker.BrokerDatabase
+import org.apache.activemq.apollo.broker.BrokerFactory
+import org.apache.activemq.apollo.broker.VirtualHost
+import org.apache.activemq.transport.TransportFactory
+import org.apache.activemq.util.URISupport
+import java.net.{URL, URI}
+import collection.JavaConversions._
+
+class XmlBrokerFactory extends BrokerFactory.Handler {
+  
+  def createBroker(value: String): Broker = {
+    try {
+      var brokerURI = new URI(value)
+      val context = JAXBContext.newInstance("org.apache.activemq.apollo.jaxb")
+      val unmarshaller = context.createUnmarshaller()
+
+      var configURL: URL = null
+      brokerURI = URISupport.stripScheme(brokerURI)
+      val scheme = brokerURI.getScheme()
+      if (scheme == null || "file".equals(scheme)) {
+        configURL = URISupport.changeScheme(URISupport.stripScheme(brokerURI), "file").toURL()
+      } else
+      if ("classpath".equals(scheme)) {
+        configURL = Thread.currentThread().getContextClassLoader().getResource(brokerURI.getSchemeSpecificPart())
+      } else {
+        configURL = URISupport.changeScheme(brokerURI, scheme).toURL()
+      }
+      if (configURL == null) {
+        throw new IOException("Cannot create broker from non-existent URI: " + brokerURI)
+      }
+      val factory = XMLInputFactory.newInstance()
+      val reader = factory.createXMLStreamReader(configURL.openStream())
+      val properties = new PropertiesReader(reader)
+      val xml = unmarshaller.unmarshal(properties).asInstanceOf[BrokerConfig]
+      return createMessageBroker(xml)
+    } catch {
+      case e: Exception =>
+        throw new RuntimeException("Cannot create broker from URI: " + value, e)
+    }
+  }
+
+  def createMessageBroker(brokerConfig: BrokerConfig): Broker = {
+    val rc = new Broker()
+    for (virtualHostConfig <- brokerConfig.virtualHosts) {
+      rc.addVirtualHost(createVirtualHost(virtualHostConfig))
+    }
+    for (element <- brokerConfig.transportServers) {
+      try {
+        val server = TransportFactory.bind(element)
+        rc.transportServers.add(server)
+      } catch {
+        case e:Exception=>
+          throw new Exception("Unable to bind transport server '" + element + " due to: "
+ e.getMessage(), e)
+      }
+    }
+    for (element <- brokerConfig.connectUris) {
+      rc.connectUris.add(element)
+    }
+    return rc
+  }
+
+
+  def createVirtualHost(virtualHostConfig: VirtualHostConfig): VirtualHost = {
+    val rc = new VirtualHost()
+    rc.setNamesArray(virtualHostConfig.hostNames)
+    if (virtualHostConfig.store != null) {
+      val database = new BrokerDatabase()
+      database.setVirtualHost(rc)
+//      TODO:
+//      database.setStore( )
+      rc.setDatabase(database)
+    }
+    return rc
+  }
+}

Copied: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/package-info.java
(from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/package-info.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/package-info.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/scala/org/apache/activemq/apollo/jaxb/package-info.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/main/java/org/apache/activemq/apollo/jaxb/package-info.java&r1=961098&r2=961099&rev=961099&view=diff
==============================================================================
    (empty)

Copied: activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java
(from r961098, activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/scala/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-jaxb/src/test/java/org/apache/activemq/apollo/jaxb/JAXBConfigTest.java&r1=961098&r2=961099&rev=961099&view=diff
==============================================================================
    (empty)

Modified: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala?rev=961099&r1=961098&r2=961099&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala
Wed Jul  7 03:53:56 2010
@@ -23,28 +23,33 @@ import javax.ws.rs._
 import core.MediaType
 import org.fusesource.scalate.util.Logging
 import reflect.{BeanProperty, BeanInfo}
+import org.codehaus.jackson.annotate.JsonProperty
+import com.sun.jersey.api.view.ImplicitProduces
+import org.apache.activemq.apollo.jaxb.BrokerConfig
 
 /**
  * Defines the default representations to be used on resources
  */
-//@ImplicitProduces(Array("text/html;qs=5"))
-//@Produces(Array("application/json", "application/xml","text/xml"))
-@Consumes(Array(MediaType.APPLICATION_JSON))
-@Produces(Array(MediaType.APPLICATION_JSON))
-trait Resource extends Logging
+@ImplicitProduces(Array("text/html;qs=5"))
+@Produces(Array("application/json", "application/xml","text/xml"))
+trait Resource extends Logging {
+}
 
 @Path("/")
 class Root() extends Resource {
 
+  @GET
+  def get() = this
+
   @BeanProperty
-  var brokers: Array[Broker] = List(
+  var brokers: Array[Broker] = Array(
     new Broker(this, "default"),
     new Broker(this, "example")
-  ).toArray[Broker]
+  )
 
   @Path("{id}")
   def broker(@PathParam("id") id : String): Broker = {
-    if( id == "default" ) {
+    if( id == "default" || id=="example" ) {
       new Broker(this, id)
     } else {
       throw new NotFoundException("Broker " + id + " not found")
@@ -52,64 +57,59 @@ class Root() extends Resource {
   }
 }
 
-case class Broker(parent:Root, @BeanProperty id: String) extends Resource {
-  @Path("config")
-  def config =  BrokerConfig(this, id)
+case class Broker(parent:Root, @BeanProperty @BeanProperty id: String) extends Resource {
+  @GET
+  def get():AnyRef = {
+    if( id == "default") {
+      val config = new BrokerConfig();
+      config.setName(id);
+      return config
+    } else {
+      return null;
+    }
+  }
+
   @Path("status")
   def status = BrokerStatus(this, id)
 }
 
-case class BrokerConfig(parent:Broker, @BeanProperty id:String) extends Resource {
+case class BrokerStatus(parent:Broker, @BeanProperty id:String) extends Resource {
+  @GET
+  def get() = this
 
   @Path("virtual-hosts")
-  def virtualHosts :List[VirtualHostConfig] = List(
-    new VirtualHostConfig(this, "host1"),
-    new VirtualHostConfig(this, "host2")
-  )
+  def virtualHosts :Array[VirtualHostStatus] = null
   @Path("virtual-hosts/{id}")
-  def virtualHost(@PathParam("id") id : String):VirtualHostConfig = null
-
-  @Path("connectors")
-  def connectors :List[ConnectorConfig] = null
-  @Path("connectors/{id}")
-  def connector(@PathParam("id") id : String):ConnectorConfig = null
-}
-
-case class BrokerStatus(parent:Broker, @BeanProperty id:String) extends Resource {
-  @Path("virtual-hosts")
-  def virtualHosts :List[VirtualHostStatus] = null
-  @Path("virtual-host/{id}")
   def virtualHost(@PathParam("id") id : String):VirtualHostStatus = null
 
   @Path("connectors")
-  def connectors :List[ConnectorStatus] = null
+  def connectors :Array[ConnectorStatus] = null
   @Path("connectors/{id}")
   def connector(@PathParam("id") id : String):ConnectorStatus = null
 
   @Path("connections")
-  def connections :List[ConnectionStatus] = null
+  def connections :Array[ConnectionStatus] = null
   @Path("connections/{id}")
   def connection(@PathParam("id") id : String):ConnectionStatus = null
 }
 
-case class VirtualHostConfig(parent:BrokerConfig, @BeanProperty id: String) extends Resource
{
-  var names:List[String] = null
-}
 case class VirtualHostStatus(parent:BrokerStatus, @BeanProperty id: String) extends Resource
{
   var state:String = null
+  @GET
+  def get() = this
 }
 
-case class ConnectorConfig(parent:BrokerConfig, @BeanProperty id:String) extends Resource
{
-  var uri:String = null;
-  var connect:String = null;
-}
 case class ConnectorStatus(parent:BrokerStatus, @BeanProperty id: String) extends Resource
{
   var state:String = "unknown";
   var accepted:Long = 0;
+  @GET
+  def get() = this
 }
 
 case class ConnectionStatus(parent:BrokerStatus, @BeanProperty id:String) extends Resource
{
   var state:String = "unknown";
   var readCounter:Long = 0;
   var writeCounter:Long = 0;
+  @GET
+  def get() = this
 }

Modified: activemq/sandbox/activemq-apollo-actor/pom.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/pom.xml?rev=961099&r1=961098&r2=961099&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/pom.xml (original)
+++ activemq/sandbox/activemq-apollo-actor/pom.xml Wed Jul  7 03:53:56 2010
@@ -97,7 +97,7 @@
     <jetty-plugin-version>7.0.1.v20091125</jetty-plugin-version>
     <scalate-version>1.1-SNAPSHOT</scalate-version>
     <servlet-api-version>2.5</servlet-api-version>
-    <jackson-version>1.3.2</jackson-version>
+    <jackson-version>1.5.2</jackson-version>
     
     <scala-version>2.8.0.Beta1</scala-version>
     <scalatest-version>1.0.1-for-scala-2.8.0.Beta1-RC7-with-test-interfaces-0.3-SNAPSHOT</scalatest-version>



Mime
View raw message