Author: chirino
Date: Tue Mar 29 15:05:30 2011
New Revision: 1086618

URL: http://svn.apache.org/viewvc?rev=1086618&view=rev
Log:
Made the XMLCodec interface more consistent with the calling convention used by 
the JsonCodec.

Modified:
    
activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/dto/XmlCodecTest.java
    
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
    
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala
    
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/osgi/BrokerService.scala
    
activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/dto/XmlCodecTest.java
    
activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/XmlCodec.java
    
activemq/activemq-apollo/trunk/apollo-dto/src/test/java/org/apache/activemq/apollo/dto/XmlCodecTest.java
    
activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/dto/XmlCodecTest.java
    
activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/dto/XmlCodecTest.java

Modified: 
activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/dto/XmlCodecTest.java
URL: 
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/dto/XmlCodecTest.java?rev=1086618&r1=1086617&r2=1086618&view=diff
==============================================================================
--- 
activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/dto/XmlCodecTest.java
 (original)
+++ 
activemq/activemq-apollo/trunk/apollo-bdb/src/test/scala/org/apache/activemq/apollo/broker/store/bdb/dto/XmlCodecTest.java
 Tue Mar 29 15:05:30 2011
@@ -38,7 +38,7 @@ public class XmlCodecTest {
 
     @Test
     public void unmarshalling() throws Exception {
-        BrokerDTO dto = XmlCodec.unmarshalBrokerDTO(resource("simple.xml"));
+        BrokerDTO dto = XmlCodec.decode(BrokerDTO.class, 
resource("simple.xml"));
         assertNotNull(dto);
         VirtualHostDTO host = dto.virtual_hosts.get(0);
         assertEquals("vh-local", host.id);

Modified: 
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
URL: 
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala?rev=1086618&r1=1086617&r2=1086618&view=diff
==============================================================================
--- 
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
 (original)
+++ 
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ConfigStore.scala
 Tue Mar 29 15:05:30 2011
@@ -190,15 +190,15 @@ class FileConfigStore(var file:File = ne
         }
       }
 
-      unmarshalBrokerDTO(new ByteArrayInputStream(in), props)
+      decode(classOf[BrokerDTO], new ByteArrayInputStream(in), props)
     } else {
-      unmarshalBrokerDTO(new ByteArrayInputStream(in))
+      decode(classOf[BrokerDTO], new ByteArrayInputStream(in))
     }
   }
 
   def marshall(in:BrokerDTO) = {
     val baos = new ByteArrayOutputStream
-    marshalBrokerDTO(in, baos, true)
+    encode(in, baos, true)
     baos.toByteArray
   }
 }

Modified: 
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala
URL: 
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala?rev=1086618&r1=1086617&r2=1086618&view=diff
==============================================================================
--- 
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala
 (original)
+++ 
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jaxb/XmlBrokerFactory.scala
 Tue Mar 29 15:05:30 2011
@@ -46,7 +46,7 @@ class XmlBrokerFactory extends BrokerFac
         throw new IOException("Cannot create broker from non-existent URI: " + 
brokerURI)
       }
 
-      val xml = unmarshalBrokerDTO(configURL, System.getProperties)
+      val xml = decode(classOf[BrokerDTO], configURL, System.getProperties)
       return createMessageBroker(xml)
     } catch {
       case e: Exception =>

Modified: 
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/osgi/BrokerService.scala
URL: 
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/osgi/BrokerService.scala?rev=1086618&r1=1086617&r2=1086618&view=diff
==============================================================================
--- 
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/osgi/BrokerService.scala
 (original)
+++ 
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/osgi/BrokerService.scala
 Tue Mar 29 15:05:30 2011
@@ -69,7 +69,7 @@ object BrokerService extends Log {
             props.put(key.asInstanceOf[String], 
cmProps.get(key).asInstanceOf[String])
           }
         }
-        XmlCodec.unmarshalBrokerDTO(new FileInputStream(apollo_xml), props)
+        XmlCodec.decode(classOf[BrokerDTO], new FileInputStream(apollo_xml), 
props)
       }
 
       debug("Starting broker");

Modified: 
activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/dto/XmlCodecTest.java
URL: 
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/dto/XmlCodecTest.java?rev=1086618&r1=1086617&r2=1086618&view=diff
==============================================================================
--- 
activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/dto/XmlCodecTest.java
 (original)
+++ 
activemq/activemq-apollo/trunk/apollo-cassandra/src/test/scala/org/apache/activemq/apollo/broker/store/cassandra/dto/XmlCodecTest.java
 Tue Mar 29 15:05:30 2011
