You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by da...@apache.org on 2009/05/27 14:14:03 UTC
svn commit: r779136 - in /cxf/dosgi/trunk/discovery/local/src:
main/java/org/apache/cxf/dosgi/discovery/local/
test/java/org/apache/cxf/dosgi/discovery/local/
Author: davidb
Date: Wed May 27 12:14:03 2009
New Revision: 779136
URL: http://svn.apache.org/viewvc?rev=779136&view=rev
Log:
Fix for CXF-2200.
Modified:
cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java
cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java
cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java
cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java
Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java?rev=779136&r1=779135&r2=779136&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtils.java Wed May 27 12:14:03 2009
@@ -76,6 +76,10 @@
for (Element ref : references) {
List<String> iNames = getProvidedInterfaces(ref.getChildren(PROVIDE_INTERFACE_ELEMENT, ns));
Map<String, Object> remoteProps = getProperties(ref.getChildren(PROPERTY_ELEMENT, ns));
+
+ // this property is used by discovery for matching
+ remoteProps.put(ServicePublication.SERVICE_INTERFACE_NAME, iNames);
+
if (addEndpointID) {
remoteProps.put(ServicePublication.ENDPOINT_ID, UUID.randomUUID().toString());
}
Modified: cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java?rev=779136&r1=779135&r2=779136&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/ServiceEndpointDescriptionImpl.java Wed May 27 12:14:03 2009
@@ -32,6 +32,7 @@
import java.util.logging.Logger;
import org.osgi.service.discovery.ServiceEndpointDescription;
+import org.osgi.service.discovery.ServicePublication;
public class ServiceEndpointDescriptionImpl implements ServiceEndpointDescription {
@@ -41,14 +42,14 @@
private Set<String> interfaceNames;
Map<String, Object> properties;
- @SuppressWarnings("unchecked")
public ServiceEndpointDescriptionImpl(String interfaceName) {
- this(Collections.singletonList(interfaceName), Collections.EMPTY_MAP);
+ this(Collections.singletonList(interfaceName));
}
- @SuppressWarnings("unchecked")
public ServiceEndpointDescriptionImpl(List<String> interfaceNames) {
- this(interfaceNames, Collections.EMPTY_MAP);
+ this(interfaceNames,
+ Collections.<String, Object>singletonMap(
+ ServicePublication.SERVICE_INTERFACE_NAME, interfaceNames));
}
public ServiceEndpointDescriptionImpl(List<String> interfaceNames,
Modified: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java?rev=779136&r1=779135&r2=779136&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryServiceTest.java Wed May 27 12:14:03 2009
@@ -82,15 +82,17 @@
assertEquals(2, lds.servicesInfo.size());
Map<Collection<String>, String> eids = getEndpointIDs(lds.servicesInfo.keySet());
+ List<String> intf1 = Arrays.asList("org.example.SomeService");
Map<String, Object> sed1Props = new HashMap<String, Object>();
sed1Props.put("osgi.remote.requires.intents", "confidentiality");
+ sed1Props.put(ServicePublication.SERVICE_INTERFACE_NAME, intf1);
setEndpointID(eids, sed1Props, "org.example.SomeService");
- ServiceEndpointDescription sed1 = new ServiceEndpointDescriptionImpl(
- Arrays.asList("org.example.SomeService"), sed1Props);
+ ServiceEndpointDescription sed1 = new ServiceEndpointDescriptionImpl(intf1, sed1Props);
+ List<String> intf2 = Arrays.asList("SomeOtherService", "WithSomeSecondInterface");
Map<String, Object> sed2Props = new HashMap<String, Object>();
+ sed2Props.put(ServicePublication.SERVICE_INTERFACE_NAME, intf2);
setEndpointID(eids, sed2Props, "SomeOtherService", "WithSomeSecondInterface");
- ServiceEndpointDescription sed2 = new ServiceEndpointDescriptionImpl(
- Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), sed2Props);
+ ServiceEndpointDescription sed2 = new ServiceEndpointDescriptionImpl(intf2, sed2Props);
assertTrue(lds.servicesInfo.containsKey(sed1));
assertTrue(lds.servicesInfo.containsKey(sed2));
@@ -117,10 +119,11 @@
lds.bundleChanged(be);
Map<Collection<String>, String> eids2 = getEndpointIDs(lds.servicesInfo.keySet());
+ List<String> intf3 = Arrays.asList("org.example.SomeRelatedService", "org.example.SomeService");
Map<String, Object> sed3Props = new HashMap<String, Object>();
+ sed3Props.put(ServicePublication.SERVICE_INTERFACE_NAME, intf3);
setEndpointID(eids2, sed3Props, "org.example.SomeRelatedService", "org.example.SomeService");
- ServiceEndpointDescription sed3 = new ServiceEndpointDescriptionImpl(
- Arrays.asList("org.example.SomeRelatedService", "org.example.SomeService"), sed3Props);
+ ServiceEndpointDescription sed3 = new ServiceEndpointDescriptionImpl(intf3, sed3Props);
assertEquals(3, lds.servicesInfo.size());
assertTrue(lds.servicesInfo.containsKey(sed1));
assertTrue(lds.servicesInfo.containsKey(sed2));
@@ -218,10 +221,14 @@
// set up the mock filter behaviour
Dictionary<String, Object> d1 = new Hashtable<String, Object>();
d1.put("blah", "5");
+ d1.put("osgi.remote.service.interfaces",
+ Arrays.asList("SomeOtherService", "WithSomeSecondInterface"));
EasyMock.expect(mockFilter.match(d1)).andReturn(true).anyTimes();
Dictionary<String, Object> d2 = new Hashtable<String, Object>();
d2.put("blah", "3");
d2.put("boo", "hello");
+ d2.put("osgi.remote.service.interfaces",
+ Arrays.asList("org.example.SomeRelatedService", "org.example.SomeService"));
EasyMock.expect(mockFilter.match(d2)).andReturn(true).anyTimes();
control.replay();
@@ -232,14 +239,16 @@
// it should be prepopulated with the info from bundle b0
assertEquals(2, lds.servicesInfo.size());
+ List<String> intf1 = Arrays.asList("org.example.SomeService");
Map<String, Object> sed1Props = new HashMap<String, Object>();
sed1Props.put("osgi.remote.requires.intents", "confidentiality");
- ServiceEndpointDescription sed1 = new ServiceEndpointDescriptionImpl(
- Arrays.asList("org.example.SomeService"), sed1Props);
+ sed1Props.put(ServicePublication.SERVICE_INTERFACE_NAME, intf1);
+ ServiceEndpointDescription sed1 = new ServiceEndpointDescriptionImpl(intf1, sed1Props);
+ List<String> intf2 = Arrays.asList("SomeOtherService", "WithSomeSecondInterface");
Map<String, Object> sed2Props = new HashMap<String, Object>();
sed2Props.put("blah", "5");
- ServiceEndpointDescription sed2 = new ServiceEndpointDescriptionImpl(
- Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), sed2Props);
+ sed2Props.put(ServicePublication.SERVICE_INTERFACE_NAME, intf2);
+ ServiceEndpointDescription sed2 = new ServiceEndpointDescriptionImpl(intf2, sed2Props);
assertTrue(lds.servicesInfo.containsKey(sed1));
assertTrue(lds.servicesInfo.containsKey(sed2));
@@ -265,11 +274,12 @@
BundleEvent be = new BundleEvent(BundleEvent.STARTED, b1);
lds.bundleChanged(be);
+ List<String> intf3 = Arrays.asList("org.example.SomeRelatedService", "org.example.SomeService");
Map<String, Object> sed3Props = new HashMap<String, Object>();
sed3Props.put("blah", "3");
sed3Props.put("boo", "hello");
- ServiceEndpointDescription sed3 = new ServiceEndpointDescriptionImpl(
- Arrays.asList("org.example.SomeRelatedService", "org.example.SomeService"), sed3Props);
+ sed3Props.put(ServicePublication.SERVICE_INTERFACE_NAME, intf3);
+ ServiceEndpointDescription sed3 = new ServiceEndpointDescriptionImpl(intf3, sed3Props);
assertEquals(3, lds.servicesInfo.size());
assertTrue(lds.servicesInfo.containsKey(sed1));
assertTrue(lds.servicesInfo.containsKey(sed2));
@@ -333,10 +343,11 @@
// it should be prepopulated with the info from bundle b0
assertEquals(2, lds.servicesInfo.size());
+ List<String> intf1 = Arrays.asList("org.example.SomeService");
Map<String, Object> sed1Props = new HashMap<String, Object>();
+ sed1Props.put(ServicePublication.SERVICE_INTERFACE_NAME, intf1);
sed1Props.put("osgi.remote.requires.intents", "confidentiality");
- ServiceEndpointDescription sed1 = new ServiceEndpointDescriptionImpl(
- Arrays.asList("org.example.SomeService"), sed1Props);
+ ServiceEndpointDescription sed1 = new ServiceEndpointDescriptionImpl(intf1, sed1Props);
ServiceEndpointDescription sed2 = new ServiceEndpointDescriptionImpl(
Arrays.asList("SomeOtherService", "WithSomeSecondInterface"));
assertTrue(lds.servicesInfo.containsKey(sed1));
Modified: cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java?rev=779136&r1=779135&r2=779136&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java (original)
+++ cxf/dosgi/trunk/discovery/local/src/test/java/org/apache/cxf/dosgi/discovery/local/LocalDiscoveryUtilsTest.java Wed May 27 12:14:03 2009
@@ -99,18 +99,22 @@
assertEquals(2, seds.size());
Map<Collection<String>, String> eids = getEndpointIDs(seds);
+ List<String> interfaces = Arrays.asList("SomeService");
Map<String, Object> sed1Props = new HashMap<String, Object>();
sed1Props.put("osgi.remote.requires.intents", "confidentiality");
sed1Props.put(ServicePublication.ENDPOINT_ID, eids.get(
- Collections.singleton("SomeService")));
- ServiceEndpointDescription sed1 = new ServiceEndpointDescriptionImpl(
- Arrays.asList("SomeService"), sed1Props);
+ Collections.singleton("SomeService")));
+ sed1Props.put(ServicePublication.SERVICE_INTERFACE_NAME, interfaces);
+ ServiceEndpointDescription sed1 =
+ new ServiceEndpointDescriptionImpl(interfaces, sed1Props);
+ List<String> interfaces2 = Arrays.asList("SomeOtherService", "WithSomeSecondInterface");
Map<String, Object> sed2Props = new HashMap<String, Object>();
sed2Props.put(ServicePublication.ENDPOINT_ID, eids.get(
- new HashSet<String>(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"))));
- ServiceEndpointDescription sed2 = new ServiceEndpointDescriptionImpl(
- Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), sed2Props);
+ new HashSet<String>(interfaces2)));
+ sed2Props.put(ServicePublication.SERVICE_INTERFACE_NAME, interfaces2);
+ ServiceEndpointDescription sed2 =
+ new ServiceEndpointDescriptionImpl(interfaces2, sed2Props);
assertTrue(seds.contains(sed1));
assertTrue(seds.contains(sed2));
}