cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r703368 - in /cxf/sandbox/dosgi: discovery/local/src/test/resources/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ d...
Date Fri, 10 Oct 2008 09:42:09 GMT
Author: eglynn
Date: Fri Oct 10 02:42:09 2008
New Revision: 703368

URL: http://svn.apache.org/viewvc?rev=703368&view=rev
Log:
[dOSGi] Adding support for remote publication of selected interfaces exposed by a multi-interface
OSGi service

Added:
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml
  (with props)
Modified:
    cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.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/hooks/AbstractClientHook.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.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/OsgiUtilsTest.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/resources/OSGI-INF/remote-services/remote-services.xml
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/test-resources/rs2.xml
    cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml
    cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml
    cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml
    cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml
    cxf/sandbox/dosgi/systests/basic/src/test/resources/OSGI-INF/remote-services/remote-services.xml

Modified: cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml (original)
+++ cxf/sandbox/dosgi/discovery/local/src/test/resources/remote-services.xml Fri Oct 10 02:42:09
2008
@@ -16,14 +16,14 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.GreeterService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
     <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9005/greeter</property>
   </service-description>
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.GreeterService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
     <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:10000/greeter</property>

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java Fri
Oct 10 02:42:09 2008
@@ -23,7 +23,7 @@
     
     public static final String REMOTE_PROPERTY_PREFIX = "osgi.remote";
     
-    public static final String REMOTE_INTERFACES_PROPERTY = REMOTE_PROPERTY_PREFIX + ".interfaces";
+    public static final String REMOTE_INTERFACES_PROPERTY = REMOTE_PROPERTY_PREFIX + ".publish.interfaces";
     public static final String REQUIRES_INTENTS_PROPERTY = REMOTE_PROPERTY_PREFIX + ".requires.intents";
     public static final String CONFIGURATION_PROPERTY = ".configuration";
 

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=703368&r1=703367&r2=703368&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 Fri
Oct 10 02:42:09 2008
@@ -31,6 +31,7 @@
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.util.StringTokenizer;
 
 import org.apache.cxf.dosgi.dsw.qos.IntentMap;
 import org.apache.cxf.dosgi.dsw.service.ServiceEndpointDescriptionImpl;
@@ -136,6 +137,36 @@
         return srefs;
         
     }
+
+    public static ServiceEndpointDescription[] flattenServiceDescription(ServiceEndpointDescription
sd) {
+        ServiceEndpointDescription[] list = null;
+        if (sd.getInterfaceNames() == null 
+            || sd.getInterfaceNames().length <= 1) {
+            list = new ServiceEndpointDescription[] {sd};
+        } else {
+            String[] iNames = sd.getInterfaceNames();
+            list = new ServiceEndpointDescription[iNames.length];
+            for (int i = 0; i < iNames.length; i++) {
+                Map<String, Object> props =  
+                    excludeProperty(sd.getProperties(),  
+                                    Constants.REMOTE_INTERFACES_PROPERTY);
+                list[i] = new ServiceEndpointDescriptionImpl(iNames[i], props);
+            }
+        }
+        return list;
+    }
+
+    private static Map<String, Object> excludeProperty(Map properties, 
+                                                       String exlcude) {
+        Map<String, Object> pruned = new HashMap<String, Object>();
+        for (Object key : properties.keySet()) {
+            if (key.equals(exlcude)) {
+            } else {
+                pruned.put((String)key, properties.get(key));
+            }
+        }
+        return pruned;
+    }
     
     @SuppressWarnings("unchecked")
     public static List<Element> getAllDescriptionElements(Bundle b) {
@@ -396,4 +427,64 @@
         }
         return type.isAssignableFrom(o.getClass()) ? (T)o : null;
     }
