Repository: aries-rsa
Updated Branches:
  refs/heads/master 965444751 -> 990752a79


[ARIES-1543] Make it easier to use EndpointDescriptionParser


Project: http://git-wip-us.apache.org/repos/asf/aries-rsa/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-rsa/commit/990752a7
Tree: http://git-wip-us.apache.org/repos/asf/aries-rsa/tree/990752a7
Diff: http://git-wip-us.apache.org/repos/asf/aries-rsa/diff/990752a7

Branch: refs/heads/master
Commit: 990752a7990a3c3d84690da8afa0b8bc18239a1f
Parents: 9654447
Author: Christian Schneider <[email protected]>
Authored: Tue May 3 15:39:08 2016 +0200
Committer: Christian Schneider <[email protected]>
Committed: Tue May 3 15:39:08 2016 +0200

----------------------------------------------------------------------
 .../EndpointDescriptionBundleParser.java        | 104 -----------
 .../endpoint/EndpointDescriptionParser.java     |  77 +++++---
 .../discovery/endpoint/PropertiesMapper.java    |   2 +-
 .../local/EndpointDescriptionBundleParser.java  |  92 ++++++++++
 .../rsa/discovery/local/LocalDiscovery.java     |   1 -
 .../EndpointDescriptionBundleParserTest.java    | 171 ------------------
 .../endpoint/EndpointDescriptionParserTest.java |  19 +-
 .../endpoint/PropertiesMapperTest.java          |  38 ++--
 .../EndpointDescriptionBundleParserTest.java    | 181 +++++++++++++++++++
 .../publish/PublishingEndpointListener.java     |  16 +-
 .../zookeeper/subscribe/InterfaceMonitor.java   |  13 +-
 .../publish/PublishingEndpointListenerTest.java |  14 +-
 .../itests/felix/tcp/TestDiscoveryExport.java   |   7 +-
 13 files changed, 363 insertions(+), 372 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParser.java
----------------------------------------------------------------------
diff --git 
a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParser.java
 
