activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r961108 - in /activemq/sandbox/activemq-apollo-actor: activemq-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/ activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/ activemq-dto/src/main/java/org/apache/active...
Date Wed, 07 Jul 2010 03:58:11 GMT
Author: chirino
Date: Wed Jul  7 03:58:10 2010
New Revision: 961108

URL: http://svn.apache.org/viewvc?rev=961108&view=rev
Log:
improving dto model

Added:
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/IdDTO.java
      - copied, changed from r961107, activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/StoreDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceDTO.java
      - copied, changed from r961107, activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerSummaryDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceStatusDTO.java
      - copied, changed from r961107, activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/apache/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/apache/activemq/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/apache/activemq/apollo/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/apache/activemq/apollo/dto/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/apache/activemq/apollo/dto/XmlEncoderDecoderTest.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/apache/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/apache/activemq/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/apache/activemq/apollo/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/apache/activemq/apollo/dto/
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/apache/activemq/apollo/dto/simple.xml
      - copied, changed from r961107, activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml
Modified:
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala
    activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerStatusDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerSummaryDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectionStatusDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectorDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/StoreDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.java
    activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index
    activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/ConfigStore.scala
    activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala
    activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/resources/Root.scala

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala
Wed Jul  7 03:58:10 2010
@@ -25,14 +25,13 @@ import org.apache.activemq.apollo.broker
 import jaxb.PropertiesReader
 import org.apache.activemq.apollo.dto._
 import java.lang.String
