cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r704530 - 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/hooks/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ felix/framework/src/m...
Date Tue, 14 Oct 2008 13:13:36 GMT
Author: sergeyb
Date: Tue Oct 14 06:13:35 2008
New Revision: 704530

URL: http://svn.apache.org/viewvc?rev=704530&view=rev
Log:
DOSGI : updating Discovery interface as agreed by the group

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/hooks/ServiceHookUtils.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ServiceEndpointDescriptionImpl.java
    cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/discovery/Discovery.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=704530&r1=704529&r2=704530&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
Tue Oct 14 06:13:35 2008
@@ -183,11 +183,21 @@
         }
     }
     
-    public boolean publishService(ServiceEndpointDescription sd) {
-        return publishService(sd, false);
+    public ServiceEndpointDescription publishService(Map javaInterfaces,
+                                                     Map endpointInterfaces,
+                                                     Map properties) {
+        return publishService(javaInterfaces, endpointInterfaces, properties, true);
+        
     }
     
-    public boolean publishService(ServiceEndpointDescription sd, boolean autoPublish) {
+    @SuppressWarnings("unchecked")
+    public ServiceEndpointDescription publishService(Map javaInterfaces,
+                                                     Map endpointInterfaces,
+                                                     Map properties, 
+                                                     boolean autoPublish) {
+        ServiceEndpointDescriptionImpl sd = new ServiceEndpointDescriptionImpl(javaInterfaces,
+                                                                               endpointInterfaces,
+                                                                               properties);
         servicesInfo.putIfAbsent(sd, sd);
         for (Map.Entry<ServiceListener, Filter> entry : listeners.entrySet()) {
             if (entry.getValue() == null 
@@ -195,7 +205,7 @@
                 entry.getKey().serviceAvailable(sd);
             }
         }
-        return true;
+        return sd;
     }
     
     public void unpublishService(ServiceEndpointDescription sd) {

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=704530&r1=704529&r2=704530&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
Tue Oct 14 06:13:35 2008
@@ -54,6 +54,13 @@
         properties = remoteProperties;
     }
     
+    public ServiceEndpointDescriptionImpl(Map<String, String> javaInterfaces,
+                                          Map<String, String> endpointInterfaces,
+                                          Map<String, Object> remoteProperties) {
+        this.interfaceNames = new HashSet<String>(javaInterfaces.keySet());
+        properties = remoteProperties;
+    }
+    
     public Object getProperty(String key) {
         return properties.get(key);
     }
@@ -107,7 +114,6 @@
     }
 
     public String getVersion(String interfaceName) {
-        // TODO Auto-generated method stub
-        return null;
+        return "0.0";
     }
 }

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=704530&r1=704529&r2=704530&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
Tue Oct 14 06:13:35 2008
@@ -18,6 +18,8 @@
   */
 package org.apache.cxf.dosgi.dsw.hooks;
 
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.logging.Logger;
 
@@ -45,12 +47,18 @@
     
     public static boolean publish(BundleContext bc, ServiceEndpointDescription sd) {
         
-        boolean published = false;
+        ServiceEndpointDescription sdPublished = null;
         OsgiService<Discovery> pair = OsgiUtils.getOsgiService(bc, Discovery.class);
         if (pair != null) {
             try {
-                published = pair.getService().publishService(sd);
-                if (published) {
+                Map<String, String> javaInterfaces = getJavaInterfaceVersionMap(sd);
+                Map<String, String> endpointInterfaces = getJavaInterfaceEndpointInterfaceMap(sd);
+                Map<String, Object> properties = getPropertiesMap(sd);
+                sdPublished = pair.getService().publishService(javaInterfaces,
+                                                               endpointInterfaces,
+                                                               properties);
+                
+                if (sdPublished != null) {
                     LOG.info("Remote " + sd.getInterfaceNames()[0]
                              + " endpoint has been published into Discovery service");
                 }
@@ -58,7 +66,7 @@
                 pair.ungetService(bc);
             }
         }
-        return published;
+        return sdPublished != null;
     }
     
     public static Server createServer(ConfigurationTypeHandler handler,
@@ -131,4 +139,24 @@
     public static boolean isCreatedByDsw(ServiceReference sref) {
         return sref != null && sref.getProperty(Constants.DSW_CLIENT_ID) != null;
     }
+    
+    private static Map<String, String> getJavaInterfaceVersionMap(ServiceEndpointDescription
sd) {
+        Map<String, String> interfaceNames = new HashMap<String, String>();
+        for (String interfaceName : sd.getInterfaceNames()) {
+            interfaceNames.put(interfaceName, sd.getVersion(interfaceName));
+        }
+        return interfaceNames;
+    }
+    
+    private static Map<String, String> getJavaInterfaceEndpointInterfaceMap(ServiceEndpointDescription
sd) {
+        return Collections.emptyMap();
+    }
+    
+    private static Map<String, Object> getPropertiesMap(ServiceEndpointDescription
sd) {
+        Map<String, Object> props = new HashMap<String, Object>();
+        for (Object key : sd.getPropertyKeys()) {
+            props.put(key.toString(), sd.getProperty(key.toString()));
+        }
+        return props;
+    }
 }

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=704530&r1=704529&r2=704530&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
Tue Oct 14 06:13:35 2008
@@ -117,7 +117,6 @@
     }
 
     public String getVersion(String interfaceName) {
-        // TODO Auto-generated method stub
-        return null;
+        return "0.0";
     }
 }

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=704530&r1=704529&r2=704530&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
Tue Oct 14 06:13:35 2008
@@ -16,6 +16,8 @@
 
 package org.osgi.service.discovery;
 
+import java.util.Map;
+
 /**
  * 
  * TODO: How to update published ServiceDescriptions? How to identify
@@ -119,37 +121,43 @@
      * pushes the information about the service to the network. Otherwise, it is
      * just available upon request from other Discovery implementations.
      * 
-     * @param serviceEndpointDescription
-     *            ServiceEndpointDescription of the service to publish
-     * @return true if the service was successfully published.
+     * @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
+     *            if true, service information is actively pushed to the network
+     *            for discovery
+     * @return ServiceEndpointDescription if the service was successfully published.
      * @throws IllegalArgumentException
      *             if serviceEndpointDescription is null, incomplete or invalid
      *             (e.g. contains unknown property types)
      */
-    boolean publishService(ServiceEndpointDescription serviceEndpointDescription);
-
+    ServiceEndpointDescription publishService(Map javaInterfaces,
+                                              Map endpointInterfaces,
+                                              Map 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.
+     * 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 serviceEndpointDescription
-     *            ServiceEndpointDescription of the service to publish
-     * @param autopublish
-     *            if true, service information is actively pushed to the network
-     *            for discovery
-     * @return true if the service was successfully published.
+     * @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)
      */
-    boolean publishService(
-                    ServiceEndpointDescription serviceEndpointDescription,
-                    boolean autopublish);
+    ServiceEndpointDescription publishService(Map javaInterfaces,
+                                              Map endpointInterfaces,
+                                              Map 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



Mime
View raw message