@@ -38,7 +38,7 @@ public class XmlCodecTest {
 
     @Test
     public void unmarshalling() throws Exception {
-        BrokerDTO dto = XmlCodec.unmarshalBrokerDTO(resource("simple.xml"));
+        BrokerDTO dto = XmlCodec.decode(BrokerDTO.class, 
resource("simple.xml"));
         assertNotNull(dto);
         VirtualHostDTO host = dto.virtual_hosts.get(0);
         assertEquals("vh-local", host.id);

Modified: 
activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/XmlCodec.java
URL: 
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/XmlCodec.java?rev=1086618&r1=1086617&r2=1086618&view=diff
==============================================================================
--- 
activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/XmlCodec.java
 (original)
+++ 
activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/XmlCodec.java
 Tue Mar 29 15:05:30 2011
@@ -106,19 +106,19 @@ public class XmlCodec {
         return JAXBContext.newInstance(packages);
     }
 
-    static public BrokerDTO unmarshalBrokerDTO(URL url) throws IOException, 
XMLStreamException, JAXBException {
-        return unmarshalBrokerDTO(url, null);
+    static public <T> T decode(Class<T> clazz, URL url) throws IOException, 
XMLStreamException, JAXBException {
+        return decode(clazz, url, null);
     }
 
-    static public BrokerDTO unmarshalBrokerDTO(URL url, Properties props) 
throws IOException, XMLStreamException, JAXBException {
-        return unmarshalBrokerDTO(url.openStream(), props);
+    static public <T> T decode(Class<T> clazz, URL url, Properties props) 
throws IOException, XMLStreamException, JAXBException {
+        return decode(clazz, url.openStream(), props);
     }
 
-    static public BrokerDTO unmarshalBrokerDTO(InputStream is) throws 
IOException, XMLStreamException, JAXBException {
-        return unmarshalBrokerDTO(is, null);
+    static public <T> T decode(Class<T> clazz, InputStream is) throws 
IOException, XMLStreamException, JAXBException {
+        return decode(clazz, is, null);
     }
 
-    static public BrokerDTO unmarshalBrokerDTO(InputStream is, Properties 
props) throws IOException, XMLStreamException, JAXBException {
+    static public <T> T decode(Class<T> clazz, InputStream is, Properties 
props) throws IOException, XMLStreamException, JAXBException {
         ClassLoader original = Thread.currentThread().getContextClassLoader();
         try {
             
Thread.currentThread().setContextClassLoader(ClassFinder.class_loader());
@@ -131,7 +131,7 @@ public class XmlCodec {
                     reader = new PropertiesFilter(reader, props);
                 }
                 Unmarshaller unmarshaller = context().createUnmarshaller();
-                return (BrokerDTO) unmarshaller.unmarshal(reader);
+                return clazz.cast(unmarshaller.unmarshal(reader));
             } finally {
                 is.close();
             }
@@ -141,7 +141,7 @@ public class XmlCodec {
         }
     }
 
-    static public void marshalBrokerDTO(BrokerDTO in, OutputStream os, boolean 
format) throws JAXBException {
+    static public void encode(Object in, OutputStream os, boolean format) 
throws JAXBException {
         ClassLoader original = Thread.currentThread().getContextClassLoader();
         try {
             
Thread.currentThread().setContextClassLoader(ClassFinder.class_loader());

Modified: 
activemq/activemq-apollo/trunk/apollo-dto/src/test/java/org/apache/activemq/apollo/dto/XmlCodecTest.java
URL: 
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/test/java/org/apache/activemq/apollo/dto/XmlCodecTest.java?rev=1086618&r1=1086617&r2=1086618&view=diff
==============================================================================
--- 
activemq/activemq-apollo/trunk/apollo-dto/src/test/java/org/apache/activemq/apollo/dto/XmlCodecTest.java
 (original)
+++ 
activemq/activemq-apollo/trunk/apollo-dto/src/test/java/org/apache/activemq/apollo/dto/XmlCodecTest.java
 Tue Mar 29 15:05:30 2011
@@ -37,7 +37,7 @@ public class XmlCodecTest {
 
     @Test
     public void unmarshalling() throws Exception {
-        BrokerDTO dto = 
XmlCodec.unmarshalBrokerDTO(resource("XmlCodecTest.xml"));
+        BrokerDTO dto = XmlCodec.decode(BrokerDTO.class, 
resource("XmlCodecTest.xml"));
         assertNotNull(dto);
         assertEquals(1, dto.connectors.size());
         ConnectorDTO connector = dto.connectors.get(0);
@@ -84,7 +84,7 @@ public class XmlCodecTest {
         connector.bind = "tcp://[::]:61616";
         broker.connectors.add(connector);
 
-        XmlCodec.marshalBrokerDTO(broker, System.out, true);
+        XmlCodec.encode(broker, System.out, true);
 
     }
 

Modified: 
activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/dto/XmlCodecTest.java
URL: 
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/dto/XmlCodecTest.java?rev=1086618&r1=1086617&r2=1086618&view=diff
==============================================================================
--- 
activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/dto/XmlCodecTest.java
 (original)
+++ 
activemq/activemq-apollo/trunk/apollo-hawtdb/src/test/scala/org/apache/activemq/apollo/broker/store/hawtdb/dto/XmlCodecTest.java
 Tue Mar 29 15:05:30 2011
@@ -38,7 +38,7 @@ public class XmlCodecTest {
 
     @Test
     public void unmarshalling() throws Exception {
-        BrokerDTO dto = XmlCodec.unmarshalBrokerDTO(resource("simple.xml"));
+        BrokerDTO dto = XmlCodec.decode(BrokerDTO.class, 
resource("simple.xml"));
         assertNotNull(dto);
         VirtualHostDTO host = dto.virtual_hosts.get(0);
         assertEquals("vh-local", host.id);

Modified: 
activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/dto/XmlCodecTest.java
URL: 
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/dto/XmlCodecTest.java?rev=1086618&r1=1086617&r2=1086618&view=diff
==============================================================================
--- 
activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/dto/XmlCodecTest.java
 (original)
+++ 
activemq/activemq-apollo/trunk/apollo-jdbm2/src/test/scala/org/apache/activemq/apollo/broker/store/jdbm2/dto/XmlCodecTest.java
 Tue Mar 29 15:05:30 2011
@@ -38,7 +38,7 @@ public class XmlCodecTest {
 
     @Test
     public void unmarshalling() throws Exception {
-        BrokerDTO dto = XmlCodec.unmarshalBrokerDTO(resource("simple.xml"));
+        BrokerDTO dto = XmlCodec.decode(BrokerDTO.class, 
resource("simple.xml"));
         assertNotNull(dto);
         VirtualHostDTO host = dto.virtual_hosts.get(0);
         assertEquals("vh-local", host.id);


Reply via email to