+import XmlEncoderDecoder._
 
 class XmlBrokerFactory extends BrokerFactory.Handler {
 
   def createBroker(value: String): Broker = {
     try {
       var brokerURI = new URI(value)
-      val context = JAXBContext.newInstance("org.apache.activemq.apollo.dto")
-      val unmarshaller = context.createUnmarshaller()
 
       var configURL: URL = null
       brokerURI = URISupport.stripScheme(brokerURI)
@@ -48,10 +47,8 @@ class XmlBrokerFactory extends BrokerFac
       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[BrokerDTO]
+
+      val xml = unmarshalBrokerDTO(configURL, System.getProperties)
       return createMessageBroker(xml)
     } catch {
       case e: Exception =>

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/XMLBrokerFactoryTest.scala
Wed Jul  7 03:58:10 2010
@@ -27,7 +27,7 @@ import org.apache.activemq.apollo.broker
  */
 class XMLBrokerFactoryTest extends FunSuiteSupport {
   test("Simple Config") {
-    val uri = "xml:classpath:org/apache/activemq/apollo/jaxb/testSimpleConfig.xml"
+    val uri = "xml:classpath:org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml"
     info("Loading broker configuration from the classpath with URI: " + uri)
     val broker = BrokerFactory.createBroker(uri, false)
 
@@ -70,13 +70,13 @@ class XMLBrokerFactoryTest extends FunSu
     // non-existent classpath
 
     expectException("Creating broker from non-existing url does not throw an exception!")
{
-      val uri = "xml:classpath:org/apache/activemq/apollo/jaxb/testUris-fail.xml"
+      val uri = "xml:classpath:org/apache/activemq/apollo/broker/jaxb/testUris-fail.xml"
       BrokerFactory.createBroker(uri, false)
     }
 
     //non-existent file
     expectException("Creating broker from non-existing url does not throw an exception!")
{
-      val uri = "xml:file:/org/apache/activemq/apollo/jaxb/testUris-fail.xml"
+      val uri = "xml:file:/org/apache/activemq/apollo/broker/jaxb/testUris-fail.xml"
       BrokerFactory.createBroker(uri, false)
     }
 

Modified: activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml
Wed Jul  7 03:58:10 2010
@@ -20,13 +20,12 @@
 
   <transport-server>pipe://test1?wireFormat=mock</transport-server>
 
-  <connect-uri>pipe://test1</connect-uri>
-  <connect-uri>tcp://127.0.0.1:61616</connect-uri>
+  <connector/>
+  <connector>pipe://test1</connector>
 
   <virtual-host>
     <host-name>localhost</host-name>
     <host-name>test.localhost</host-name>
-    
     <memory-store/>
   </virtual-host>
   

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerDTO.java
Wed Jul  7 03:58:10 2010
@@ -30,13 +30,7 @@ import javax.xml.bind.annotation.XmlRoot
  */
 @XmlRootElement(name="broker")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class BrokerDTO {
-
-    /**
-     * A unique id of the broker.
-     */
-	@XmlAttribute(name="id")
-	public String id;
+public class BrokerDTO extends ServiceDTO {
 
     /**
      * Used to track config revisions.
@@ -45,13 +39,6 @@ public class BrokerDTO {
     public int rev;
 
     /**
-     * Should this broker be running?
-     */
-    @XmlAttribute(name="enabled")
-    public boolean enabled;
-
-
-    /**
      * Used to track who last modified the configuration.
      */
     @XmlAttribute(name="modified-by")
@@ -72,7 +59,7 @@ public class BrokerDTO {
     /**
      * A broker accepts connections via it's configured connectors.
      */
-    @XmlElement(name="connectors")
+    @XmlElement(name="connector")
     public List<ConnectorDTO> connectors = new ArrayList<ConnectorDTO>();
 
     /**
@@ -82,4 +69,6 @@ public class BrokerDTO {
     @XmlAttribute(name="basedir")
     public String basedir;
 
+    
+
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerStatusDTO.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerStatusDTO.java?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerStatusDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerStatusDTO.java
Wed Jul  7 03:58:10 2010
@@ -29,31 +29,20 @@ import javax.xml.bind.annotation.XmlRoot
  */
 @XmlRootElement(name="broker-status")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class BrokerStatusDTO {
+public class BrokerStatusDTO extends ServiceStatusDTO {
 
     /**
-     * A unique id of the broker.
+     * The current time on the broker machine.
      */
-	@XmlAttribute(name="id")
-	public String id;
+	@XmlAttribute(name="current-time")
+	public String currentTime;
 
     /**
-     * The state of the object.
-     */
-	@XmlAttribute(name="state")
-	public String state;
-    
-    /**
      * Since when has the broker in in this state?
      */
 	@XmlAttribute(name="in-state-since")
 	public String inStateSince;
 
-    /**
-     * The current time on the broker machine.
-     */
-	@XmlAttribute(name="current-time")
-	public String currentTime;
 
 
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerSummaryDTO.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerSummaryDTO.java?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerSummaryDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerSummaryDTO.java
Wed Jul  7 03:58:10 2010
@@ -29,13 +29,7 @@ import javax.xml.bind.annotation.XmlRoot
  */
 @XmlRootElement(name="broker-summary")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class BrokerSummaryDTO {
-
-    /**
-     * A unique id of the broker.
-     */
-	@XmlAttribute(name="id")
-	public String id;
+public class BrokerSummaryDTO extends IdDTO {
 
     /**
      * The latest revision of the broker config.

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectionStatusDTO.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectionStatusDTO.java?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectionStatusDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectionStatusDTO.java
Wed Jul  7 03:58:10 2010
@@ -29,19 +29,7 @@ import javax.xml.bind.annotation.XmlRoot
  */
 @XmlRootElement(name="connection-status")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class ConnectionStatusDTO {
-
-    /**
-     * A unique id of the connection.
-     */
-	@XmlAttribute(name="id")
-	public String id;
-
-    /**
-     * The state of the object.
-     */
-	@XmlAttribute(name="state")
-	public String state;
+public class ConnectionStatusDTO extends ServiceStatusDTO {
 
     /**
      * The number of bytes that have been read from the connection.
@@ -49,7 +37,6 @@ public class ConnectionStatusDTO {
 	@XmlAttribute(name="read-counter")
 	public Long readCounter;
 
-
     /**
      * The number of bytes that have been written to the connection.
      */

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectorDTO.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectorDTO.java?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectorDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ConnectorDTO.java
Wed Jul  7 03:58:10 2010
@@ -26,21 +26,9 @@ import javax.xml.bind.annotation.*;
  */
 @XmlRootElement(name = "connector")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class ConnectorDTO {
+public class ConnectorDTO extends ServiceDTO {
 
     /**
-     * A unique id.
-     */
-	@XmlAttribute(name="id")
-	public String id;
-
-    /**
-     * Should this connector be running?
-     */
-    @XmlAttribute(name="enabled")
-    public boolean enabled;
-    
-    /**
      * The transport uri which it will accept connections on.
      */
     @XmlAttribute

Copied: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/IdDTO.java
(from r961107, activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/StoreDTO.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/IdDTO.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/IdDTO.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/StoreDTO.java&r1=961107&r2=961108&rev=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/StoreDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/IdDTO.java
Wed Jul  7 03:58:10 2010
@@ -16,16 +16,22 @@
  */
 package org.apache.activemq.apollo.dto;
 
-import org.codehaus.jackson.annotate.JsonTypeInfo;
-
-import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.*;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-@XmlType(name = "store-type")
-@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
-public abstract class StoreDTO {
+@XmlRootElement(name="id")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class IdDTO {
+
+    /**
+     * A unique id of the object within it's container
+     */
+	@XmlAttribute(name="id")
+	public String id;
 
 
-}
+}
\ No newline at end of file

Copied: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceDTO.java
(from r961107, activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerSummaryDTO.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceDTO.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceDTO.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerSummaryDTO.java&r1=961107&r2=961108&rev=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/BrokerSummaryDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceDTO.java
Wed Jul  7 03:58:10 2010
@@ -22,26 +22,17 @@ import javax.xml.bind.annotation.XmlAttr
 import javax.xml.bind.annotation.XmlRootElement;
 
 /**
- * <p>
- * </p>
- *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-@XmlRootElement(name="broker-summary")
+@XmlRootElement(name="id")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class BrokerSummaryDTO {
+public class ServiceDTO extends IdDTO {
 
     /**
-     * A unique id of the broker.
+     * Should this service be running?
      */
-	@XmlAttribute(name="id")
-	public String id;
-
-    /**
-     * The latest revision of the broker config.
-     */
-	@XmlAttribute(name="rev")
-	public Integer rev;
+    @XmlAttribute(name="enabled")
+    public boolean enabled;
 
 
-}
+}
\ No newline at end of file

Copied: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceStatusDTO.java
(from r961107, activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.java)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceStatusDTO.java?p2=activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceStatusDTO.java&p1=activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.java&r1=961107&r2=961108&rev=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/ServiceStatusDTO.java
Wed Jul  7 03:58:10 2010
@@ -22,25 +22,17 @@ import javax.xml.bind.annotation.XmlAttr
 import javax.xml.bind.annotation.XmlRootElement;
 
 /**
- * <p>
- * </p>
- *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-@XmlRootElement(name="virtual-host-status")
+@XmlRootElement(name="service-status")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class VirtualHostStatusDTO {
-    
-    /**
-     * A unique id of the virtual host.
-     */
-	@XmlAttribute(name="id")
-	public String id;
+public class ServiceStatusDTO extends IdDTO {
 
     /**
-     * The state of the object.
+     * The state of the service.
      */
 	@XmlAttribute(name="state")
 	public String state;
-    
-}
+
+
+}
\ No newline at end of file

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/StoreDTO.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/StoreDTO.java?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/StoreDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/StoreDTO.java
Wed Jul  7 03:58:10 2010
@@ -18,14 +18,16 @@ package org.apache.activemq.apollo.dto;
 
 import org.codehaus.jackson.annotate.JsonTypeInfo;
 
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlType;
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
 @XmlType(name = "store-type")
+@XmlSeeAlso({MemoryStoreDTO.class, HawtDBStoreDTO.class})
 @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
 public abstract class StoreDTO {
 
-
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostDTO.java
Wed Jul  7 03:58:10 2010
@@ -25,26 +25,12 @@ import javax.xml.bind.annotation.*;
  */
 @XmlRootElement(name = "virtual-host")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class VirtualHostDTO {
-	
-    /**
-     * A unique id of the virtual host.
-     */
-	@XmlAttribute(name="id")
-	public String id;
+public class VirtualHostDTO extends ServiceDTO {
 
-    /**
-     * Should this virtual host be running?
-     */
-    @XmlAttribute(name="enabled")
-    public boolean enabled;
-
-    @XmlElement(name="host-names", required=true)
+    @XmlElement(name="host-name", required=true)
     public ArrayList<String> hostNames = new ArrayList<String>();
 
     @XmlElementRef   
     public StoreDTO store;
     
-
-
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.java?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.java
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/java/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.java
Wed Jul  7 03:58:10 2010
@@ -29,18 +29,6 @@ import javax.xml.bind.annotation.XmlRoot
  */
 @XmlRootElement(name="virtual-host-status")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class VirtualHostStatusDTO {
-    
-    /**
-     * A unique id of the virtual host.
-     */
-	@XmlAttribute(name="id")
-	public String id;
-
-    /**
-     * The state of the object.
-     */
-	@XmlAttribute(name="state")
-	public String state;
-    
+public class VirtualHostStatusDTO extends ServiceStatusDTO {
+        
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index
Wed Jul  7 03:58:10 2010
@@ -15,5 +15,3 @@
 ## limitations under the License.
 ## ------------------------------------------------------------------------
 BrokerDTO
-HawtDBStoreDTO
-MemoryStoreDTO

Added: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/apache/activemq/apollo/dto/XmlEncoderDecoderTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/apache/activemq/apollo/dto/XmlEncoderDecoderTest.java?rev=961108&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/apache/activemq/apollo/dto/XmlEncoderDecoderTest.java
(added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/java/org/apache/activemq/apollo/dto/XmlEncoderDecoderTest.java
Wed Jul  7 03:58:10 2010
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.apollo.dto;
+
+import org.junit.Test;
+
+import java.io.InputStream;
+import static junit.framework.Assert.*;
+
+
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+
+public class XmlEncoderDecoderTest {
+
+    private InputStream resource(String path) {
+        return getClass().getResourceAsStream(path);
+    }
+
+    @Test
+    public void unmarshalling() throws Exception {
+        BrokerDTO dto = XmlEncoderDecoder.unmarshalBrokerDTO(resource("simple.xml"));
+        assertNotNull(dto);
+        assertEquals("default", dto.id);
+        assertEquals(true, dto.enabled);
+        assertEquals("vh-local", dto.virtualHosts.get(0).id);
+        assertEquals(true, dto.virtualHosts.get(0).enabled);
+        assertEquals("localhost", dto.virtualHosts.get(0).hostNames.get(0));
+        assertEquals("example.com", dto.virtualHosts.get(0).hostNames.get(1));
+    }
+
+
+    @Test
+    public void marshalling() throws Exception {
+        BrokerDTO broker = new BrokerDTO();
+        broker.id = "default";
+        broker.enabled = true;
+
+        VirtualHostDTO host = new VirtualHostDTO();
+        host.id = "vh-local";
+        host.enabled = true;
+        host.hostNames.add("localhost");
+        host.hostNames.add("example.com");
+        broker.virtualHosts.add(host);
+
+        ConnectorDTO connector = new ConnectorDTO();
+        connector.id = "port-61616";
+        connector.enabled = true;
+        connector.bind = "tcp://0.0.0.0:61616";
+        broker.connectors.add(connector);
+        broker.basedir = "./activemq-data/default";
+
+        XmlEncoderDecoder.marshalBrokerDTO(broker, System.out, true);
+
+    }
+
+}

Copied: activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/apache/activemq/apollo/dto/simple.xml
(from r961107, activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml)
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/apache/activemq/apollo/dto/simple.xml?p2=activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/apache/activemq/apollo/dto/simple.xml&p1=activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml&r1=961107&r2=961108&rev=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-broker/src/test/scala/org/apache/activemq/apollo/broker/jaxb/testSimpleConfig.xml
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-dto/src/test/resources/org/apache/activemq/apollo/dto/simple.xml
Wed Jul  7 03:58:10 2010
@@ -6,28 +6,19 @@
     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.
 -->
-<broker xmlns="http://activemq.apache.org/schema/activemq/apollo">
-  <dispatcher name="test dispatcher" threads="4"/>
-
-  <transport-server>pipe://test1?wireFormat=mock</transport-server>
-
-  <connect-uri>pipe://test1</connect-uri>
-  <connect-uri>tcp://127.0.0.1:61616</connect-uri>
-
-  <virtual-host>
-    <host-name>localhost</host-name>
-    <host-name>test.localhost</host-name>
-    
-    <memory-store/>
-  </virtual-host>
-  
-</broker>
\ No newline at end of file
+<broker basedir="./activemq-data/default" rev="0" enabled="true" id="default" xmlns="http://activemq.apache.org/schema/activemq/apollo">
+    <virtual-host enabled="true" id="vh-local">
+        <host-name>localhost</host-name>
+        <host-name>example.com</host-name>
+    </virtual-host>
+    <connector bind="tcp://0.0.0.0:61616" enabled="true" id="port-61616"/>
+</broker>

Modified: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/ConfigStore.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/ConfigStore.scala?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/ConfigStore.scala
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/ConfigStore.scala
Wed Jul  7 03:58:10 2010
@@ -18,16 +18,17 @@ package org.apache.activemq.apollo
 
 import broker._
 import broker.jaxb.PropertiesReader
+import dto.{XmlEncoderDecoder, ConnectorDTO, VirtualHostDTO, BrokerDTO}
 import java.util.regex.Pattern
 import javax.xml.stream.{XMLOutputFactory, XMLInputFactory}
 import _root_.org.fusesource.hawtdispatch.ScalaDispatch._
-import dto.{ConnectorDTO, VirtualHostDTO, BrokerDTO}
 import org.apache.activemq.util.{Hasher, IOHelper}
 import java.util.concurrent.{TimeUnit, ExecutorService, Executors}
 import org.fusesource.hawtbuf.{ByteArrayInputStream, ByteArrayOutputStream}
 import org.apache.activemq.Service
 import javax.xml.bind.{Marshaller, JAXBContext}
 import java.io.{OutputStreamWriter, File}
+import XmlEncoderDecoder._
 
 /**
  * <p>
@@ -40,13 +41,13 @@ trait ConfigStore extends Service {
 
   def listBrokers(cb: (List[String]) => Unit):Unit
 
-  def getBroker(id:String, cb: (Option[BrokerDTO]) => Unit):Unit
+  def getBroker(id:String, eval:Boolean)(cb: (Option[BrokerDTO]) => Unit):Unit
 
-  def putBroker(config:BrokerDTO, cb: (Boolean) => Unit):Unit
+  def putBroker(config:BrokerDTO)(cb: (Boolean) => Unit):Unit
 
-  def removeBroker(id:String, rev:Int, cb: (Boolean) => Unit):Unit
+  def removeBroker(id:String, rev:Int)(cb: (Boolean) => Unit):Unit
 
-  def forBroker(cb: (BrokerDTO)=> Unit):Unit
+  def foreachBroker(eval:Boolean)(cb: (BrokerDTO)=> Unit):Unit
 
 }
 
@@ -69,12 +70,6 @@ class FileConfigStore extends ConfigStor
   }
   case class StoredBrokerModel(id:String, rev:Int, data:Array[Byte], hash:Int)
 
-  val context = JAXBContext.newInstance("org.apache.activemq.apollo.dto")
-  val unmarshaller = context.createUnmarshaller
-  val marshaller = context.createMarshaller
-  marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, java.lang.Boolean.TRUE )
-  val inputfactory = XMLInputFactory.newInstance
-
   var file:File = new File("activemq.xml")
   @volatile
   var latest:StoredBrokerModel = null
@@ -151,20 +146,20 @@ class FileConfigStore extends ConfigStor
   } >>: dispatchQueue
 
 
-  def forBroker(cb: (BrokerDTO)=> Unit) = using(cb) {
-
+  def foreachBroker(eval:Boolean)(cb: (BrokerDTO)=> Unit) = using(cb) {
+    cb(unmarshall(latest.data, eval))
   }
 
 
-  def getBroker(id:String, cb: (Option[BrokerDTO]) => Unit) = reply(cb) {
+  def getBroker(id:String, eval:Boolean)(cb: (Option[BrokerDTO]) => Unit) = reply(cb)
{
     if( latest.id == id ) {
-      Some(unmarshall(latest.data))
+      Some(unmarshall(latest.data, eval))
     } else {
       None
     }
   } >>: dispatchQueue
 
-  def putBroker(config:BrokerDTO, cb: (Boolean) => Unit) = reply(cb) {
+  def putBroker(config:BrokerDTO)(cb: (Boolean) => Unit) = reply(cb) {
     debug("storing broker model: %s ver %d", config.id, config.rev)
     if( latest.id != config.id ) {
       debug("this store can only update broker: "+latest.id)
@@ -178,7 +173,7 @@ class FileConfigStore extends ConfigStor
     }
   } >>: dispatchQueue
 
-  def removeBroker(id:String, rev:Int, cb: (Boolean) => Unit) = reply(cb) {
+  def removeBroker(id:String, rev:Int)(cb: (Boolean) => Unit) = reply(cb) {
     // not supported.
     false
   } >>: dispatchQueue
@@ -195,7 +190,7 @@ class FileConfigStore extends ConfigStor
             // has a chance to update the runtime too.
             val c = unmarshall(config.data)
             c.rev = config.rev
-            putBroker(c, null)
+            putBroker(c) { x=> }
           }
           schedualNextUpdateCheck
         }
@@ -243,16 +238,17 @@ class FileConfigStore extends ConfigStor
     config
   }
 
-  def unmarshall(in:Array[Byte]) = {
-    val bais = new ByteArrayInputStream(in);
-    val reader = inputfactory.createXMLStreamReader(bais)
-    val properties = new PropertiesReader(reader)
-    unmarshaller.unmarshal(properties).asInstanceOf[BrokerDTO]
+  def unmarshall(in:Array[Byte], evalProps:Boolean=false) = {
+    if (evalProps) {
+      unmarshalBrokerDTO(new ByteArrayInputStream(in), System.getProperties)
+    } else {
+      unmarshalBrokerDTO(new ByteArrayInputStream(in))
+    }
   }
 
   def marshall(in:BrokerDTO) = {
     val baos = new ByteArrayOutputStream
-    marshaller.marshal(in, new OutputStreamWriter(baos));
+    marshalBrokerDTO(in, baos, true)
     baos.toByteArray
   }
 }

Modified: activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala?rev=961108&r1=961107&r2=961108&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala
(original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-web/src/main/scala/org/apache/activemq/apollo/web/ServletContextListener.scala
Wed Jul  7 03:58:10 2010
@@ -42,21 +42,13 @@ class ServletContextListener extends Gui
       BrokerRegistry.configStore = createConfigStore
 
       // Brokers startup async.
-      BrokerRegistry.configStore.listBrokers { ids =>
-        ids.foreach { id=>
-          BrokerRegistry.configStore.getBroker(id, { x=>
-            x match {
-              case Some(config)=>
-                // Only start the broker up if it's enabled..
-                if( config.enabled ) {
-                  val broker = new Broker()
-                  broker.config = config
-                  BrokerRegistry.add(broker)
-                  broker.start()
-                }
-              case None =>
-            }
-          })
+      BrokerRegistry.configStore.foreachBroker(true) { config=>
+        // Only start the broker up if it's enabled..
+        if( config.enabled ) {
+          val broker = new Broker()
+          broker.config = config
+          BrokerRegistry.add(broker)
+          broker.start()
         }
       }
 
@@ -72,15 +64,16 @@ class ServletContextListener extends Gui
 
   override def contextDestroyed(servletContextEvent: ServletContextEvent) = {
     super.contextDestroyed(servletContextEvent);
-
-    // un-register/stop brokers we are managing.
-    if( broker!=null ) {
-      BrokerRegistry.remove(broker.id);
-      LoggingTracker("broker shutdown") { tracker =>
-        broker.stop(tracker.task(broker.id))
-        BrokerRegistry.configStore.stop(tracker.task("config store"))
+    val tracker = new LoggingTracker("broker shutdown")
+    BrokerRegistry.configStore.foreachBroker(false) { config=>
+      // remove started brokers what we configured..
+      val broker = BrokerRegistry.remove(config.id);
+      if( broker!=null ) {
+        tracker.stop(broker)
       }
     }
+    tracker.stop(BrokerRegistry.configStore)
+    tracker.await
   }
 
   def getInjector = Guice.createInjector(new ScalateModule() {

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=961108&r1=961107&r2=961108&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:58:10 2010
@@ -94,7 +94,7 @@ case class Broker(parent:Root, @BeanProp
 
   private def config() = {
     Future[Option[BrokerDTO]] { cb=>
-      configStore.getBroker(id, cb)
+      configStore.getBroker(id, false)(cb)
     }.getOrElse(result(NOT_FOUND))
   }
 
@@ -111,14 +111,14 @@ case class Broker(parent:Root, @BeanProp
     config.id = id;
     config.rev = rev
     Future[Boolean] { cb=>
-      configStore.putBroker(config, cb)
+      configStore.putBroker(config)(cb)
     } || result(NOT_FOUND)
   }
 
   @DELETE @Path("config/{rev}")
   def delete(@PathParam("rev") rev:Int) = {
     Future[Boolean] { cb=>
-      configStore.removeBroker(id, rev, cb)
+      configStore.removeBroker(id, rev)(cb)
     } || result(NOT_FOUND)
   }
 



Mime
View raw message