b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParser.java
deleted file mode 100644
index a702e8e..0000000
--- 
a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParser.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * 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.aries.rsa.discovery.endpoint;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class EndpointDescriptionBundleParser {
-    private static final Logger LOG = 
LoggerFactory.getLogger(EndpointDescriptionBundleParser.class);
-
-    private static final String REMOTE_SERVICES_HEADER_NAME = "Remote-Service";
-    private static final String REMOTE_SERVICES_DIRECTORY = 
"OSGI-INF/remote-service/";
-
-    private EndpointDescriptionParser parser;
-
-    public EndpointDescriptionBundleParser() {
-        parser = new EndpointDescriptionParser();
-    }
-
-    public List<EndpointDescription> getAllEndpointDescriptions(Bundle b) {
-        List<EndpointDescriptionType> elements = getAllDescriptionElements(b);
-
-        List<EndpointDescription> endpoints = new 
ArrayList<EndpointDescription>(elements.size());
-        for (EndpointDescriptionType epd : elements) {
-            Map<String, Object> props = new 
PropertiesMapper().toProps(epd.getProperty());
-            endpoints.add(new EndpointDescription(props));
-        }
-        return endpoints;
-    }
-
-    List<EndpointDescriptionType> getAllDescriptionElements(Bundle b) {
-        Enumeration<URL> urls = getEndpointDescriptionURLs(b);
-        List<EndpointDescriptionType> elements = new 
ArrayList<EndpointDescriptionType>();
-        while (urls.hasMoreElements()) {
-            URL resourceURL = (URL) urls.nextElement();
-            try {
-                
elements.addAll(parser.getEndpointDescriptions(resourceURL.openStream()));
-            } catch (Exception ex) {
-                LOG.warn("Problem parsing: " + resourceURL, ex);
-            }
-        }
-        return elements;
-    }
-    
-    Enumeration<URL> getEndpointDescriptionURLs(Bundle b) {
-        String origDir = getRemoteServicesDir(b);
-        
-        // Split origDir into dir and file pattern
-        String filePattern = "*.xml";
-        String dir;
-        if (origDir.endsWith("/")) {
-            dir = origDir.substring(0, origDir.length() - 1);
-        } else {
-            int idx = origDir.lastIndexOf('/');
-            if (idx >= 0 & origDir.length() > idx) {
-                filePattern = origDir.substring(idx + 1);
-                dir = origDir.substring(0, idx);
-            } else {
-                filePattern = origDir;
-                dir = "";
-            }
-        }
-
-        Enumeration<URL> urls = b.findEntries(dir, filePattern, false);
-        return (urls == null) ? Collections.enumeration(new ArrayList<URL>()) 
: urls;
-    }
-
-    private static String getRemoteServicesDir(Bundle b) {
-        Dictionary<?, ?> headers = b.getHeaders();
-        Object header = null;
-        if (headers != null) {
-            header = headers.get(REMOTE_SERVICES_HEADER_NAME);
-        }
-        return (header == null) ? REMOTE_SERVICES_DIRECTORY : 
header.toString();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParser.java
----------------------------------------------------------------------
diff --git 
a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParser.java
 
b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParser.java
index 291dc35..0a0c02f 100644
--- 
a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParser.java
+++ 
b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParser.java
@@ -18,37 +18,39 @@
  */
 package org.apache.aries.rsa.discovery.endpoint;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
-import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
 import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionsType;
+import org.osgi.xmlns.rsa.v1_0.ObjectFactory;
+import org.osgi.xmlns.rsa.v1_0.PropertyType;
 
 public class EndpointDescriptionParser {
     private JAXBContext jaxbContext;
 
     public EndpointDescriptionParser() {
         try {
-            jaxbContext = 
JAXBContext.newInstance(EndpointDescriptionsType.class.getPackage().getName(),
-                                                  
this.getClass().getClassLoader());
+            jaxbContext = 
JAXBContext.newInstance(EndpointDescriptionsType.class);
         } catch (JAXBException e) {
             throw new RuntimeException(e.getMessage(), e);
         }
     }
 
-    public List<EndpointDescriptionType> getEndpointDescriptions(InputStream 
is) {
+    private List<EndpointDescriptionType> readEpdts(InputStream is) {
         try {
             Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
             Source source = new StreamSource(is);
@@ -59,32 +61,63 @@ public class EndpointDescriptionParser {
             throw new RuntimeException(ex.getMessage(), ex);
         }
     }
+    
+    public List<EndpointDescription> readEndpoints(InputStream is) {
+        List<EndpointDescriptionType> epdts = readEpdts(is);
+        List<EndpointDescription> epds = new ArrayList<EndpointDescription>();
+        for (EndpointDescriptionType epdt : epdts) {
+            epds.add(convert(epdt));
+        }
+        return epds;
+    }
+    
+    public EndpointDescription readEndpoint(InputStream is) {
+        List<EndpointDescription> endpoints = readEndpoints(is);
+        if (endpoints.isEmpty()) {
+            return null;
+        }
+        return endpoints.iterator().next();
+    }
 
-    public void writeTo(EndpointDescriptionsType endpointDescriptions, 
OutputStream os) {
+    public void writeEndpoint(EndpointDescription epd, OutputStream os) {
+        writeEpdt(convert(epd), os);
+    }
+    
+    private void writeEpdt(EndpointDescriptionType endpointDescription, 
OutputStream os) {
         try {
             Marshaller marshaller = jaxbContext.createMarshaller();
             marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
-            QName name = new QName("http://www.osgi.org/xmlns/rsa/v1.0.0";, 
"endpoint-descriptions");
-            JAXBElement<EndpointDescriptionsType> el = 
-                new JAXBElement<EndpointDescriptionsType>(name, 
EndpointDescriptionsType.class, 
-                    endpointDescriptions);
+            EndpointDescriptionsType endpointDescriptions = new 
EndpointDescriptionsType();
+            
endpointDescriptions.getEndpointDescription().add(endpointDescription);
+            JAXBElement<EndpointDescriptionsType> el = new 
ObjectFactory().createEndpointDescriptions(endpointDescriptions);
             marshaller.marshal(el, os);
         } catch (Exception ex) {
             throw new RuntimeException(ex.getMessage(), ex);
         } finally {
-            try {
-                os.close();
-            } catch (IOException e) {
-                // Ignore
-            }
+            safeClose(os);
         }
     }
-    
-    public byte[] getData(EndpointDescriptionType endpointDescription) {
-        EndpointDescriptionsType endpointDescriptions = new 
EndpointDescriptionsType();
-        endpointDescriptions.getEndpointDescription().add(endpointDescription);
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        writeTo(endpointDescriptions, bos);
-        return bos.toByteArray();
+
+    private void safeClose(OutputStream os) {
+        try {
+            os.close();
+        } catch (IOException e) {
+            // Ignore
+        }
+    }
+
+    private EndpointDescriptionType convert(EndpointDescription epd) {
+        List<PropertyType> props = new 
PropertiesMapper().fromProps(epd.getProperties());
+        EndpointDescriptionType epdt = new EndpointDescriptionType();
+        epdt.getProperty().addAll(props);
+        return epdt;
     }
+
+    private EndpointDescription convert(EndpointDescriptionType epdt) {
+        Map<String, Object> props = new 
PropertiesMapper().toProps(epdt.getProperty());
+        return new EndpointDescription(props);
+        
+    }
+    
+
 }

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
----------------------------------------------------------------------
diff --git 
a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
 
b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
index 13c02bb..a17020b 100644
--- 
a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
+++ 
b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
@@ -46,7 +46,7 @@ import org.osgi.xmlns.rsa.v1_0.XmlType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class PropertiesMapper {
+class PropertiesMapper {
     private static final Logger LOG = 
LoggerFactory.getLogger(PropertiesMapper.class);
 
     public Map<String, Object> toProps(List<PropertyType> properties) {

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
----------------------------------------------------------------------
diff --git 
a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
 
b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
new file mode 100644
index 0000000..b4393a9
--- /dev/null
+++ 
b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
@@ -0,0 +1,92 @@
+/**
+ * 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.aries.rsa.discovery.local;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
+import org.osgi.framework.Bundle;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class EndpointDescriptionBundleParser {
+    private static final Logger LOG = 
LoggerFactory.getLogger(EndpointDescriptionBundleParser.class);
+
+    private static final String REMOTE_SERVICES_HEADER_NAME = "Remote-Service";
+    private static final String REMOTE_SERVICES_DIRECTORY = 
"OSGI-INF/remote-service/";
+
+    private EndpointDescriptionParser parser;
+
+    public EndpointDescriptionBundleParser() {
+        parser = new EndpointDescriptionParser();
+    }
+
+    public List<EndpointDescription> getAllEndpointDescriptions(Bundle b) {
+        Enumeration<URL> urls = getEndpointDescriptionURLs(b);
+        List<EndpointDescription> elements = new 
ArrayList<EndpointDescription>();
+        while (urls.hasMoreElements()) {
+            URL resourceURL = (URL) urls.nextElement();
+            try {
+                
elements.addAll(parser.readEndpoints(resourceURL.openStream()));
+            } catch (Exception ex) {
+                LOG.warn("Problem parsing: " + resourceURL, ex);
+            }
+        }
+        return elements;
+    }
+    
+    Enumeration<URL> getEndpointDescriptionURLs(Bundle b) {
+        String origDir = getRemoteServicesDir(b);
+        
+        // Split origDir into dir and file pattern
+        String filePattern = "*.xml";
+        String dir;
+        if (origDir.endsWith("/")) {
+            dir = origDir.substring(0, origDir.length() - 1);
+        } else {
+            int idx = origDir.lastIndexOf('/');
+            if (idx >= 0 & origDir.length() > idx) {
+                filePattern = origDir.substring(idx + 1);
+                dir = origDir.substring(0, idx);
+            } else {
+                filePattern = origDir;
+                dir = "";
+            }
+        }
+
+        Enumeration<URL> urls = b.findEntries(dir, filePattern, false);
+        return (urls == null) ? Collections.enumeration(new ArrayList<URL>()) 
: urls;
+    }
+
+    private static String getRemoteServicesDir(Bundle b) {
+        Dictionary<?, ?> headers = b.getHeaders();
+        Object header = null;
+        if (headers != null) {
+            header = headers.get(REMOTE_SERVICES_HEADER_NAME);
+        }
+        return (header == null) ? REMOTE_SERVICES_DIRECTORY : 
header.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
----------------------------------------------------------------------
diff --git 
a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
 
b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
index 823d736..a1e8575 100644
--- 
a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
+++ 
b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
@@ -29,7 +29,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionBundleParser;
 import org.apache.aries.rsa.util.StringPlus;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParserTest.java
----------------------------------------------------------------------
diff --git 
a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParserTest.java
 
b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParserTest.java
deleted file mode 100644
index 06afb0a..0000000
--- 
a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionBundleParserTest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/**
- * 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.aries.rsa.discovery.endpoint;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-import junit.framework.TestCase;
-
-import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionBundleParser;
-import org.easymock.EasyMock;
-import org.osgi.framework.Bundle;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-
-public class EndpointDescriptionBundleParserTest extends TestCase {
-
-    private Bundle createBundleContaining(URL ed1URL) {
-        Bundle b = EasyMock.createNiceMock(Bundle.class);
-        EasyMock.expect(b.findEntries(
-            EasyMock.eq("OSGI-INF/remote-service"),
-            EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn(
-                Collections.enumeration(Arrays.asList(ed1URL))).anyTimes();
-        EasyMock.replay(b);
-        return b;
-    }
-
-    public void testAllEndpoints1() {
-        URL ed1URL = getClass().getResource("/ed1.xml");
-
-        Bundle b = createBundleContaining(ed1URL);
-
-        List<EndpointDescription> endpoints = new 
EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
-        assertEquals(4, endpoints.size());
-        EndpointDescription endpoint0 = endpoints.get(0);
-        assertEquals("http://somewhere:12345";, endpoint0.getId());
-        assertEquals(Arrays.asList("SomeService"), endpoint0.getInterfaces());
-        assertEquals(Arrays.asList("confidentiality"),
-            endpoint0.getProperties().get("osgi.remote.requires.intents"));
-        assertEquals("testValue", endpoint0.getProperties().get("testKey"));
-
-        EndpointDescription endpoint1 = endpoints.get(1);
-        assertEquals("myScheme://somewhere:12345", endpoint1.getId());
-        assertEquals(Arrays.asList("SomeOtherService", 
"WithSomeSecondInterface"), endpoint1.getInterfaces());
-
-        EndpointDescription endpoint2 = endpoints.get(2);
-        assertEquals("http://somewhere";, endpoint2.getId());
-        assertEquals(Arrays.asList("SomeOtherService", 
"WithSomeSecondInterface"), endpoint2.getInterfaces());
-
-        EndpointDescription endpoint3 = endpoints.get(3);
-        assertEquals("http://somewhere:1/2/3/4?5";, endpoint3.getId());
-        assertEquals(Arrays.asList("SomeOtherService", 
"WithSomeSecondInterface"), endpoint3.getInterfaces());
-    }
-
-    public void testAllEndpoints2() throws Exception {
-        URL ed2URL = getClass().getResource("/ed2.xml");
-
-        Bundle b = createBundleContaining(ed2URL);
-
-        List<EndpointDescription> endpoints = new 
EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
-        assertEquals(2, endpoints.size());
-        EndpointDescription endpoint0 = endpoints.get(0);
-        assertEquals("foo:bar", endpoint0.getId());
-        assertEquals(Arrays.asList("com.acme.HelloService"), 
endpoint0.getInterfaces());
-        assertEquals(Arrays.asList("SOAP"), endpoint0.getIntents());
-        // changed from exported to imported
-        assertEquals("org.apache.cxf.ws", 
endpoint0.getProperties().get("service.imported.configs"));
-
-        EndpointDescription endpoint1 = endpoints.get(1);
-        Map<String, Object> props = endpoint1.getProperties();
-        assertEquals(Arrays.asList("com.acme.HelloService", 
"some.other.Service"), endpoint1.getInterfaces());
-        assertEquals("org.apache.cxf.ws", 
props.get("service.imported.configs"));
-        // exports should have been removed
-        assertNull(props.get("service.exported.configs"));
-
-        assertEquals(EndpointDescriptionBundleParserTest.normXML("<other:t1 
xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' "
-            + "xmlns='http://www.acme.org/xmlns/other/v1.0.0'><foo 
type='bar'>haha</foo>\n"
-            + "        </other:t1>"),
-            EndpointDescriptionBundleParserTest.normXML((String) 
props.get("someXML")));
-        assertEquals(Long.MAX_VALUE, props.get("long"));
-        assertEquals(-1L, props.get("long2"));
-        assertEquals(Double.MAX_VALUE, props.get("double"));
-        assertEquals(1.0d, props.get("Double2"));
-        assertEquals(42.24f, props.get("float"));
-        assertEquals(1.0f, props.get("Float2"));
-        assertEquals(17, props.get("int"));
-        assertEquals(42, props.get("Integer2"));
-        assertEquals((byte) 127, props.get("byte"));
-        assertEquals((byte) -128, props.get("Byte2"));
-        assertEquals(Boolean.TRUE, props.get("boolean"));
-        assertEquals(Boolean.TRUE, props.get("Boolean2"));
-        assertEquals((short) 99, props.get("short"));
-        assertEquals((short) -99, props.get("Short2"));
-        assertEquals('@', props.get("char"));
-        assertEquals('X', props.get("Character2"));
-
-        int[] intArray = (int[]) props.get("int-array");
-        assertTrue(Arrays.equals(new int[] {1, 2}, intArray));
-
-        Integer[] integerArray = (Integer[]) props.get("Integer-array");
-        assertTrue(Arrays.equals(new Integer[] {2, 1}, integerArray));
-
-        assertEquals(Arrays.asList(true, false), props.get("bool-list"));
-        assertEquals(new HashSet<Object>(), props.get("long-set"));
-        Set<String> stringSet = new HashSet<String>();
-        stringSet.add("Hello there");
-        stringSet.add("How are you?");
-        assertEquals(stringSet, props.get("string-set"));
-        assertEquals("Hello", props.get("other1").toString().trim());
-
-        List<?> l = (List<?>) props.get("other2");
-        assertEquals(1, l.size());
-        assertEquals(EndpointDescriptionBundleParserTest.normXML("<other:t2 
xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' " 
-                                   + 
"xmlns='http://www.osgi.org/xmlns/rsa/v1.0.0'/>"),
-                                   
EndpointDescriptionBundleParserTest.normXML((String) l.get(0)));
-    }
-
-    public static String stripProlog(String s) {
-        return s.replaceAll("<\\?(.*?)\\?>", "");
-    }
-
-    public static String stripComment(String s) {
-        return Pattern.compile("<!--(.*?)-->", 
Pattern.DOTALL).matcher(s).replaceAll("");
-    }
-
-    public static String normXML(String s) {
-        String s2 = stripComment(s);
-        String s3 = stripProlog(s2);
-        try {
-            TransformerFactory transFactory = TransformerFactory.newInstance();
-            Transformer transformer = transFactory.newTransformer();
-            StringWriter buffer = new StringWriter();
-            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
-            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, 
"yes");
-            transformer.transform(new StreamSource(new StringReader(s3)), new 
StreamResult(buffer));
-            return buffer.toString();
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParserTest.java
----------------------------------------------------------------------
diff --git 
a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParserTest.java
 
b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParserTest.java
index dea3c19..12ead94 100644
--- 
a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParserTest.java
+++ 
b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParserTest.java
@@ -22,30 +22,17 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.List;
 
-import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionBundleParser;
-import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
-import org.easymock.EasyMock;
 import org.junit.Assert;
 import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
 
 public class EndpointDescriptionParserTest {
 
     @Test
-    public void testNoRemoteServicesXMLFiles() {
-        Bundle b = EasyMock.createNiceMock(Bundle.class);
-        EasyMock.replay(b);
-
-        List<EndpointDescriptionType> rsElements = new 
EndpointDescriptionBundleParser().getAllDescriptionElements(b);
-        Assert.assertEquals(0, rsElements.size());
-    }
-
-    @Test
     public void testEndpointDescriptionsFromURL() throws IOException {
         URL ed1URL = getClass().getResource("/ed1.xml");
-        List<EndpointDescriptionType> edElements = new 
EndpointDescriptionParser().
-            getEndpointDescriptions(ed1URL.openStream());
+        List<EndpointDescription> edElements = new EndpointDescriptionParser().
+            readEndpoints(ed1URL.openStream());
         Assert.assertEquals(4, edElements.size());
     }
 }

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
----------------------------------------------------------------------
diff --git 
a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
 
b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
index 3ba0451..17ef458 100644
--- 
a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
+++ 
b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
@@ -19,27 +19,24 @@
 package org.apache.aries.rsa.discovery.endpoint;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.net.URL;
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.xml.sax.InputSource;
-import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
-import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
 import org.custommonkey.xmlunit.XMLAssert;
+import org.junit.Ignore;
 import org.junit.Test;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
-import org.osgi.xmlns.rsa.v1_0.PropertyType;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.xml.sax.InputSource;
 
 public class PropertiesMapperTest {
-    private static final String LF = "\n";
-
     @Test
+    @Ignore
     public void testCreateXML() throws Exception {
         Map<String, Object> m = new LinkedHashMap<String, Object>();
         m.put("service.imported.configs", "org.apache.cxf.ws");
@@ -63,10 +60,7 @@ public class PropertiesMapperTest {
         m.put("char", '@');
         m.put("Character2", 'X');
 
-        List<Boolean> boolList = new ArrayList<Boolean>();
-        boolList.add(true);
-        boolList.add(false);
-        m.put("bool-list", boolList);
+        m.put("bool-list", Arrays.asList(new Boolean[]{true, false}));
         m.put("empty-set", new HashSet<Object>());
 
         Set<String> stringSet = new LinkedHashSet<String>();
@@ -77,18 +71,18 @@ public class PropertiesMapperTest {
         int[] intArray = new int[] {1, 2};
         m.put("int-array", intArray);
 
-        String xml = "<xml>" + LF
-            + "<t1 xmlns=\"http://www.acme.org/xmlns/other/v1.0.0\";>" + LF
-            + "<foo type='bar'>haha</foo>" + LF
-            + "</t1>" + LF
+        String xml = "<xml>\n"
+            + "<t1 xmlns=\"http://www.acme.org/xmlns/other/v1.0.0\";>\n"
+            + "<foo type='bar'>haha</foo>\n"
+            + "</t1>\n"
             + "</xml>";
         m.put("someXML", xml);
 
-        List<PropertyType> props = new PropertiesMapper().fromProps(m);
-        EndpointDescriptionType epd = new EndpointDescriptionType();
-        epd.getProperty().addAll(props);
-        byte[] epData = new EndpointDescriptionParser().getData(epd);
-
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        EndpointDescription epd = new EndpointDescription(m);
+        new EndpointDescriptionParser().writeEndpoint(epd, bos);
+        byte[] epData = bos.toByteArray();
+        System.out.println(new String(epData));
         URL edURL = getClass().getResource("/ed2-generated.xml");
         InputSource expectedXml = new InputSource(edURL.openStream());
         InputSource actualXml = new InputSource(new 
ByteArrayInputStream(epData)); 

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
----------------------------------------------------------------------
diff --git 
a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
 
b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
new file mode 100644
index 0000000..63753ac
--- /dev/null
+++ 
b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
@@ -0,0 +1,181 @@
+/**
+ * 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.aries.rsa.discovery.local;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.easymock.EasyMock;
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+
+import junit.framework.TestCase;
+
+public class EndpointDescriptionBundleParserTest extends TestCase {
+
+    private Bundle createBundleContaining(URL ed1URL) {
+        Bundle b = EasyMock.createNiceMock(Bundle.class);
+        EasyMock.expect(b.findEntries(
+            EasyMock.eq("OSGI-INF/remote-service"),
+            EasyMock.eq("*.xml"), EasyMock.anyBoolean())).andReturn(
+                Collections.enumeration(Arrays.asList(ed1URL))).anyTimes();
+        EasyMock.replay(b);
+        return b;
+    }
+    
+    @Test
+    public void testNoRemoteServicesXMLFiles() {
+        Bundle b = EasyMock.createNiceMock(Bundle.class);
+        EasyMock.replay(b);
+
+        List<EndpointDescription> rsElements = new 
EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
+        Assert.assertEquals(0, rsElements.size());
+    }
+
+    public void testAllEndpoints1() {
+        URL ed1URL = getClass().getResource("/ed1.xml");
+
+        Bundle b = createBundleContaining(ed1URL);
+
+        List<EndpointDescription> endpoints = new 
EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
+        assertEquals(4, endpoints.size());
+        EndpointDescription endpoint0 = endpoints.get(0);
+        assertEquals("http://somewhere:12345";, endpoint0.getId());
+        assertEquals(Arrays.asList("SomeService"), endpoint0.getInterfaces());
+        assertEquals(Arrays.asList("confidentiality"),
+            endpoint0.getProperties().get("osgi.remote.requires.intents"));
+        assertEquals("testValue", endpoint0.getProperties().get("testKey"));
+
+        EndpointDescription endpoint1 = endpoints.get(1);
+        assertEquals("myScheme://somewhere:12345", endpoint1.getId());
+        assertEquals(Arrays.asList("SomeOtherService", 
"WithSomeSecondInterface"), endpoint1.getInterfaces());
+
+        EndpointDescription endpoint2 = endpoints.get(2);
+        assertEquals("http://somewhere";, endpoint2.getId());
+        assertEquals(Arrays.asList("SomeOtherService", 
"WithSomeSecondInterface"), endpoint2.getInterfaces());
+
+        EndpointDescription endpoint3 = endpoints.get(3);
+        assertEquals("http://somewhere:1/2/3/4?5";, endpoint3.getId());
+        assertEquals(Arrays.asList("SomeOtherService", 
"WithSomeSecondInterface"), endpoint3.getInterfaces());
+    }
+
+    public void testAllEndpoints2() throws Exception {
+        URL ed2URL = getClass().getResource("/ed2.xml");
+
+        Bundle b = createBundleContaining(ed2URL);
+
+        List<EndpointDescription> endpoints = new 
EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
+        assertEquals(2, endpoints.size());
+        EndpointDescription endpoint0 = endpoints.get(0);
+        assertEquals("foo:bar", endpoint0.getId());
+        assertEquals(Arrays.asList("com.acme.HelloService"), 
endpoint0.getInterfaces());
+        assertEquals(Arrays.asList("SOAP"), endpoint0.getIntents());
+        // changed from exported to imported
+        assertEquals("org.apache.cxf.ws", 
endpoint0.getProperties().get("service.imported.configs"));
+
+        EndpointDescription endpoint1 = endpoints.get(1);
+        Map<String, Object> props = endpoint1.getProperties();
+        assertEquals(Arrays.asList("com.acme.HelloService", 
"some.other.Service"), endpoint1.getInterfaces());
+        assertEquals("org.apache.cxf.ws", 
props.get("service.imported.configs"));
+        // exports should have been removed
+        assertNull(props.get("service.exported.configs"));
+
+        assertEquals(EndpointDescriptionBundleParserTest.normXML("<other:t1 
xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' "
+            + "xmlns='http://www.acme.org/xmlns/other/v1.0.0'><foo 
type='bar'>haha</foo>\n"
+            + "        </other:t1>"),
+            EndpointDescriptionBundleParserTest.normXML((String) 
props.get("someXML")));
+        assertEquals(Long.MAX_VALUE, props.get("long"));
+        assertEquals(-1L, props.get("long2"));
+        assertEquals(Double.MAX_VALUE, props.get("double"));
+        assertEquals(1.0d, props.get("Double2"));
+        assertEquals(42.24f, props.get("float"));
+        assertEquals(1.0f, props.get("Float2"));
+        assertEquals(17, props.get("int"));
+        assertEquals(42, props.get("Integer2"));
+        assertEquals((byte) 127, props.get("byte"));
+        assertEquals((byte) -128, props.get("Byte2"));
+        assertEquals(Boolean.TRUE, props.get("boolean"));
+        assertEquals(Boolean.TRUE, props.get("Boolean2"));
+        assertEquals((short) 99, props.get("short"));
+        assertEquals((short) -99, props.get("Short2"));
+        assertEquals('@', props.get("char"));
+        assertEquals('X', props.get("Character2"));
+
+        int[] intArray = (int[]) props.get("int-array");
+        assertTrue(Arrays.equals(new int[] {1, 2}, intArray));
+
+        Integer[] integerArray = (Integer[]) props.get("Integer-array");
+        assertTrue(Arrays.equals(new Integer[] {2, 1}, integerArray));
+
+        assertEquals(Arrays.asList(true, false), props.get("bool-list"));
+        assertEquals(new HashSet<Object>(), props.get("long-set"));
+        Set<String> stringSet = new HashSet<String>();
+        stringSet.add("Hello there");
+        stringSet.add("How are you?");
+        assertEquals(stringSet, props.get("string-set"));
+        assertEquals("Hello", props.get("other1").toString().trim());
+
+        List<?> l = (List<?>) props.get("other2");
+        assertEquals(1, l.size());
+        assertEquals(EndpointDescriptionBundleParserTest.normXML("<other:t2 
xmlns:other='http://www.acme.org/xmlns/other/v1.0.0' " 
+                                   + 
"xmlns='http://www.osgi.org/xmlns/rsa/v1.0.0'/>"),
+                                   
EndpointDescriptionBundleParserTest.normXML((String) l.get(0)));
+    }
+
+    public static String stripProlog(String s) {
+        return s.replaceAll("<\\?(.*?)\\?>", "");
+    }
+
+    public static String stripComment(String s) {
+        return Pattern.compile("<!--(.*?)-->", 
Pattern.DOTALL).matcher(s).replaceAll("");
+    }
+
+    public static String normXML(String s) {
+        String s2 = stripComment(s);
+        String s3 = stripProlog(s2);
+        try {
+            TransformerFactory transFactory = TransformerFactory.newInstance();
+            Transformer transformer = transFactory.newTransformer();
+            StringWriter buffer = new StringWriter();
+            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, 
"yes");
+            transformer.transform(new StreamSource(new StringReader(s3)), new 
StreamResult(buffer));
+            return buffer.toString();
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListener.java
----------------------------------------------------------------------
diff --git 
a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListener.java
 
b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListener.java
index cda76bc..188c08f 100644
--- 
a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListener.java
+++ 
b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListener.java
@@ -18,6 +18,7 @@
  */
 package org.apache.aries.rsa.discovery.zookeeper.publish;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -30,7 +31,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
-import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
 import org.apache.aries.rsa.discovery.zookeeper.util.Utils;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
@@ -42,8 +42,6 @@ import org.osgi.framework.BundleContext;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.EndpointListener;
 import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
-import org.osgi.xmlns.rsa.v1_0.PropertyType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -87,6 +85,12 @@ public class PublishingEndpointListener implements 
EndpointListener {
             }
         }
     }
+    
+    private byte[] getData(EndpointDescription epd) {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        endpointDescriptionParser.writeEndpoint(epd, bos);
+        return bos.toByteArray();
+    }
 
     private void addEndpoint(EndpointDescription endpoint) throws 
URISyntaxException, KeeperException,
                                                                   
InterruptedException, IOException {
@@ -109,11 +113,7 @@ public class PublishingEndpointListener implements 
EndpointListener {
             String fullPath = path + '/' + endpointKey;
             LOG.info("Creating ZooKeeper node for service with path {}", 
fullPath);
             createPath(path, zk);
-            List<PropertyType> propsOut = new 
PropertiesMapper().fromProps(props);
-            EndpointDescriptionType epd = new EndpointDescriptionType();
-            epd.getProperty().addAll(propsOut);
-            byte[] epData = endpointDescriptionParser.getData(epd);
-            createEphemeralNode(fullPath, epData);
+            createEphemeralNode(fullPath, getData(endpoint));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/subscribe/InterfaceMonitor.java
----------------------------------------------------------------------
diff --git 
a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/subscribe/InterfaceMonitor.java
 
b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/subscribe/InterfaceMonitor.java
index f50848f..bf68081 100644
--- 
a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/subscribe/InterfaceMonitor.java
+++ 
b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/subscribe/InterfaceMonitor.java
@@ -25,7 +25,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
-import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
 import org.apache.aries.rsa.discovery.zookeeper.util.Utils;
 import org.apache.zookeeper.AsyncCallback.StatCallback;
 import org.apache.zookeeper.KeeperException;
@@ -36,7 +35,6 @@ import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.data.Stat;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.EndpointListener;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -240,7 +238,7 @@ public class InterfaceMonitor implements Watcher, 
StatCallback {
             byte[] data = zk.getData(node, false, null);
             LOG.debug("Got data for node: {}", node);
 
-            EndpointDescription endpoint = getFirstEnpointDescription(data);
+            EndpointDescription endpoint = parser.readEndpoint(new 
ByteArrayInputStream(data));
             if (endpoint != null) {
                 return endpoint;
             }
@@ -250,13 +248,4 @@ public class InterfaceMonitor implements Watcher, 
StatCallback {
         }
         return null;
     }
-
-    public EndpointDescription getFirstEnpointDescription(byte[] data) {
-        List<EndpointDescriptionType> elements = 
parser.getEndpointDescriptions(new ByteArrayInputStream(data));
-        if (elements.isEmpty()) {
-            return null;
-        }
-        Map<String, Object> props = new 
PropertiesMapper().toProps(elements.get(0).getProperty());
-        return new EndpointDescription(props);
-    }
 }

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
----------------------------------------------------------------------
diff --git 
a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
 
b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
index 6e6dfb9..919a74d 100644
--- 
a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
+++ 
b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
@@ -20,15 +20,13 @@ package org.apache.aries.rsa.discovery.zookeeper.publish;
 
 import static org.easymock.EasyMock.expect;
 
+import java.io.ByteArrayOutputStream;
 import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
-import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
-import org.apache.aries.rsa.discovery.zookeeper.publish.DiscoveryPlugin;
-import 
org.apache.aries.rsa.discovery.zookeeper.publish.PublishingEndpointListener;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooDefs.Ids;
@@ -45,8 +43,6 @@ import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
-import org.osgi.xmlns.rsa.v1_0.PropertyType;
 
 import junit.framework.TestCase;
 
@@ -99,10 +95,10 @@ public class PublishingEndpointListenerTest extends 
TestCase {
         final ZooKeeper zk = EasyMock.createNiceMock(ZooKeeper.class);
         String expectedFullPath = 
"/osgi/service_registry/org/foo/myClass/some.machine#9876##test";
         
-        List<PropertyType> props2 = new 
PropertiesMapper().fromProps(expectedProps);
-        EndpointDescriptionType epd = new EndpointDescriptionType();
-        epd.getProperty().addAll(props2);
-        byte[] data = new EndpointDescriptionParser().getData(epd);
+        EndpointDescription epd = new EndpointDescription(expectedProps);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        new EndpointDescriptionParser().writeEndpoint(epd, bos);
+        byte[] data = bos.toByteArray();
         expectCreated(zk, expectedFullPath, EasyMock.aryEq(data));
         EasyMock.replay(zk);
 

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/990752a7/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestDiscoveryExport.java
----------------------------------------------------------------------
diff --git 
a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestDiscoveryExport.java
 
b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestDiscoveryExport.java
index f8a8271..997872d 100644
--- 
a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestDiscoveryExport.java
+++ 
b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/tcp/TestDiscoveryExport.java
@@ -21,12 +21,10 @@ package org.apache.aries.rsa.itests.felix.tcp;
 
 import java.io.ByteArrayInputStream;
 import java.util.List;
-import java.util.Map;
 
 import javax.inject.Inject;
 
 import org.apache.aries.rsa.discovery.endpoint.EndpointDescriptionParser;
-import org.apache.aries.rsa.discovery.endpoint.PropertiesMapper;
 import org.apache.aries.rsa.examples.echotcp.api.EchoService;
 import org.apache.aries.rsa.itests.felix.RsaTestBase;
 import org.apache.aries.rsa.spi.DistributionProvider;
@@ -42,7 +40,6 @@ import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType;
 
 @RunWith(PaxExam.class)
 public class TestDiscoveryExport extends RsaTestBase {
@@ -85,9 +82,7 @@ public class TestDiscoveryExport extends RsaTestBase {
         throws KeeperException, InterruptedException {
         byte[] data = zk.getData(endpointPath, false, null);
         ByteArrayInputStream is = new ByteArrayInputStream(data);
-        List<EndpointDescriptionType> epdList = new 
EndpointDescriptionParser().getEndpointDescriptions(is);
-        Map<String, Object> props = new 
PropertiesMapper().toProps(epdList.get(0).getProperty());
-        return new EndpointDescription(props);
+        return new EndpointDescriptionParser().readEndpoint(is);
     }
 
     private String getEndpointPath(ZooKeeper zk, String servicePath) throws 
KeeperException, InterruptedException {

Reply via email to