+
+    public static String[] getPublishableInterfaces(ServiceEndpointDescription sd,
+                                                    ServiceReference sref) {
+        String publishProperty = 
+            (String)sd.getProperty(Constants.REMOTE_INTERFACES_PROPERTY);
+        String[] actualInterfaces = 
+            (String[])sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
+        String[] publishableInterfaces = null;
+
+        if (actualInterfaces != null
+            && actualInterfaces.length > 0
+            && publishProperty != null
+            && publishProperty.length() > 0) {
+
+            if ("*".equals(publishProperty)) {
+                // wildcard indicates all interfaces should be published
+                //
+                publishableInterfaces = actualInterfaces;
+            } else {
+                String[] requestedInterfaces = tokenize(publishProperty, ",");
+                ArrayList<String> publishableList = new ArrayList<String>();
+
+                for (int i = 0; i < requestedInterfaces.length; i++) {
+                    if (contains(actualInterfaces, requestedInterfaces[i])) {
+                        publishableList.add(requestedInterfaces[i]);
+                    } else {
+                        // simply ignore non-exposed interfaces
+                        //
+                        LOG.warning("ignoring publish interface, " 
+                                    + requestedInterfaces[i] 
+                                    + ", not exposed by service");
+                    }
+                }
+
+                if (publishableList.size() > 0) {
+                    publishableInterfaces = 
+                        publishableList.toArray(new String[publishableList.size()]);
+                }
+            }
+        }
+
+        return publishableInterfaces;
+    }
+
+    private static String[] tokenize(String str, String delim) {
+        StringTokenizer tokenizer = new StringTokenizer(str, delim);
+        String[] tokens = new String[tokenizer.countTokens()];
+        for (int i = 0; tokenizer.hasMoreTokens(); i++) {
+            tokens[i] = tokenizer.nextToken();
+        }
+        return tokens;
+    }
+
+    private static boolean contains(String[] list, String member) {
+        boolean found = false;
+        for (int i = 0; i < list.length && !found; i++) {
+            found = member.equals(list[i]);
+        }
+        return found;
+    }
 }

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=703368&r1=703367&r2=703368&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
Fri Oct 10 02:42:09 2008
@@ -56,7 +56,7 @@
         for (ServiceEndpointDescription sd  : sds) {
             
             
-            if (!OsgiUtils.getBooleanProperty(sd, Constants.REMOTE_INTERFACES_PROPERTY))
{
+            if (sd.getProperty(Constants.REMOTE_INTERFACES_PROPERTY) == null) {
                 continue;
             }
             

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
Fri Oct 10 02:42:09 2008
@@ -18,8 +18,10 @@
   */
 package org.apache.cxf.dosgi.dsw.hooks;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.cxf.dosgi.dsw.Constants;
@@ -33,8 +35,8 @@
 
 public class CxfPublishHook extends AbstractHook {
     
-    private Map<ServiceReference, EndpointInfo> endpoints
-        = new LinkedHashMap<ServiceReference, EndpointInfo>();
+    private Map<ServiceReference, List<EndpointInfo>> endpoints
+        = new LinkedHashMap<ServiceReference, List<EndpointInfo>>();
     
     public CxfPublishHook(BundleContext bc, CxfDistributionProvider dpService) {
         super(bc, dpService);
@@ -55,54 +57,73 @@
         // by accepting Configuration Admin Service updates or checking 
         // local configuration data, if any available - it will let
         // this code to check for SDs from the additional source
-        if (sd == null
-            || !OsgiUtils.getBooleanProperty(sd, Constants.REMOTE_INTERFACES_PROPERTY)) {
+
+        String[] publishableInterfaces = 
+            sd != null
+            ? OsgiUtils.getPublishableInterfaces(sd, sref)
+            : null; 
+        if (publishableInterfaces == null || publishableInterfaces.length == 0) {
             return;
         }
 
-            
-        Server server = null;
-        boolean isPublished = false;
-        server = ServiceHookUtils.createServer(
-                                 getHandler(sd, getHandlerProperties()),
-                                 sref,
-                                 getContext(), 
-                                 sref.getBundle().getBundleContext(), 
-                                 sd, 
-                                 getContext().getService(sref));
-        if (server != null && ServiceHookUtils.publish(getContext(), sd)) {
-            isPublished = true;
-        }
+        ServiceEndpointDescription[] flatList = 
+            OsgiUtils.flattenServiceDescription(sd);
+        for (int i = 0; i < publishableInterfaces.length; i++) {    
+            Server server = null;
+            boolean isPublished = false;
+            server = ServiceHookUtils.createServer(
+                                     getHandler(sd, getHandlerProperties()),
+                                     sref,
+                                     getContext(), 
+                                     sref.getBundle().getBundleContext(), 
+                                     sd, 
+                                     getContext().getService(sref));
+            if (server != null && ServiceHookUtils.publish(getContext(), sd)) {
+                isPublished = true;
+            }
         
-        synchronized(endpoints) {
-            endpoints.put(sref, new EndpointInfo(getContext(),
-                                                 sd,
-                                                 server,
-                                                 isPublished));
+            synchronized(endpoints) {
+                EndpointInfo ei = new EndpointInfo(getContext(),
+                                                   flatList[i],
+                                                   server,
+                                                   isPublished);
+                if (endpoints.containsKey(sref)) {
+                    endpoints.get(sref).add(ei);
+                } else {
+                    List<EndpointInfo> endpointList = 
+                        new ArrayList<EndpointInfo>();
+                    endpointList.add(ei);
+                    endpoints.put(sref, endpointList);
+                }
+            }
         }
     }
     
     public void removeEndpoint(ServiceReference sref) {
-        EndpointInfo ei = null;
+        List<EndpointInfo> endpointList = null;
         synchronized(endpoints) {
-            ei = endpoints.remove(sref);
+            endpointList = endpoints.remove(sref);
         }
-        if (ei != null) {
-            ServiceHookUtils.unregisterServer(ei);
+        if (endpointList != null) {
+            for (EndpointInfo ei : endpointList) {
+                ServiceHookUtils.unregisterServer(ei);
+            }
         }
     }
     
     public void removeEndpoints() {
         synchronized(endpoints) {
-            for (EndpointInfo ei : endpoints.values()) {
-                ServiceHookUtils.unregisterServer(ei);
+            for (List<EndpointInfo> endpointList : endpoints.values()) {
+                for (EndpointInfo ei : endpointList) {
+                    ServiceHookUtils.unregisterServer(ei);
+                }
             }
             endpoints.clear();
         }
         
     }
     
-    public Map<ServiceReference, EndpointInfo> getEndpoints() {
+    public Map<ServiceReference, List<EndpointInfo>> getEndpoints() {
         return Collections.unmodifiableMap(endpoints);
     }
     

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=703368&r1=703367&r2=703368&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
Fri Oct 10 02:42:09 2008
@@ -44,6 +44,12 @@
     }
     
     @SuppressWarnings("unchecked")
+    public ServiceEndpointDescriptionImpl(String interfaceName,
+                                  Map<String, Object> remoteProperties) {
+        this(Collections.singletonList(interfaceName), remoteProperties);
+    }
+
+    @SuppressWarnings("unchecked")
     public ServiceEndpointDescriptionImpl(List<String> interfaceNames) {
         this(interfaceNames, Collections.EMPTY_MAP);
     }
@@ -58,7 +64,7 @@
         return properties.get(key);
     }
 
-    public Map getProperties() {
+    public Map<String, Object> getProperties() {
         return Collections.unmodifiableMap(properties);
     }
 

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/OsgiUtilsTest.java
Fri Oct 10 02:42:09 2008
@@ -21,6 +21,60 @@
 import org.osgi.service.discovery.ServiceEndpointDescription;
 
 public class OsgiUtilsTest extends TestCase {
+
+    public void testGetPublishableInterfacesAll() throws Exception {
+        doTestGetPublishableInterfaces("foo,bar,snafu",
+                                       new String[] {"snafu", "foo", "bar"},
+                                       new String[] {"foo", "bar", "snafu"});
+    }
+
+    public void testGetPublishableInterfacesSubset() throws Exception {
+        doTestGetPublishableInterfaces("foo,snafu",
+                                       new String[] {"snafu", "foo", "bar"},
+                                       new String[] {"foo", "snafu"});
+    }
+
+    public void testGetPublishableInterfacesSuperset() throws Exception {
+        doTestGetPublishableInterfaces("foo,bar,snafu",
+                                       new String[] {"snafu", "bar"},
+                                       new String[] {"bar", "snafu"});
+    }
+
+    public void testGetPublishableInterfacesNonexistant() throws Exception {
+        doTestGetPublishableInterfaces("foo,bar,tofu",
+                                       new String[] {"snafu", "foo", "bar"},
+                                       new String[] {"foo", "bar"});
+    }
+
+    public void testGetPublishableInterfacesWildcarded() throws Exception {
+        doTestGetPublishableInterfaces("*",
+                                       new String[] {"snafu", "foo", "bar"},
+                                       new String[] {"snafu", "foo", "bar"});
+    }
+
+    public void doTestGetPublishableInterfaces(String requested, 
+                                               String[] actual, 
+                                               String[] expected)
+        throws Exception {
+        ServiceEndpointDescription sd =
+            EasyMock.createMock(ServiceEndpointDescription.class);
+        ServiceReference sref = EasyMock.createMock(ServiceReference.class);
+        EasyMock.expect(sd.getProperty(Constants.REMOTE_INTERFACES_PROPERTY)).andReturn(requested);
+        EasyMock.expect(sref.getProperty(org.osgi.framework.Constants.OBJECTCLASS)).andReturn(actual);
+        EasyMock.replay(sd);
+        EasyMock.replay(sref);
+        
+        String[] ret = OsgiUtils.getPublishableInterfaces(sd, sref);
+
+        assertNotNull(ret);
+        assertEquals(expected.length, ret.length);
+        for (int i = 0; i < expected.length; i++) {
+            assertEquals(expected[i], ret[i]);
+        }
+
+        EasyMock.verify();
+    }
+
     public void testGetRemoteReferencesFromRegistrationProperties() {
         final Map<String, Object> props = new HashMap<String, Object>();
         props.put(org.osgi.framework.Constants.OBJECTCLASS, new String [] {"myClass"});

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=703368&r1=703367&r2=703368&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
Fri Oct 10 02:42:09 2008
@@ -22,6 +22,7 @@
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 
 
@@ -47,16 +48,29 @@
     public void setUp() {
         control = EasyMock.createNiceControl();
     }
+
+    @Test
+    public void testPublishSingleInterface() throws Exception {
+        String[] serviceNames = new String[]{TestService.class.getName()};
+        doTestPublishHook("remote-services.xml", serviceNames);
+    }
+
+    @Test
+    public void testPublishMultiInterface() throws Exception {
+        String[] serviceNames = new String[]{TestService.class.getName(), 
+                                             AdditionalInterface.class.getName()};
+        doTestPublishHook("multi-services.xml", serviceNames);
+    }
     
     @SuppressWarnings("unchecked")
-    @Test
-    public void testPublishHook() throws Exception {
+    private void doTestPublishHook(String remoteServices, 
+                                   String[] serviceNames) throws Exception {
         
         Bundle bundle = control.createMock(Bundle.class);
         bundle.findEntries(EasyMock.eq("OSGI-INF/remote-services"), 
             EasyMock.eq("*.xml"), EasyMock.anyBoolean());
         EasyMock.expectLastCall().andReturn(Collections.enumeration(
-            Arrays.asList(getClass().getResource("/OSGI-INF/remote-services/remote-services.xml"))));
+            Arrays.asList(getClass().getResource("/OSGI-INF/remote-services/" + remoteServices))));
         Dictionary<String, String> bundleHeaders = new Hashtable<String, String>();
         bundleHeaders.put(org.osgi.framework.Constants.BUNDLE_NAME, 
                           "Test Bundle");
@@ -69,14 +83,13 @@
         EasyMock.expectLastCall().andReturn(requestingContext).anyTimes();
         
         TestService serviceObject = new TestServiceImpl();
-        String[] serviceNames = new String[]{TestService.class.getName()};
         Dictionary serviceProps = new Hashtable();
-        
+
         ServiceReference sref = control.createMock(ServiceReference.class);
         sref.getBundle();
         EasyMock.expectLastCall().andReturn(bundle).anyTimes();
         sref.getProperty(Constants.OBJECTCLASS);
-        EasyMock.expectLastCall().andReturn(serviceNames);
+        EasyMock.expectLastCall().andReturn(serviceNames).anyTimes();
         sref.getPropertyKeys();                           
         EasyMock.expectLastCall().andReturn(new String[]{}).anyTimes();
         
@@ -92,7 +105,24 @@
                                                    server);
         hook.publishEndpoint(sref);
         hook.verify();
-        
+
+        assertEquals(1, hook.getEndpoints().size());
+        List<EndpointInfo> list = hook.getEndpoints().get(sref);
+        assertNotNull(list);
+        assertEquals(serviceNames.length, list.size());
+        for (int i = 0; i < serviceNames.length; i++) {
+            assertNotNull(list.get(i));
+            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]);
+            String excludeProp = 
+                org.apache.cxf.dosgi.dsw.Constants.REMOTE_INTERFACES_PROPERTY;
+            assertNull(sd.getProperties().get(excludeProp));
+        }
     }
 
     private static class TestPublishHook extends CxfPublishHook {
@@ -138,8 +168,11 @@
             Assert.assertTrue(called);
         }
     }
+
+    public interface AdditionalInterface {
+    }
     
-    private static class TestServiceImpl implements TestService {
+    private static class TestServiceImpl implements TestService, AdditionalInterface {
         
     }
 }

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml?rev=703368&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml
(added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml
Fri Oct 10 02:42:09 2008
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
+  <service-description>
+    <interface name="org.apache.cxf.dosgi.dsw.hooks.TestService" />
+    <interface name="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface"
/>
+    <property key="osgi.remote.publish.interfaces">org.apache.cxf.dosgi.dsw.hooks.TestService,org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface</property>
+    <property key="osgi.remote.requires.intents">SOAP HTTP</property>
+    <property key="osgi.remote.configuration.type">pojo</property>
+    <property key="osgi.remote.configuration.pojo.address">http://localhost:9001/hello</property>
+  </service-description>
+</service-descriptions>

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/multi-services.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/remote-services.xml?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/OSGI-INF/remote-services/remote-services.xml
Fri Oct 10 02:42:09 2008
@@ -22,7 +22,9 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.dsw.hooks.TestService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <interface name="org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface"
/>
+    <!--property key="osgi.remote.publish.interfaces">org.apache.cxf.dosgi.dsw.hooks.TestService,org.apache.cxf.dosgi.dsw.hooks.CxfPublishHookTest$AdditionalInterface</property-->
+    <property key="osgi.remote.publish.interfaces">*</property>
     <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9000/hello</property>

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/test-resources/rs2.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/test-resources/rs2.xml?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/test-resources/rs2.xml (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/resources/test-resources/rs2.xml Fri Oct 10 02:42:09
2008
@@ -23,6 +23,6 @@
   <service-description>
     <interface name="org.example.Service" />
     <property key="osgi.intents">confidentiality.message integrity</property>
-    <property key="osgi.remote.interfaces">*</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
   </service-description>
 </service-descriptions>

Modified: cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/samples/greeter/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml
Fri Oct 10 02:42:09 2008
@@ -16,7 +16,7 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.greeter.GreeterService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
     <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <!--
       property name="osgi.remote.requires.intents">reliability decoupled

Modified: cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/samples/greeter/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml
Fri Oct 10 02:42:09 2008
@@ -16,7 +16,7 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.greeter.GreeterService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
     <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9090/greeter</property>

Modified: cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/samples/simple_pojo/client/src/main/resources/OSGI-INF/remote-services/remote-services.xml
Fri Oct 10 02:42:09 2008
@@ -16,7 +16,7 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.HelloService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
 
 <!-- Uncomment to enable SOAP 1.2 and confirm via message logging -->
     <!--

Modified: cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/samples/simple_pojo/impl/src/main/resources/OSGI-INF/remote-services/remote-services.xml
Fri Oct 10 02:42:09 2008
@@ -16,7 +16,7 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.HelloService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
 
 <!-- Uncomment to enable SOAP 1.2 and confirm via message logging -->
     <!--
@@ -35,7 +35,7 @@
   </service-description>
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.GreeterService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
     <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9005/greeter</property>

Modified: cxf/sandbox/dosgi/systests/basic/src/test/resources/OSGI-INF/remote-services/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/systests/basic/src/test/resources/OSGI-INF/remote-services/remote-services.xml?rev=703368&r1=703367&r2=703368&view=diff
==============================================================================
--- cxf/sandbox/dosgi/systests/basic/src/test/resources/OSGI-INF/remote-services/remote-services.xml
(original)
+++ cxf/sandbox/dosgi/systests/basic/src/test/resources/OSGI-INF/remote-services/remote-services.xml
Fri Oct 10 02:42:09 2008
@@ -16,14 +16,14 @@
 <service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.HelloService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
     <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9000/hello</property>
   </service-description>
   <service-description>
     <interface name="org.apache.cxf.dosgi.samples.pojo.hello.GreeterService" />
-    <property key="osgi.remote.interfaces">true</property>
+    <property key="osgi.remote.publish.interfaces">*</property>
     <property key="osgi.remote.requires.intents">SOAP HTTP</property>
     <property key="osgi.remote.configuration.type">pojo</property>
     <property key="osgi.remote.configuration.pojo.address">http://localhost:9005/greeter</property>



Mime
View raw message