Author: davidb
Date: Thu Dec 11 01:27:43 2008
New Revision: 725633
URL: http://svn.apache.org/viewvc?rev=725633&view=rev
Log:
Fix for CXF-1836 - updated the DistributionProvider according to the latest RFC
119 definition.
Unit tests updated too.
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/distribution/DistributionProvider.java
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java?rev=725633&r1=725632&r2=725633&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
Thu Dec 11 01:27:43 2008
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.dosgi.dsw.service;
+import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
@@ -54,25 +55,23 @@
tracker.close();
}
- public Map<String, String> getPublicationProperties(ServiceReference sr) {
+ public Map<String, String> getExposedProperties(ServiceReference sr) {
synchronized (publicationProperties) {
return publicationProperties.get(sr);
}
}
- public ServiceReference[] getExposedServices() {
+ public Collection /*<? extends ServiceReference>*/ getExposedServices() {
synchronized (exposedServices) {
- return exposedServices.toArray(new
ServiceReference[exposedServices.size()]);
+ // Defensive copy
+ return new HashSet<ServiceReference>(exposedServices);
}
}
- public ServiceReference[] getPublishedServices() {
- return new ServiceReference[]{};
- }
-
- public ServiceReference[] getRemoteServices() {
+ public Collection /*<? extends ServiceReference>*/ getRemoteServices() {
synchronized (remoteServices) {
- return remoteServices.toArray(new
ServiceReference[remoteServices.size()]);
+ // Defensive copy
+ return new HashSet<ServiceReference>(remoteServices);
}
}
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java?rev=725633&r1=725632&r2=725633&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
Thu Dec 11 01:27:43 2008
@@ -98,10 +98,10 @@
EasyMock.replay(callingContext);
EasyMock.replay(sd);
- assertEquals("Precondition failed", 0, dp.getRemoteServices().length);
+ assertEquals("Precondition failed", 0, dp.getRemoteServices().size());
p.createProxy(sr, dswContext, callingContext, CharSequence.class, sd);
- assertEquals(1, dp.getRemoteServices().length);
- assertSame(sr, dp.getRemoteServices()[0]);
+ assertEquals(1, dp.getRemoteServices().size());
+ assertSame(sr, dp.getRemoteServices().iterator().next());
}
public void testCreateServerPopulatesDistributionProvider() {
@@ -132,16 +132,16 @@
EasyMock.replay(callingContext);
EasyMock.replay(sd);
- assertEquals("Precondition failed", 0, dp.getExposedServices().length);
+ assertEquals("Precondition failed", 0, dp.getExposedServices().size());
p.createServer(sr, dswContext, callingContext, sd, String.class,
myService);
- assertEquals(1, dp.getExposedServices().length);
- assertSame(sr, dp.getExposedServices()[0]);
+ assertEquals(1, dp.getExposedServices().size());
+ assertSame(sr, dp.getExposedServices().iterator().next());
Map<String, String> expected = new HashMap<String, String>();
expected.put("osgi.remote.configuration.type", "pojo");
expected.put("osgi.remote.configuration.pojo.address",
"http://somehost:54321/java/lang/String");
expected.put("osgi.intents", "A B");
- assertEquals(expected, dp.getPublicationProperties(sr));
+ assertEquals(expected, dp.getExposedProperties(sr));
}
private ServerFactoryBean createMockServerFactoryBean() {
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java?rev=725633&r1=725632&r2=725633&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
Thu Dec 11 01:27:43 2008
@@ -68,10 +68,10 @@
}
};
- assertEquals("Precondition failed", 0, dp.getRemoteServices().length);
+ assertEquals("Precondition failed", 0, dp.getRemoteServices().size());
w.createProxy(sr, dswContext, callingContext, CharSequence.class, sd);
- assertEquals(1, dp.getRemoteServices().length);
- assertSame(sr, dp.getRemoteServices()[0]);
+ assertEquals(1, dp.getRemoteServices().size());
+ assertSame(sr, dp.getRemoteServices().iterator().next());
}
Modified:
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java?rev=725633&r1=725632&r2=725633&view=diff
==============================================================================
---
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
(original)
+++
cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
Thu Dec 11 01:27:43 2008
@@ -34,28 +34,24 @@
EasyMock.replay(bc);
DistributionProviderImpl dp = new DistributionProviderImpl(bc);
- assertEquals(0, dp.getExposedServices().length);
- assertEquals(0, dp.getPublishedServices().length);
- assertEquals(0, dp.getRemoteServices().length);
+ assertEquals(0, dp.getExposedServices().size());
+ assertEquals(0, dp.getRemoteServices().size());
ServiceReference sr = new TestServiceReference();
ServiceReference sr2 = new TestServiceReference();
dp.addExposedService(sr, null);
- assertEquals(1, dp.getExposedServices().length);
- assertEquals(0, dp.getPublishedServices().length);
- assertEquals(0, dp.getRemoteServices().length);
- assertSame(sr, dp.getExposedServices()[0]);
+ assertEquals(1, dp.getExposedServices().size());
+ assertEquals(0, dp.getRemoteServices().size());
+ assertSame(sr, dp.getExposedServices().iterator().next());
dp.addExposedService(sr, null);
- assertEquals(1, dp.getExposedServices().length);
- assertEquals(0, dp.getPublishedServices().length);
- assertEquals(0, dp.getRemoteServices().length);
- assertSame(sr, dp.getExposedServices()[0]);
+ assertEquals(1, dp.getExposedServices().size());
+ assertEquals(0, dp.getRemoteServices().size());
+ assertSame(sr, dp.getExposedServices().iterator().next());
dp.addExposedService(sr2, null);
- assertEquals(2, dp.getExposedServices().length);
- assertEquals(0, dp.getPublishedServices().length);
- assertEquals(0, dp.getRemoteServices().length);
+ assertEquals(2, dp.getExposedServices().size());
+ assertEquals(0, dp.getRemoteServices().size());
}
public void testRemoteServices() {
@@ -63,28 +59,24 @@
EasyMock.replay(bc);
DistributionProviderImpl dp = new DistributionProviderImpl(bc);
- assertEquals(0, dp.getExposedServices().length);
- assertEquals(0, dp.getPublishedServices().length);
- assertEquals(0, dp.getRemoteServices().length);
+ assertEquals(0, dp.getExposedServices().size());
+ assertEquals(0, dp.getRemoteServices().size());
ServiceReference sr = new TestServiceReference();
ServiceReference sr2 = new TestServiceReference();
dp.addRemoteService(sr);
- assertEquals(0, dp.getExposedServices().length);
- assertEquals(0, dp.getPublishedServices().length);
- assertEquals(1, dp.getRemoteServices().length);
- assertSame(sr, dp.getRemoteServices()[0]);
+ assertEquals(0, dp.getExposedServices().size());
+ assertEquals(1, dp.getRemoteServices().size());
+ assertSame(sr, dp.getRemoteServices().iterator().next());
dp.addRemoteService(sr);
- assertEquals(0, dp.getExposedServices().length);
- assertEquals(0, dp.getPublishedServices().length);
- assertEquals(1, dp.getRemoteServices().length);
- assertSame(sr, dp.getRemoteServices()[0]);
+ assertEquals(0, dp.getExposedServices().size());
+ assertEquals(1, dp.getRemoteServices().size());
+ assertSame(sr, dp.getRemoteServices().iterator().next());
dp.addRemoteService(sr2);
- assertEquals(0, dp.getExposedServices().length);
- assertEquals(0, dp.getPublishedServices().length);
- assertEquals(2, dp.getRemoteServices().length);
+ assertEquals(0, dp.getExposedServices().size());
+ assertEquals(2, dp.getRemoteServices().size());
}
public void testPublicationProperties() {
@@ -95,15 +87,15 @@
ServiceReference sr = new TestServiceReference();
ServiceReference sr2 = new TestServiceReference();
- assertNull(dp.getPublicationProperties(sr));
+ assertNull(dp.getExposedProperties(sr));
dp.addExposedService(sr, null);
Map<String, String> pp = new HashMap<String, String>();
pp.put("a", "b");
dp.addExposedService(sr2, pp);
- assertEquals(0, dp.getPublicationProperties(sr).size());
- assertEquals(pp, dp.getPublicationProperties(sr2));
+ assertEquals(0, dp.getExposedProperties(sr).size());
+ assertEquals(pp, dp.getExposedProperties(sr2));
}
private static class TestServiceReference implements ServiceReference {
Modified:
cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/distribution/DistributionProvider.java
URL:
http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/distribution/DistributionProvider.java?rev=725633&r1=725632&r2=725633&view=diff
==============================================================================
---
cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/distribution/DistributionProvider.java
(original)
+++
cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/distribution/DistributionProvider.java
Thu Dec 11 01:27:43 2008
@@ -17,6 +17,7 @@
*/
package org.osgi.service.distribution;
+import java.util.Collection;
import java.util.Map;
import org.osgi.framework.ServiceReference;
@@ -59,37 +60,27 @@
/**
* @return ServiceReferences of services registered in the local Service
* Registry that are proxies to remote services. If no proxies are
- * registered, then an empty array is returned.
+ * registered, then an empty collection is returned.
*/
- ServiceReference[] getRemoteServices();
+ Collection /*<? extends ServiceReference>*/ getRemoteServices();
/**
* @return ServiceReferences of local services that are exposed remotely
* using this DisitributionProvider. Note that certain services
may be
* exposed and without being published to a discovery service.
This
* API returns all the exposed services. If no services are
exposed an
- * empty array is returned.
+ * empty collection is returned.
*/
- ServiceReference[] getExposedServices();
-
- /**
- * @return Local ServiceReferences of exposed services that are published
- * remotely to a discovery mechanism using this
DisitributionProvider.
- * Note that certain services might be exposed without being
- * published.
- * This API returns all the published service. If no services are
- * published an empty array is returned.
- */
- ServiceReference[] getPublishedServices();
+ Collection /*<? extends ServiceReference>*/ getExposedServices();
/**
* Provides access to extra properties set by the DistributionProvider on
* endpoints, as they will appear on client side proxies given an exposed
* ServiceReference.
* These properties are not always available on the server-side
- * ServiceReference of the published
+ * ServiceReference of the exposed
* service but will be on the remote client side proxy to this service.
- * This API provides access to these extra properties from the publishing
+ * This API provides access to these extra properties from the exposing
* side.
* E.g. a service is exposed remotely, the distribution software is
configured
* to add transactionality to the remote service. Because of this, on the
@@ -100,8 +91,8 @@
* This QoS is added by the distribution.
* This API provides access to these extra properties from the server-side.
*
- * @param sr A ServiceReference of a published service.
+ * @param sr A ServiceReference of an exposed service.
* @return The map of extra properties.
*/
- Map getPublicationProperties(ServiceReference sr);
+ Map /*<String, String>*/ getExposedProperties(ServiceReference sr);
}