You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by eg...@apache.org on 2008/11/10 17:30:21 UTC

svn commit: r712686 - in /cxf/sandbox/dosgi: discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ dsw/cxf-dsw/src/main/java/...

Author: eglynn
Date: Mon Nov 10 08:30:20 2008
New Revision: 712686

URL: http://svn.apache.org/viewvc?rev=712686&view=rev
Log:
[dOSGi] Updated to latest Collections-based version of Discovery service APIs

Modified:
    cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java
    cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ServiceEndpointDescriptionImpl.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/TestUtils.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java
    cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/Discovery.java
    cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/FindServiceCallback.java
    cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java
    cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceListener.java

Modified: cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java (original)
+++ cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryService.java Mon Nov 10 08:30:20 2008
@@ -29,6 +29,7 @@
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.BlockingQueue;
@@ -115,11 +116,8 @@
         listeners.remove(sl);
     }
     
-    public ServiceEndpointDescription[] findService(String interfaceName, String filter) {
-        Collection<ServiceEndpointDescription> sds =
-            findServiceWithFilter(interfaceName, createFilter(filter));
-        return sds.toArray(new ServiceEndpointDescription[]{});
-        
+    public Collection /*<ServiceEndpointDescription>*/ findService(String interfaceName, String filter) {
+        return findServiceWithFilter(interfaceName, createFilter(filter));
     }
     
     public void findService(String interfaceName, String filter, FindServiceCallback listener) {
@@ -178,7 +176,7 @@
         if (sds.isEmpty()) {
             return false;
         } else {
-            listener.servicesFound(sds.toArray(new ServiceEndpointDescription[]{}));
+            listener.servicesFound(sds);
             return true;
         }
     }
@@ -426,14 +424,15 @@
     
     private static String[] getInterfaceNames(ServiceEndpointDescription sd, String interfaceName) {
         
-        String[] interfaceNames = sd.getInterfaceNames();
+        Collection interfaceNames = sd.getInterfaceNames();
         if (interfaceName == null) {
-            return interfaceNames;
+            return null;
         }
         
-        for (String s : interfaceNames) {
-            if (s.equals(interfaceName)) {
-                return new String[]{s};
+	Iterator iNames = interfaceNames.iterator();
+        while (iNames.hasNext()) {
+            if (iNames.next().equals(interfaceName)) {
+                return new String[]{interfaceName};
             }
         }
         return null;

Modified: cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java (original)
+++ cxf/sandbox/dosgi/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java Mon Nov 10 08:30:20 2008
@@ -105,8 +105,8 @@
         return null;
     }
 
-    public String[] getInterfaceNames() {
-        return interfaceNames.toArray(new String[]{});
+    public Collection /*<String>*/ getInterfaceNames() {
+        return interfaceNames;
     }
 
     public String getProtocolSpecificInterfaceName(String interfaceName) {

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/OsgiUtils.java Mon Nov 10 08:30:20 2008
@@ -144,11 +144,12 @@
 
     public static ServiceEndpointDescription[] flattenServiceDescription(ServiceEndpointDescription sd) {
         ServiceEndpointDescription[] list = null;
-        if (sd.getInterfaceNames() == null 
-            || sd.getInterfaceNames().length <= 1) {
+	int interfaceNameCount = sd.getInterfaceNames().size();
+        if (sd.getInterfaceNames() == null || interfaceNameCount <= 1) {
             list = new ServiceEndpointDescription[] {sd};
         } else {
-            String[] iNames = sd.getInterfaceNames();
+            String[] iNames = (String[])
+                sd.getInterfaceNames().toArray(new String[interfaceNameCount]);
             list = new ServiceEndpointDescription[iNames.length];
             for (int i = 0; i < iNames.length; i++) {
                 Map<String, Object> props =  
@@ -275,7 +276,9 @@
     
     public static String[] getInterfaceNames(ServiceEndpointDescription sd, String interfaceName) {
         
-        String[] interfaceNames = sd.getInterfaceNames();
+	int interfaceNameCount = sd.getInterfaceNames().size();
+        String[] interfaceNames = (String[])
+            sd.getInterfaceNames().toArray(new String[interfaceNameCount]);
         if (interfaceName == null) {
             return interfaceNames;
         }

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactory.java Mon Nov 10 08:30:20 2008
@@ -46,6 +46,9 @@
     }
     
     public Object getService(Bundle requestingBundle, ServiceRegistration sreg) {        
+        String interfaceName = sd.getInterfaceNames() != null && sd.getInterfaceNames().size() > 0
+	                       ? (String)sd.getInterfaceNames().toArray()[0]
+			       : null;
         try {
             return handler.createProxy(sreg.getReference(), 
                                        dswContext, 
@@ -53,12 +56,12 @@
                                        iClass,
                                        sd);
         } catch (IntentUnsatifiedException iue) {
-            LOG.info("Did not create proxy for " + sd.getInterfaceNames()[0] + " because intent " +
+            LOG.info("Did not create proxy for " + interfaceName + " because intent " +
                     iue.getIntent() + " could not be satisfied");
         } catch (Exception ex) {
             LOG.log(Level.WARNING,
                     "Problem creating a remote proxy for " 
-                    + sd.getInterfaceNames()[0] + " from CXF FindHook: ", 
+                    + interfaceName + " from CXF FindHook: ", 
                     ex);
         }
         

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java Mon Nov 10 08:30:20 2008
@@ -73,8 +73,8 @@
             return null;
         }
         
-        LOG.info("Creating a " + sd.getInterfaceNames()[0] + " client, endpoint address is "
-                 + address);
+        LOG.info("Creating a " + sd.getInterfaceNames().toArray()[0]
+                 + " client, endpoint address is " + address);
 
 
         try {
@@ -110,7 +110,7 @@
             return null;
         }
         
-        LOG.info("Creating a " + sd.getInterfaceNames()[0]
+        LOG.info("Creating a " + sd.getInterfaceNames().toArray()[0]
             + " endpoint from CXF PublishHook, address is " + address);
         
         ServerFactoryBean factory = createServerFactoryBean();

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java Mon Nov 10 08:30:20 2008
@@ -64,7 +64,7 @@
             return null;
         }
         
-        LOG.info("Creating a " + sd.getInterfaceNames()[0] + " client, wsdl address is "
+        LOG.info("Creating a " + sd.getInterfaceNames().toArray()[0] + " client, wsdl address is "
                  + OsgiUtils.getProperty(sd, Constants.WSDL_CONFIG_PREFIX));
         
         String serviceNs = OsgiUtils.getProperty(sd, Constants.SERVICE_NAMESPACE);

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java Mon Nov 10 08:30:20 2008
@@ -143,18 +143,12 @@
         if (sds.isEmpty()) {
             // try discovery service
             
-            // REVISIT Discovery RI will change soon to use standard "objectClass" 
-            // property key, instead of "interface-name". At that point we can
-            // just reuse the given filter instead of constructing a modified one. Also
-            // we currently throw away any filter predicates unrelated to the interface
-            // name, which is clearly inappropriate.
-            
-            String modifiedFilter = 
-                "(" + ServiceEndpointDescription.PROP_KEY_INTERFACE_NAME 
-                + "=" + interfaceName + ")";
+            // Discovery RI uses standard "objectClass" property key, 
+            // so we cano just reuse the given filter instead of constructing
+            // a modified one. 
 
             Collection<ServiceEndpointDescription> discovered = 
-                getFromDiscoveryService(interfaceName, modifiedFilter);
+                getFromDiscoveryService(interfaceName, filterValue);
             if (discovered.size() != 0) {
                 LOG.info("synchronous lookup discovered " + discovered.size()
                          + " references for interface: " + interfaceName);
@@ -163,7 +157,7 @@
                 LOG.info("nothing discovered initially for interface: " 
                          + interfaceName +  ", fallback to async lookup");
                 if (filterValue != null && filterValue.length() > 0) {
-                    LOG.fine("installing service listener for: " + modifiedFilter);
+                    LOG.fine("installing service listener for: " + filterValue);
                     listenToDiscoveryService(
                         new ServiceListener() {
                             public void serviceAvailable(ServiceEndpointDescription sd) {
@@ -190,7 +184,7 @@
                                 // so to allow to drive transparent fail-over
                             }                        
                         },
-                        modifiedFilter);
+                        filterValue);
                 }
             }
         }

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java Mon Nov 10 08:30:20 2008
@@ -100,10 +100,10 @@
         OsgiService<Discovery> pair = OsgiUtils.getOsgiService(getContext(), Discovery.class);
         if (pair != null) {
             try {
-                ServiceEndpointDescription[] sds =
+                Collection sds =
                     pair.getService().findService(interfaceName, filterValue);
                 if (sds != null) {
-                    return Arrays.asList(sds);
+                    return (Collection<ServiceEndpointDescription>)sds;
                 }
             } finally {
                 pair.ungetService(getContext());

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java Mon Nov 10 08:30:20 2008
@@ -20,6 +20,7 @@
 
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.logging.Logger;
 
@@ -63,7 +64,7 @@
                                                                properties);
                 
                 if (sdPublished != null) {
-                    LOG.info("Remote " + sd.getInterfaceNames()[0]
+                    LOG.info("Remote " + sd.getInterfaceNames().toArray()[0]
                              + " endpoint has been published into Discovery service");
                 }
             } finally {
@@ -83,10 +84,11 @@
         if (handler == null) {
             return null;
         }
-        
+
+        String interfaceName = (String)sd.getInterfaceNames().toArray()[0];
         // this is an extra sanity check, but do we really need it now ?
-        Class<?> interfaceClass = ClassUtils.getInterfaceClass(serviceObject, 
-                                                               sd.getInterfaceNames()[0]);
+        Class<?> interfaceClass = ClassUtils.getInterfaceClass(serviceObject, interfaceName); 
+                                                               
         if (interfaceClass != null) {
             try {
                 return handler.createServer(serviceReference,
@@ -96,11 +98,11 @@
                                             interfaceClass, 
                                             serviceObject);
             } catch (IntentUnsatifiedException iue) {
-                LOG.info("Did not remote service " + sd.getInterfaceNames()[0] 
+                LOG.info("Did not remote service " + interfaceName
                          + " because intent " + iue.getIntent()
                          + " could not be satisfied");
             } catch (Exception ex) {
-                LOG.warning("WARNING : Problem creating a remote endpoint for " + sd.getInterfaceNames()[0]
+                LOG.warning("WARNING : Problem creating a remote endpoint for " + interfaceName
                         + " from CXF PublishHook, reason is " + ex.getMessage());
             }
         }
@@ -126,7 +128,7 @@
                                                                    Discovery.class);
             if (pair != null) {
                 LOG.info("Unpublishing Service Description for "  
-                          + ei.getServiceDescription().getInterfaceNames()[0] 
+                          + ei.getServiceDescription().getInterfaceNames().toArray()[0] 
                           + " from a Discovery service "); 
                 pair.getService().unpublishService(ei.getServiceDescription());
                 pair.ungetService(ei.getContext());
@@ -147,7 +149,9 @@
     
     private static Map<String, String> getJavaInterfaceVersionMap(ServiceEndpointDescription sd) {
         Map<String, String> interfaceNames = new HashMap<String, String>();
-        for (String interfaceName : sd.getInterfaceNames()) {
+        Iterator iNames = sd.getInterfaceNames().iterator();
+        while (iNames.hasNext()) {
+            String interfaceName = (String)iNames.next();
             interfaceNames.put(interfaceName, sd.getVersion(interfaceName));
         }
         return interfaceNames;

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ServiceEndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ServiceEndpointDescriptionImpl.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ServiceEndpointDescriptionImpl.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ServiceEndpointDescriptionImpl.java Mon Nov 10 08:30:20 2008
@@ -108,8 +108,8 @@
         return null;
     }
 
-    public String[] getInterfaceNames() {
-        return interfaceNames.toArray(new String[]{});
+    public Collection<String> getInterfaceNames() {
+        return interfaceNames;
     }
 
     public String getProtocolSpecificInterfaceName(String interfaceName) {

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/TestUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/TestUtils.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/TestUtils.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/TestUtils.java Mon Nov 10 08:30:20 2008
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.dosgi.dsw;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.easymock.classextension.EasyMock;
 import org.osgi.service.discovery.ServiceEndpointDescription;
 
@@ -28,9 +31,13 @@
     }
 
     public static ServiceEndpointDescription mockServiceDescription(String... interfaceNames) {
+        List<String> iList = new ArrayList<String>();
+        for (String iName : interfaceNames) {
+	    iList.add(iName);
+	}
         ServiceEndpointDescription sd = EasyMock.createNiceMock(ServiceEndpointDescription.class);
         sd.getInterfaceNames();
-        EasyMock.expectLastCall().andReturn(interfaceNames);
+        EasyMock.expectLastCall().andReturn(iList);
         return sd;
     }
     

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java Mon Nov 10 08:30:20 2008
@@ -19,6 +19,7 @@
 package org.apache.cxf.dosgi.dsw.hooks;
 
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Hashtable;
@@ -119,10 +120,10 @@
             ServiceEndpointDescription sd = list.get(i).getServiceDescription();
             assertNotNull(sd);
             assertNotNull(sd.getInterfaceNames());
-            assertEquals(1, sd.getInterfaceNames().length);
-            String[] names = sd.getInterfaceNames();
-            assertEquals(1, names.length);
-            assertEquals(serviceNames[i], names[0]);
+            assertEquals(1, sd.getInterfaceNames().size());
+            Collection names = sd.getInterfaceNames();
+            assertEquals(1, names.size());
+            assertEquals(serviceNames[i], names.toArray()[0]);
             String excludeProp = 
                 org.apache.cxf.dosgi.dsw.Constants.REMOTE_INTERFACES_PROPERTY;
             assertNull(sd.getProperties().get(excludeProp));

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java Mon Nov 10 08:30:20 2008
@@ -18,6 +18,9 @@
   */
 package org.apache.cxf.dosgi.dsw.hooks;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import junit.framework.TestCase;
 
 import org.apache.cxf.dosgi.dsw.TestUtils;
@@ -71,9 +74,13 @@
     
     private ServiceEndpointDescription mockServiceDescription(IMocksControl control, 
                                                              String... interfaceNames) {
+        List<String> iList = new ArrayList<String>();
+        for (String iName : interfaceNames) {
+	    iList.add(iName);
+	}
         ServiceEndpointDescription sd = control.createMock(ServiceEndpointDescription.class);
         sd.getInterfaceNames();
-        EasyMock.expectLastCall().andReturn(interfaceNames);
+        EasyMock.expectLastCall().andReturn(iList);
         return sd;
     }
     

Modified: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/Discovery.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/Discovery.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/Discovery.java (original)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/Discovery.java Mon Nov 10 08:30:20 2008
@@ -16,23 +16,32 @@
 
 package org.osgi.service.discovery;
 
+import java.util.Collection;
 import java.util.Map;
 
 /**
- * 
- * TODO: How to update published ServiceDescriptions? How to identify
- * ServiceDescriptions of the same service instance? <br>
- * TODO: how about to rename auto-publish to push/pull?<br>
- * TODO: how to propagate exceptions in async findService calls?
+ * Interface of the Discovery service. This service allows to publish services
+ * exposed for remote access as well as search for remote services. <BR>
+ * Discovery service implementations usually rely on some discovery protocols or
+ * other information distribution means.
  * 
  * @version $Revision$
  */
 public interface Discovery {
-    final String ORG_OSGI_DISCOVERY = "org.osgi.discovery";
+    /**
+     * 
+     */
+    final String OSGI_DISCOVERY = "osgi.discovery";
 
-    final String ORG_OSGI_DISCOVERY_NONE = "none";
+    /**
+     * 
+     */
+    final String OSGI_DISCOVERY_NONE = "none";
 
-    final String ORG_OSGI_DISCOVERY_AUTO_PUBLISH = "auto-publish";
+    /**
+     * 
+     */
+    final String OSGI_DISCOVERY_AUTO_PUBLISH = "auto-publish";
 
     /**
      * Add a ServiceListener for a particular service description.
@@ -79,23 +88,23 @@
      * Searches for services matching the provided interface name and filter.
      * 
      * @param interfaceName
-     *            name of the interface returned services have to provide. If
-     *            name is null then all services are considered to match.
+     *            name of the interface that returned services have to provide.
+     *            If name is null then all services are considered to match.
      * @param filter
-     *            an LDAP filter which the service has to satisfy. Note that
-     *            <code>ServiceEndpointDescription</code> defines some
-     *            properties for service url, interface version etc.. If filter
-     *            is null all services are considered to match.
-     * @return Array of ServiceEndpointDescription objects matching the service
-     *         that was found to satisfy the find criteria. The Collection may
-     *         be empty if none was found.
+     *            an LDAP filter which the service has to satisfy. If filter is
+     *            null all services are considered to match.
+     * @return Collection of <code>ServiceEndpointDescription</code> objects
+     *         which were found to match interface name and filter. The
+     *         collection is empty if none was found. The collection represents
+     *         a snapshot and as such is not going to be updated in case other matching
+     *         services become available at a later point of time.
      */
-    ServiceEndpointDescription[] findService(String interfaceName, String filter);
+    Collection /* <? extends ServiceEndpointDescription> */findService(
+            String interfaceName, String filter);
 
     /**
-     * Asynchronous version of
-     * <code>Discovery.findService(String interfaceName, String filter)</code>
-     * method.
+     * Asynchronous version of <code>Discovery.findService(String interfaceName,
+     * String filter)</code> method.
      * 
      * @param interfaceName
      *            name of the interface returned services have to provide. If
@@ -113,51 +122,70 @@
      * @see #findService(String, String)
      */
     void findService(String interfaceName, String filter,
-                    FindServiceCallback callback);
+            FindServiceCallback callback);
 
     /**
-     * Publish the provided service description. If the property
-     * org.osgi.discovery = auto-publish, the Discovery implementation actively
-     * pushes the information about the service to the network. Otherwise, it is
-     * just available upon request from other Discovery implementations.
-     * 
-     * @param javaInterfaces map containing java interface and version pairs
-     * @param endpointInterfaces map containing java interface and protocol-specific
-     *        interface names, can be empty
-     * @param properties common interface properties
-     * * @param autopublish
+     * Publish the provided service meta-data.
+     * 
+     * @param javaInterfacesAndVersions
+     *            names of java interfaces offered by the service and their
+     *            version. For every interface to publish you have to define its
+     *            version. If you don't have a version, put "0.0.0" in it.
+     * @param javaInterfacesAndEndpointInterfaces
+     *            associates java interfaces to general end point interface
+     *            names. It is not needed to to have and end point interface for
+     *            a java interface. The map may be null.
+     * @param properties
+     *            a bag of service properties (key-value pairs) to be published.
+     *            It may be null. Note that Discovery might make use of certain
+     *            standard properties like the ones defined by
+     *            {@link ServiceEndpointDescription} for the publication process
+     *            if they are provided.
+     * 
+     * @return an instance of {@link ServiceEndpointDescription} or null if the
+     *         publishing failed
+     * 
+     * @throws IllegalArgumentException
+     *             if javaInterfacesAndVersions is null or empty
+     */
+    ServiceEndpointDescription publishService(
+            Map/* <String, String> */javaInterfacesAndVersions,
+            Map/* <String, String> */javaInterfacesAndEndpointInterfaces,
+            Map/* <String, Object> */properties);
+
+    /**
+     * Publish the provided service. The information is published by the
+     * Discovery implementation.<b> If the parameter autopublish=true, the
+     * Discovery implementation actively pushes the information about the
+     * service to the network. Otherwise, it is just available upon request from
+     * other Discovery implementations. The ServiceEndpointDescription is
+     * matched using the Comparable interface.
+     * 
+     * @param javaInterfacesAndVersions
+     *            its an association between interfaces and versions. For every
+     *            interface to publish you have to define its version. If you
+     *            don't have a version, put "0.0.0" in it.
+     * @param javaInterfacesAndEndpointInterfaces
+     *            associates java interfaces to general end point interface
+     *            names. It is not needed to to have and end point interface for
+     *            a java interface. The map can be null.
+     * @param properties
+     *            a bag of properties to be published; can be null
+     * @param autopublish
      *            if true, service information is actively pushed to the network
      *            for discovery
-     * @return ServiceEndpointDescription if the service was successfully published.
+     * 
+     * @return an instance of {@link ServiceEndpointDescription} or null if the
+     *         publishing failed
+     * 
      * @throws IllegalArgumentException
-     *             if serviceEndpointDescription is null, incomplete or invalid
-     *             (e.g. contains unknown property types)
+     *             if javaInterfacesAndVersions is null or empty
      */
-    ServiceEndpointDescription publishService(Map javaInterfaces,
-                                              Map endpointInterfaces,
-                                              Map properties);
-    
-    /**
-     * Publish the provided service description. If the property
-     * org.osgi.discovery = auto-publish, the Discovery implementation actively
-     * pushes the information about the service to the network. Otherwise, it is
-     * just available upon request from other Discovery implementations.
-     * 
-     * @param javaInterfaces map containing java interface and version pairs
-     * @param endpointInterfaces map containing java interface and protocol-specific
-     *        interface names, can be empty
-     * @param properties common interface properties
-     * @return ServiceEndpointDescription if the service was successfully published.
-     * @throws IllegalArgumentException
-     *             if serviceEndpointDescription is null, incomplete or invalid
-     *             (e.g. contains unknown property types)
-     */
-    ServiceEndpointDescription publishService(Map javaInterfaces,
-                                              Map endpointInterfaces,
-                                              Map properties,
-                                              boolean autoPublish);
+    ServiceEndpointDescription publishService(
+            Map/* <String, String> */javaInterfacesAndVersions,
+            Map/* <String, String> */javaInterfacesAndEndpointInterfaces,
+            Map/* <String, Object> */properties, boolean autopublish);
 
-    
     /**
      * Make the given service un-discoverable. The previous publish request for
      * a service is undone. The service information is also removed from the

Modified: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/FindServiceCallback.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/FindServiceCallback.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/FindServiceCallback.java (original)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/FindServiceCallback.java Mon Nov 10 08:30:20 2008
@@ -16,16 +16,27 @@
 
 package org.osgi.service.discovery;
 
+import java.util.Collection;
+
 /**
- * 
+ * Interface for callback objects, which can be provided with an asynchronous
+ * find service operation and which will be called when the operation actually
+ * finished.
  * 
  * @version $Revision$
  */
 public interface FindServiceCallback {
     /**
+     * Callback indicating that a previously started asynchronous find service
+     * operation finished.
+     * 
      * @param serviceEndpointDescriptions
-     *            Array of ServiceDescription objects satisfying the find criteria. The returned array is never null but
-     *            may be empty if none was found.
+     *            ServiceDescription objects satisfying the provided find
+     *            criteria. The collection is never null but may be empty if
+     *            none was found. The collection represents a snapshot and as
+     *            such is not going to be updated in case other matching
+     *            services become available at a later point of time.
      */
-    void servicesFound(ServiceEndpointDescription[] serviceEndpointDescriptions);
+    void servicesFound(
+            Collection /* <? extends ServiceEndpointDescription> */serviceEndpointDescriptions);
 }

Modified: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java (original)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceEndpointDescription.java Mon Nov 10 08:30:20 2008
@@ -21,54 +21,52 @@
 import java.util.Map;
 
 /**
- * The ServiceEndpointDescription interface describes an endpoint of a service. This class can be considered as a
- * wrapper around the property map associated with a service and its endpoint. It provides an API to conveniently access
+ * The ServiceEndpointDescription interface describes an endpoint of a service.
+ * This class can be considered as a wrapper around the property map associated
+ * with a service and its endpoint. It provides an API to conveniently access
  * the most important properties of the service.
  * 
- * It's strongly recommended to override <code>Object.equals<code> method to implement an appropriate equivalence 
- * comparison for ServiceEndpointDescription objects. 
- * 
  * @version $Revision$
  */
 public interface ServiceEndpointDescription {
     /**
-     * If value of <code>getInterfaceName</code> needs to be described as a key-value pair e.g. by the discovery
-     * protocol, filter for discovery etc. and there is no other key standardized for that purpose yet, then this is the
-     * recommended property key to use.
-     */
-    public final String PROP_KEY_INTERFACE_NAME = "interface-name";
-
-    /**
-     * If value of <code>getProtocolSpecificInterfaceName</code> needs to be described as a key-value pair e.g. by the
-     * discovery protocol, filter for discovery etc. and there is no other key standardized for that purpose yet, then
-     * this is the recommended property key to use.
+     * If value of <code>getProtocolSpecificInterfaceName</code> needs to be
+     * described as a key-value pair e.g. by the discovery protocol, filter for
+     * discovery etc. and there is no other key standardized for that purpose
+     * yet, then this is the recommended property key to use.
      */
     public final String PROP_KEY_PROTOCOL_SPECIFIC_INTERFACE_NAME = "protocol-specific-interface-name";
 
     /**
-     * If value of <code>getVersion</code> needs to be described as a key-value pair e.g. by the discovery protocol,
-     * filter for discovery etc. and there is no other key standardized for that purpose yet, then this is the
+     * If value of <code>getVersion</code> needs to be described as a key-value
+     * pair e.g. by the discovery protocol, filter for discovery etc. and there
+     * is no other key standardized for that purpose yet, then this is the
      * recommended property key to use.
      */
     public final String PROP_KEY_VERSION = "version";
 
     /**
-     * If value of <code>getServiceLocation</code> needs to be described as a key-value pair e.g. by the discovery
-     * protocol, filter for discovery etc. and there is no other key standardized for that purpose yet, then this is the
-     * recommended property key to use.
+     * If value of <code>getServiceLocation</code> needs to be described as a
+     * key-value pair e.g. by the discovery protocol, filter for discovery etc.
+     * and there is no other key standardized for that purpose yet, then this is
+     * the recommended property key to use.
      */
     public final String PROP_KEY_SERVICE_LOCATION = "location";
 
     /**
-     * @return array of full qualified service interface names provided by the advertised service (endpoint).
+     * @return full qualified service interface names provided by the advertised
+     *         service (endpoint). The collection is never null or
+     *         empty but contains at least one service interface. 
      */
-    String[] getInterfaceNames();
+    Collection /* <? extends String> */getInterfaceNames();
 
     /**
      * @param interfaceName
-     *            for which its communication protocol specific version should be returned. It might be for instance a
-     *            web service interface name. Though this information is usually contained in according interface
-     *            descriptions, e.g. a wsdl file, it can optionally be provided here as well since discovery usually
+     *            for which its communication protocol specific version should
+     *            be returned. It might be for instance a web service interface
+     *            name. Though this information is usually contained in
+     *            according interface descriptions, e.g. a wsdl file, it can
+     *            optionally be provided here as well since discovery usually
      *            doesn't read and interprets such accompanying descriptions.
      * 
      * @return The protocol specific service interface name.
@@ -97,12 +95,22 @@
     Object getProperty(String key);
 
     /**
-     * @return <code>java.util.Collection</code> of the property names available in the ServiceDescription
-     */
-    Collection getPropertyKeys();
-
-    /**
-     * @return Returns all properties of the service as a <code>java.util.Map</code>.
+     * @return <code>java.util.Collection</code> of property names available in
+     *         the ServiceEndpointDescription. The collection is never null or
+     *         empty but contains at least basic properties like objectClass for
+     *         the service interface. The collection represents a snapshot and
+     *         as such is not going to be updated in case properties were added
+     *         or removed at a later point of time.
+     */
+    Collection/* <? extends String> */getPropertyKeys();
+
+    /**
+     * @return Returns all properties of the service as a
+     *         <code>java.util.Map</code>. The map is never null or empty but
+     *         contains at least basic properties like objectClass for the
+     *         service interface. The collection represents a snapshot and as
+     *         such is not going to be updated in case properties were added or
+     *         removed at a later point of time.
      */
-    Map getProperties();
+    Map/* <String, Object> */getProperties();
 }

Modified: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceListener.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceListener.java?rev=712686&r1=712685&r2=712686&view=diff
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceListener.java (original)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/ServiceListener.java Mon Nov 10 08:30:20 2008
@@ -17,36 +17,42 @@
 package org.osgi.service.discovery;
 
 /**
- * 
- * TODO: consider whether methods should also contain a source object (the particular discovery service which does the
- * notification)
+ * Describes the interface of listeners, which can be registered with
+ * Discovery to be notified on life-cycle changes of remote services.
  * 
  * @version $Revision$
  */
 public interface ServiceListener {
     /**
-     * Callback indicating that the specified service was discovered and is known to the calling Discovery
-     * implementation.
+     * Callback indicating that a service matching the listening criteria was
+     * discovered and is known to the calling Discovery implementation.
      * 
      * @param serviceEndpointDescription
+     *            meta-data which is known to Discovery regarding the new
+     *            service.
      */
     void serviceAvailable(ServiceEndpointDescription serviceEndpointDescription);
 
     /**
-     * Callback indicating a change in the service endpoint description of a previously discovered service.
+     * Callback indicating a change in the service endpoint description of a
+     * previously discovered service.
      * 
      * @param oldDescription
      *            previous service endpoint description
      * @param newDescription
      *            new service endpoint description
      */
-    void serviceModified(ServiceEndpointDescription oldDescription, ServiceEndpointDescription newDescription);
+    void serviceModified(ServiceEndpointDescription oldDescription,
+            ServiceEndpointDescription newDescription);
 
     /**
-     * Callback indicating that the specified service endpoint is no longer available.
+     * Callback indicating that a previously discovered service endpoint is no longer
+     * available.
      * 
      * @param serviceEndpointDescription
-     *            ServiceEndpointDescription of the service that is no longer available
+     *            ServiceEndpointDescription of the service that is no longer
+     *            available
      */
-    void serviceUnavailable(ServiceEndpointDescription serviceEndpointDescription);
+    void serviceUnavailable(
+            ServiceEndpointDescription serviceEndpointDescription);
 }