cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject cxf-dosgi git commit: [DOSGI-229] Easier to use interface
Date Wed, 09 Mar 2016 10:26:04 GMT
Repository: cxf-dosgi
Updated Branches:
  refs/heads/master 221f4ba7f -> 0111cfdc6


[DOSGI-229] Easier to use interface


Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/0111cfdc
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/0111cfdc
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/0111cfdc

Branch: refs/heads/master
Commit: 0111cfdc6d3e5177dd05cd2d3957c0b84c0ed3cf
Parents: 221f4ba
Author: Christian Schneider <chris@die-schneider.net>
Authored: Wed Mar 9 11:25:56 2016 +0100
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Wed Mar 9 11:25:56 2016 +0100

----------------------------------------------------------------------
 .../cxf/dosgi/dsw/api/DistributionProvider.java | 18 +++--
 .../cxf/dosgi/dsw/api/EndpointHelper.java       | 41 ++++++++++
 .../dosgi/dsw/service/ClientServiceFactory.java |  8 +-
 .../dsw/service/RemoteServiceAdminCore.java     | 23 +++---
 .../dsw/service/ClientServiceFactoryTest.java   | 18 +++--
 .../dsw/service/RemoteServiceAdminCoreTest.java |  6 +-
 .../aries/rsa/provider/tcp/TCPProvider.java     | 30 +++-----
 .../aries/rsa/provider/tcp/TcpProviderTest.java | 17 +++--
 .../dsw/handlers/CXFDistributionProvider.java   | 15 ++--
 .../JaxRSPojoConfigurationTypeHandler.java      | 17 ++---
 .../handlers/PojoConfigurationTypeHandler.java  | 25 +++----
 .../handlers/WsdlConfigurationTypeHandler.java  | 30 ++++----
 .../handlers/CXFDistributionProviderTest.java   | 20 +----
 .../PojoConfigurationTypeHandlerTest.java       | 79 ++++++++------------
 14 files changed, 182 insertions(+), 165 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dosgi-provider-api/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-provider-api/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java b/dsw/cxf-dosgi-provider-api/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java
index c7328db..d7c648b 100644
--- a/dsw/cxf-dosgi-provider-api/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java
+++ b/dsw/cxf-dosgi-provider-api/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java
@@ -21,7 +21,6 @@ package org.apache.cxf.dosgi.dsw.api;
 import java.util.Map;
 
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 
 @SuppressWarnings("rawtypes")
@@ -30,25 +29,28 @@ public interface DistributionProvider {
     String[] getSupportedTypes();
 
     /**
-     * @param sref reference of the service to be exported
+     * @param serviceO service instance to be exported
+     * @param serviceContext bundle context of the bundle exporting the sevice
      * @param effectiveProperties combined properties of the service and additional properties from rsa
-     * @param exportedInterface name of the interface to be exported
-     * @return closeable Endpoint that represents the service that is exposed to the outside world
+     * @param exportedInterfaces name of the interface to be exported
+     * @return Endpoint that represents the service that is exposed to the outside world
      */
-    Endpoint exportService(ServiceReference<?> sref, 
+    Endpoint exportService(Object serviceO, 
+                           BundleContext serviceContext,
                            Map<String, Object> effectiveProperties,
                            Class[] exportedInterfaces);
 
     /**
-     * @param sref reference of the service offered to the requesting bundle
+     * @param cl classloader of the consumer bundle
+     * @param consumerContext bundle context of the consumer bundle
      * @param interfaces interfaces of the service to proxy
      * @param endpoint description of the remote endpoint
      * @return service proxy to be given to the requesting bundle
      * @throws IntentUnsatisfiedException
      */
-    Object importEndpoint(BundleContext consumerContext, 
+    Object importEndpoint(ClassLoader cl,
+                          BundleContext consumerContext, 
                           Class[] interfaces, 
                           EndpointDescription endpoint)
         throws IntentUnsatisfiedException;
-    
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dosgi-provider-api/src/main/java/org/apache/cxf/dosgi/dsw/api/EndpointHelper.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-provider-api/src/main/java/org/apache/cxf/dosgi/dsw/api/EndpointHelper.java b/dsw/cxf-dosgi-provider-api/src/main/java/org/apache/cxf/dosgi/dsw/api/EndpointHelper.java
new file mode 100644
index 0000000..cdc66ad
--- /dev/null
+++ b/dsw/cxf-dosgi-provider-api/src/main/java/org/apache/cxf/dosgi/dsw/api/EndpointHelper.java
@@ -0,0 +1,41 @@
+/**
+ * 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.
+ */
+package org.apache.cxf.dosgi.dsw.api;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public final class EndpointHelper {
+
+    private EndpointHelper() {
+    }
+
+    public static void addObjectClass(Map<String, Object> props, Class<?>[] interfaces) {
+        props.put(org.osgi.framework.Constants.OBJECTCLASS, getClassNames(interfaces));
+    }
+    
+    public static String[] getClassNames(Class<?>[] ifaces) {
+        List<String> ifaceNames = new ArrayList<String>();
+        for (Class<?> iface : ifaces) {
+            ifaceNames.add(iface.getName());
+        }
+        return ifaceNames.toArray(new String[]{});
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java b/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java
index b482b64..7c292db 100644
--- a/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java
+++ b/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java
@@ -27,8 +27,10 @@ import java.util.List;
 import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
 import org.apache.cxf.dosgi.dsw.api.IntentUnsatisfiedException;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -54,16 +56,18 @@ public class ClientServiceFactory implements ServiceFactory {
 
     public Object getService(final Bundle requestingBundle, final ServiceRegistration sreg) {
         List<String> interfaceNames = endpoint.getInterfaces();
+        final BundleContext consumerContext = requestingBundle.getBundleContext();
+        final ClassLoader consumerLoader = requestingBundle.adapt(BundleWiring.class).getClassLoader();
         try {
             LOG.debug("getService() from serviceFactory for {}", interfaceNames);
             final List<Class<?>> interfaces = new ArrayList<Class<?>>();
             for (String ifaceName : interfaceNames) {
-                interfaces.add(requestingBundle.loadClass(ifaceName));
+                interfaces.add(consumerLoader.loadClass(ifaceName));
             }
             Object proxy = AccessController.doPrivileged(new PrivilegedAction<Object>() {
                 public Object run() {
                     Class<?>[] ifAr = interfaces.toArray(new Class[]{});
-                    return handler.importEndpoint(requestingBundle.getBundleContext(), ifAr, endpoint);
+                    return handler.importEndpoint(consumerLoader, consumerContext, ifAr, endpoint);
                 }
             });
 

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java b/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
index d9bdabc..356de5e 100644
--- a/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
+++ b/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
@@ -34,6 +34,7 @@ import java.util.Set;
 
 import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
 import org.apache.cxf.dosgi.dsw.api.Endpoint;
+import org.apache.cxf.dosgi.dsw.api.EndpointHelper;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
@@ -175,7 +176,11 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
         try {
             Class<?>[] interfaces = getInterfaces(interfaceNames, serviceReference.getBundle());
             Map<String, Object> eprops = createEndpointProps(serviceProperties, interfaces);
-            Endpoint endpoint = provider.exportService(serviceReference, eprops, interfaces);
+            BundleContext serviceContext = serviceReference.getBundle().getBundleContext();
+            
+            // TODO unget service when export is destroyed
+            Object serviceO = serviceContext.getService(serviceReference);
+            Endpoint endpoint = provider.exportService(serviceO, serviceContext, eprops, interfaces);
             return new ExportRegistrationImpl(serviceReference, endpoint, this);
         } catch (Exception e) {
             return new ExportRegistrationImpl(this, e);
@@ -552,13 +557,13 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
         return props;
     }
     
-    protected Map<String, Object> createEndpointProps(Map<String, Object> sd, 
+    protected Map<String, Object> createEndpointProps(Map<String, Object> effectiveProps, 
                                                       Class<?>[] ifaces) {
         Map<String, Object> props = new HashMap<String, Object>();
-        copyEndpointProperties(sd, props);
+        copyEndpointProperties(effectiveProps, props);
         props.remove(org.osgi.framework.Constants.SERVICE_ID);
-        props.put(org.osgi.framework.Constants.OBJECTCLASS, getClassNames(ifaces));
-        props.put(RemoteConstants.ENDPOINT_SERVICE_ID, sd.get(org.osgi.framework.Constants.SERVICE_ID));
+        EndpointHelper.addObjectClass(props, ifaces);
+        props.put(RemoteConstants.ENDPOINT_SERVICE_ID, effectiveProps.get(org.osgi.framework.Constants.SERVICE_ID));
         String frameworkUUID = bctx.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID);
         props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, frameworkUUID);
         for (Class<?> iface : ifaces) {
@@ -568,13 +573,7 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
         return props;
     }
 
-    private String[] getClassNames(Class<?>[] ifaces) {
-        List<String> ifaceNames = new ArrayList<String>();
-        for (Class<?> iface : ifaces) {
-            ifaceNames.add(iface.getName());
-        }
-        return ifaceNames.toArray(new String[]{});
-    }
+
 
     private void copyEndpointProperties(Map<String, Object> sd, Map<String, Object> endpointProps) {
         Set<Map.Entry<String, Object>> keys = sd.entrySet();

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java b/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java
index 20cdd02..fbe2c02 100644
--- a/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java
+++ b/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java
@@ -30,6 +30,7 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
@@ -40,7 +41,7 @@ import static org.easymock.EasyMock.isA;
 public class ClientServiceFactoryTest extends TestCase {
 
     @SuppressWarnings({
-     "rawtypes", "unchecked"
+     "rawtypes"
     })
     public void testGetService() throws ClassNotFoundException {
         final Object myTestProxyObject = new Object();
@@ -49,10 +50,12 @@ public class ClientServiceFactoryTest extends TestCase {
         EndpointDescription endpoint = createTestEndpointDesc();
         ImportRegistrationImpl iri = new ImportRegistrationImpl(endpoint, null);
 
-        BundleContext requestingContext = control.createMock(BundleContext.class);
-        Bundle requestingBundle = control.createMock(Bundle.class);
-        EasyMock.expect(requestingBundle.loadClass(String.class.getName())).andReturn((Class)String.class);
-        EasyMock.expect(requestingBundle.getBundleContext()).andReturn(requestingContext);
+        BundleContext consumerContext = control.createMock(BundleContext.class);
+        Bundle consumerBundle = control.createMock(Bundle.class);
+        BundleWiring bundleWiring = control.createMock(BundleWiring.class);
+        EasyMock.expect(bundleWiring.getClassLoader()).andReturn(this.getClass().getClassLoader());
+        EasyMock.expect(consumerBundle.adapt(BundleWiring.class)).andReturn(bundleWiring);
+        EasyMock.expect(consumerBundle.getBundleContext()).andReturn(consumerContext);
         ServiceRegistration sreg = control.createMock(ServiceRegistration.class);
 
 
@@ -60,7 +63,7 @@ public class ClientServiceFactoryTest extends TestCase {
         control.replay();
 
         ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, iri);
-        assertSame(myTestProxyObject, csf.getService(requestingBundle, sreg));
+        assertSame(myTestProxyObject, csf.getService(consumerBundle, sreg));
     }
 
     /**
@@ -70,7 +73,8 @@ public class ClientServiceFactoryTest extends TestCase {
      */
     private DistributionProvider mockDistributionProvider(final Object proxy) {
         DistributionProvider handler = EasyMock.createMock(DistributionProvider.class);
-        EasyMock.expect(handler.importEndpoint(anyObject(BundleContext.class), 
+        EasyMock.expect(handler.importEndpoint(anyObject(ClassLoader.class), 
+                                               anyObject(BundleContext.class), 
                                                isA(Class[].class), 
                                                anyObject(EndpointDescription.class))).andReturn(proxy);
         EasyMock.replay(handler);

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java b/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
index 13c34f0..b0f58eb 100644
--- a/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
+++ b/dsw/cxf-dosgi-rsa/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
@@ -221,7 +221,8 @@ public class RemoteServiceAdminCoreTest {
         };
 
         DistributionProvider handler = EasyMock.createMock(DistributionProvider.class);
-        EasyMock.expect(handler.exportService(anyObject(ServiceReference.class), 
+        EasyMock.expect(handler.exportService(anyObject(),
+                                              anyObject(BundleContext.class), 
                                               anyObject(Map.class), isA(Class[].class))).andReturn(er);
         EasyMock.replay(handler);
 
@@ -312,7 +313,8 @@ public class RemoteServiceAdminCoreTest {
         eProps.put("service.imported.configs", new String[] {"org.apache.cxf.ws"});
 
         DistributionProvider handler = EasyMock.createMock(DistributionProvider.class);
-        EasyMock.expect(handler.exportService(anyObject(ServiceReference.class), 
+        EasyMock.expect(handler.exportService(anyObject(),
+                                              anyObject(BundleContext.class), 
                                               anyObject(Map.class), isA(Class[].class))).andThrow(new TestException());
         EasyMock.replay(handler);
 

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java
index 9877f10..07c5a05 100644
--- a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java
+++ b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java
@@ -27,8 +27,6 @@ import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
 import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.apache.cxf.dosgi.dsw.api.IntentUnsatisfiedException;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
@@ -41,22 +39,20 @@ public class TCPProvider implements DistributionProvider {
     public String[] getSupportedTypes() {
         return new String[] {TCP_CONFIG_TYPE};
     }
-    
-    Endpoint exportService(Object service, Map<String, Object> effectiveProperties,
+
+    @Override
+    public Endpoint exportService(Object serviceO, 
+                                  BundleContext serviceContext,
+                                  Map<String, Object> effectiveProperties,
                                   Class[] exportedInterfaces) {
         effectiveProperties.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, getSupportedTypes());
-        return new TcpEndpoint(service, effectiveProperties);
+        return new TcpEndpoint(serviceO, effectiveProperties);
     }
 
     @Override
-    public Endpoint exportService(ServiceReference<?> sref, Map<String, Object> effectiveProperties,
-                                  Class[] exportedInterfaces) {
-        BundleContext serviceContext = sref.getBundle().getBundleContext();
-        Object service = serviceContext.getService(sref);
-        return exportService(service, effectiveProperties, exportedInterfaces);
-    }
-    
-    public Object importEndpoint(ClassLoader cl, Class[] interfaces,
+    public Object importEndpoint(ClassLoader cl, 
+                                 BundleContext consumerContext, 
+                                 Class[] interfaces,
                                  EndpointDescription endpoint)
         throws IntentUnsatisfiedException {
         try {
@@ -68,12 +64,4 @@ public class TCPProvider implements DistributionProvider {
         }
     }
 
-    @Override
-    public Object importEndpoint(BundleContext consumerContext, Class[] interfaces,
-                                 EndpointDescription endpoint)
-        throws IntentUnsatisfiedException {
-        ClassLoader cl = consumerContext.getBundle().adapt(BundleWiring.class).getClassLoader();
-        return importEndpoint(cl, interfaces, endpoint);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
index ec59456..583c5e1 100644
--- a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
+++ b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
@@ -28,11 +28,13 @@ import java.util.concurrent.TimeUnit;
 import org.apache.aries.rsa.provider.tcp.myservice.MyService;
 import org.apache.aries.rsa.provider.tcp.myservice.MyServiceImpl;
 import org.apache.cxf.dosgi.dsw.api.Endpoint;
+import org.apache.cxf.dosgi.dsw.api.EndpointHelper;
+import org.easymock.EasyMock;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.osgi.framework.Constants;
+import org.osgi.framework.BundleContext;
 
 public class TcpProviderTest {
 
@@ -42,14 +44,17 @@ public class TcpProviderTest {
     
     @Before
     public void createServerAndProxy() {
-        TCPProvider provider = new TCPProvider();
-        Map<String, Object> effectiveProperties = new HashMap<String, Object>();
-        effectiveProperties.put(Constants.OBJECTCLASS, new String[] {MyService.class.getName()});
         Class<?>[] exportedInterfaces = new Class[] {MyService.class};
+        TCPProvider provider = new TCPProvider();
+        Map<String, Object> props = new HashMap<String, Object>();
+        EndpointHelper.addObjectClass(props, exportedInterfaces);
         MyService myService = new MyServiceImpl();
-        ep = provider.exportService(myService, effectiveProperties, exportedInterfaces);
+        BundleContext bc = EasyMock.mock(BundleContext.class);
+        ep = provider.exportService(myService, bc, props, exportedInterfaces);
         myServiceProxy = (MyService)provider.importEndpoint(MyService.class.getClassLoader(), 
-                                                                      exportedInterfaces, ep.description());
+                                                            bc,
+                                                            exportedInterfaces, 
+                                                            ep.description());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
index 09f5a3e..46f83eb 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
@@ -35,7 +35,6 @@ import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.util.StringPlus;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 import org.slf4j.Logger;
@@ -70,20 +69,26 @@ public class CXFDistributionProvider implements DistributionProvider {
         configTypesSet = new HashSet<>(Arrays.asList(supportedConfigurationTypes));
     }
     
+    @SuppressWarnings("rawtypes")
     @Override
-    public Endpoint exportService(ServiceReference<?> sref, Map<String, Object> effectiveProperties,
+    public Endpoint exportService(Object serviceO, 
+                                  BundleContext serviceContext,
+                                  Map<String, Object> effectiveProperties,
                                   Class[] exportedInterfaces) {
         List<String> configurationTypes = determineConfigurationTypes(effectiveProperties);
         DistributionProvider handler = getHandler(configurationTypes, effectiveProperties);
-        return handler != null ? handler.exportService(sref, effectiveProperties, exportedInterfaces) : null;
+        return handler != null ? handler.exportService(serviceO, serviceContext, 
+                                                       effectiveProperties, exportedInterfaces) : null;
     }
 
+    @SuppressWarnings("rawtypes")
     @Override
-    public Object importEndpoint(BundleContext consumerContext, Class[] iClass, EndpointDescription endpoint)
+    public Object importEndpoint(ClassLoader consumerLoader, BundleContext consumerContext, 
+                                 Class[] iClass, EndpointDescription endpoint)
         throws IntentUnsatisfiedException {
         List<String> configurationTypes = determineConfigTypesForImport(endpoint);
         DistributionProvider handler = getHandler(configurationTypes, endpoint.getProperties());
-        return handler != null ? handler.importEndpoint(consumerContext, iClass, endpoint) : null;
+        return handler != null ? handler.importEndpoint(consumerLoader, consumerContext, iClass, endpoint) : null;
     }
 
     DistributionProvider getHandler(List<String> configurationTypes,

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
index c90d7df..3249de7 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
@@ -36,7 +36,6 @@ import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 import org.slf4j.Logger;
@@ -57,9 +56,10 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
     }
 
     @SuppressWarnings("rawtypes")
-    public Object importEndpoint(BundleContext consumerContext,
-                              Class[] interfaces,
-                              EndpointDescription endpoint) {
+    public Object importEndpoint(ClassLoader consumerLoader,
+                                 BundleContext consumerContext,
+                                 Class[] interfaces,
+                                 EndpointDescription endpoint) {
         Class<?> iClass = interfaces[0];
         String address = getPojoAddress(endpoint, iClass);
         if (address == null) {
@@ -112,11 +112,10 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
     }
 
     @SuppressWarnings("rawtypes")
-    public Endpoint exportService(ServiceReference<?> sref,
-                                     Map<String, Object> endpointProps,
-                                     Class[] exportedInterfaces) throws IntentUnsatisfiedException {
-        BundleContext callingContext = sref.getBundle().getBundleContext();
-        Object serviceBean = callingContext.getService(sref);
+    public Endpoint exportService(Object serviceBean,
+                                  BundleContext callingContext,
+                                  Map<String, Object> endpointProps,
+                                  Class[] exportedInterfaces) throws IntentUnsatisfiedException {
         String contextRoot = getServletContextRoot(endpointProps);
         String address;
         Class<?> iClass = exportedInterfaces[0];

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
index e929a2d..512f96f 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
@@ -35,7 +35,6 @@ import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 import org.slf4j.Logger;
@@ -56,9 +55,10 @@ public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
     }
 
     @SuppressWarnings("rawtypes")
-    public Object importEndpoint(BundleContext consumerContext,
-                              Class[] interfaces,
-                              EndpointDescription endpoint) throws IntentUnsatisfiedException {
+    public Object importEndpoint(ClassLoader consumerLoader,
+                                 BundleContext consumerContext,
+                                 Class[] interfaces,
+                                 EndpointDescription endpoint) throws IntentUnsatisfiedException {
         Class<?> iClass = interfaces[0];
         Map<String, Object> sd = endpoint.getProperties();
         String address = getClientAddress(sd);
@@ -92,11 +92,10 @@ public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
     }
 
     @SuppressWarnings("rawtypes")
-    public Endpoint exportService(ServiceReference<?> sref,
-                                     Map<String, Object> endpointProps,
-                                     Class[] exportedInterfaces) throws IntentUnsatisfiedException {
-        BundleContext callingContext = sref.getBundle().getBundleContext();
-        Object serviceBean = callingContext.getService(sref);
+    public Endpoint exportService(Object serviceO,
+                                  BundleContext serviceContext,
+                                  Map<String, Object> endpointProps,
+                                  Class[] exportedInterfaces) throws IntentUnsatisfiedException {
         Class<?> iClass = exportedInterfaces[0];
         String address = getPojoAddress(endpointProps, iClass);
         ServerFactoryBean factory = createServerFactoryBean(endpointProps, iClass);
@@ -104,14 +103,14 @@ public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
         String contextRoot = getServletContextRoot(endpointProps);
 
         final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
-        Bus bus = createBus(sid, callingContext, contextRoot);
+        Bus bus = createBus(sid, serviceContext, contextRoot);
         factory.setBus(bus);
         factory.setServiceClass(iClass);
         factory.setAddress(address);
         
-        factory.setServiceBean(serviceBean);
-        addWsInterceptorsFeaturesProps(factory, callingContext, endpointProps);
-        setWsdlProperties(factory, callingContext, endpointProps, false);
+        factory.setServiceBean(serviceO);
+        addWsInterceptorsFeaturesProps(factory, serviceContext, endpointProps);
+        setWsdlProperties(factory, serviceContext, endpointProps, false);
         String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, endpointProps);
 
         String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
index 3bd89da..a7dcb55 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
@@ -35,8 +35,8 @@ import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -55,9 +55,10 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
     }
 
     @SuppressWarnings("rawtypes")
-    public Object importEndpoint(BundleContext consumerContext,
-                              Class[] interfaces,
-                              EndpointDescription endpoint) {
+    public Object importEndpoint(ClassLoader consumerLoader,
+                                 BundleContext consumerContext,
+                                 Class[] interfaces,
+                                 EndpointDescription endpoint) {
         Class<?> iClass = interfaces[0];
         String wsdlAddressProp = getWsdlAddress(endpoint, iClass);
         if (wsdlAddressProp == null) {
@@ -102,17 +103,16 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
     }
 
     @SuppressWarnings("rawtypes")
-    public Endpoint exportService(ServiceReference<?> sref,
-                               Map<String, Object> sd,
-                               Class[] exportedInterfaces) {
-        BundleContext callingContext = sref.getBundle().getBundleContext();
-        Object serviceBean = callingContext.getService(sref);
+    public Endpoint exportService(Object serviceO,
+                                  BundleContext serviceContext,
+                                  Map<String, Object> sd,
+                                  Class[] exportedInterfaces) {
         Class<?> iClass = exportedInterfaces[0];
         String location = OsgiUtils.getProperty(sd, Constants.WSDL_LOCATION);
         if (location == null) {
             throw new RuntimeException("WSDL location property is unavailable");
         }
-        URL wsdlURL = callingContext.getBundle().getResource(location);
+        URL wsdlURL = serviceContext.getBundle().getResource(location);
         if (wsdlURL == null) {
             throw new RuntimeException("WSDL resource at " + location + " is unavailable");
         }
@@ -127,17 +127,17 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
 
         DataBinding databinding = new JAXBDataBinding();
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
-        final Long sid = (Long) sref.getProperty(org.osgi.framework.Constants.SERVICE_ID);
-        Bus bus = createBus(sid, callingContext, contextRoot);
+        final Long sid = (Long) sd.get(RemoteConstants.ENDPOINT_SERVICE_ID);
+        Bus bus = createBus(sid, serviceContext, contextRoot);
         factory.setBus(bus);
         factory.setServiceClass(iClass);
         factory.setAddress(address != null ? address : "/");
         factory.getServiceFactory().setDataBinding(databinding);
-        factory.setServiceBean(serviceBean);
+        factory.setServiceBean(serviceO);
 
-        addWsInterceptorsFeaturesProps(factory, callingContext, sd);
+        addWsInterceptorsFeaturesProps(factory, serviceContext, sd);
 
-        setWsdlProperties(factory, callingContext, sd, true);
+        setWsdlProperties(factory, serviceContext, sd, true);
 
         String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
 

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
index 1144ae0..8f58918 100644
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
+++ b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
@@ -65,7 +65,7 @@ public class CXFDistributionProviderTest {
 
     @Test
     public void testJaxrsPropertyIgnored2() {
-        DistributionProvider handler = getHandlerWith2(Constants.RS_CONFIG_TYPE, new String[] {"HTTP", "SOAP"});
+        DistributionProvider handler = getHandlerWith(Constants.RS_CONFIG_TYPE, new String[] {"HTTP", "SOAP"});
         assertTrue(handler instanceof PojoConfigurationTypeHandler);
         assertTrue(!(handler instanceof JaxRSPojoConfigurationTypeHandler));
     }
@@ -81,28 +81,14 @@ public class CXFDistributionProviderTest {
         DistributionProvider handler = getHandlerWith(Constants.WSDL_CONFIG_TYPE, null);
         assertTrue(handler instanceof WsdlConfigurationTypeHandler);
     }
-
+    
     @Test
     public void testUnsupportedConfiguration() {
         DistributionProvider handler = getHandlerWith("notSupportedConfig", null);
         Assert.assertNull(handler);
     }
 
-    private DistributionProvider getHandlerWith(String configType, String intents) {
-        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-        EasyMock.replay(bc);
-        Map<String, Object> serviceProps = new HashMap<String, Object>();
-        serviceProps.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, configType);
-        serviceProps.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, intents);
-        IntentMap intentMap = new IntentMap(new DefaultIntentMapFactory().create());
-        IntentManager intentManager = new IntentManagerImpl(intentMap);
-        HttpServiceManager httpServiceManager = new HttpServiceManager(bc, null, null);
-        CXFDistributionProvider f = new CXFDistributionProvider(bc, intentManager, httpServiceManager);
-        List<String> configurationTypes = f.determineConfigurationTypes(serviceProps);
-        return f.getHandler(configurationTypes, serviceProps);
-    }
-
-    private DistributionProvider getHandlerWith2(String configType, String[] intents) {
+    private DistributionProvider getHandlerWith(String configType, Object intents) {
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.replay(bc);
         Map<String, Object> serviceProps = new HashMap<String, Object>();

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0111cfdc/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
index bd8c9ae..002f172 100644
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
+++ b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
@@ -30,6 +30,7 @@ import junit.framework.TestCase;
 
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.api.Endpoint;
+import org.apache.cxf.dosgi.dsw.api.EndpointHelper;
 import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoService;
 import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoService;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
@@ -50,16 +51,11 @@ import org.easymock.EasyMock;
 import org.easymock.IAnswer;
 import org.easymock.IMocksControl;
 import org.junit.Assert;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
-@SuppressWarnings({
-    "unchecked", "rawtypes"
-   })
 public class PojoConfigurationTypeHandlerTest extends TestCase {
 
     public void testGetPojoAddressEndpointURI() {
@@ -135,23 +131,25 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
             }
         };
 
+        Class<?>[] exportedInterfaces = new Class[]{Runnable.class};
+        
         Map<String, Object> props = new HashMap<String, Object>();
-
         props.put(RemoteConstants.ENDPOINT_ID, "http://google.de/");
-        props.put(org.osgi.framework.Constants.OBJECTCLASS, new String[]{"my.class"});
+        EndpointHelper.addObjectClass(props, exportedInterfaces);
         props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, new String[]{"my.config"});
         EndpointDescription endpoint = new EndpointDescription(props);
 
         cpfb.setAddress((String)EasyMock.eq(props.get(RemoteConstants.ENDPOINT_ID)));
         EasyMock.expectLastCall().atLeastOnce();
 
-        cpfb.setServiceClass(EasyMock.eq(CharSequence.class));
+        cpfb.setServiceClass(EasyMock.eq(Runnable.class));
         EasyMock.expectLastCall().atLeastOnce();
 
         c.replay();
-        Object proxy = p.importEndpoint(requestingContext, new Class<?>[]{CharSequence.class}, endpoint);
+        ClassLoader cl = null;
+        Object proxy = p.importEndpoint(cl, requestingContext, exportedInterfaces, endpoint);
         assertNotNull(proxy);
-        assertTrue("Proxy is not of the requested type! ", proxy instanceof CharSequence);
+        assertTrue("Proxy is not of the requested type! ", proxy instanceof Runnable);
         c.verify();
     }
 
@@ -177,23 +175,15 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
                 return sfb;
             }
         };
-        ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
-        
         BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
-        EasyMock.expect(bundleContext.getService(sref)).andReturn(myService);
         EasyMock.replay(bundleContext);
-        Bundle bundle = EasyMock.createNiceMock(Bundle.class);
-        EasyMock.expect(bundle.getBundleContext()).andReturn(bundleContext);
-        EasyMock.replay(bundle);
-
-        EasyMock.expect(sref.getBundle()).andReturn(bundle);
-        EasyMock.replay(sref);
         
+        Class<?>[] exportedInterface = new Class[]{String.class};
         Map<String, Object> props = new HashMap<String, Object>();
-        props.put(org.osgi.framework.Constants.OBJECTCLASS, new String[]{String.class.getName()});
+        EndpointHelper.addObjectClass(props, exportedInterface);
         props.put(Constants.WS_ADDRESS_PROPERTY, "http://alternate_host:80/myString");
 
-        Endpoint exportResult = p.exportService(sref, props, new Class[]{String.class});
+        Endpoint exportResult = p.exportService(myService, bundleContext, props, exportedInterface);
         Map<String, Object> edProps = exportResult.description().getProperties();
 
         assertNotNull(edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
@@ -223,7 +213,8 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
     }
 
     private void runAddressingTest(Map<String, Object> properties, String expectedAddress) throws Exception {
-        properties.put(org.osgi.framework.Constants.OBJECTCLASS, new String[]{Runnable.class.getName()});
+        Class<?>[] exportedInterface = new Class[]{Runnable.class};
+        EndpointHelper.addObjectClass(properties, exportedInterface);
         BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
         String expectedUUID = UUID.randomUUID().toString();
         EasyMock.expect(dswContext.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID)).andReturn(expectedUUID);
@@ -244,24 +235,16 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
         Runnable myService = EasyMock.createMock(Runnable.class);
         EasyMock.replay(myService);
         
-        ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
         BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
-        EasyMock.expect(bundleContext.getService(sref)).andReturn(myService);
-        
         EasyMock.replay(bundleContext);
-        Bundle bundle = EasyMock.createNiceMock(Bundle.class);
-        EasyMock.expect(bundle.getBundleContext()).andReturn(bundleContext);
-        EasyMock.replay(bundle);
-
-        EasyMock.expect(sref.getBundle()).andReturn(bundle);
-        EasyMock.replay(sref);
 
-
-        Endpoint result = handler.exportService(sref, properties, new Class[]{Runnable.class});
+        Endpoint result = handler.exportService(myService, bundleContext, properties, exportedInterface);
         Map<String, Object> props = result.description().getProperties();
         assertEquals(expectedAddress, props.get("org.apache.cxf.ws.address"));
-        assertTrue(Arrays.equals(new String[] {"org.apache.cxf.ws"}, (String[]) props.get("service.imported.configs")));
-        assertTrue(Arrays.equals(new String[] {"java.lang.Runnable"}, (String[]) props.get("objectClass")));
+        Assert.assertArrayEquals(new String[] {"org.apache.cxf.ws"}, 
+                     (String[]) props.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
+        Assert.assertArrayEquals(new String[] {"java.lang.Runnable"}, 
+                     (String[]) props.get(org.osgi.framework.Constants.OBJECTCLASS));
     }
 
     public void t2estCreateServerException() {
@@ -281,15 +264,12 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
             }
         };
 
-        ServiceReference<?> sref = EasyMock.createNiceMock(ServiceReference.class);
-        EasyMock.replay(sref);
-
         Map<String, Object> props = new HashMap<String, Object>();
 
         Runnable myService = EasyMock.createMock(Runnable.class);
         EasyMock.replay(myService);
         try {
-            handler.exportService(sref, props, new Class[]{Runnable.class});
+            handler.exportService(myService, null, props, new Class[]{Runnable.class});
             fail("Expected TestException");
         } catch (TestException e) {
             // Expected
@@ -356,10 +336,10 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
         PojoConfigurationTypeHandler pch = new PojoConfigurationTypeHandler(bc,
                                                                             intentManager,
                                                                             dummyHttpServiceManager());
-
+        Class<?>[] exportedInterfaces = new Class[] {String.class};
         Map<String, Object> sd = new HashMap<String, Object>();
         sd.put(org.osgi.framework.Constants.SERVICE_ID, 42);
-        sd.put(org.osgi.framework.Constants.OBJECTCLASS, new String[]{String.class.getName()});
+        EndpointHelper.addObjectClass(sd, exportedInterfaces);
         EndpointDescription epd = pch.createEndpointDesc(sd, new String[] {"org.apache.cxf.ws"},
                 "http://localhost:12345", new String[] {"my_intent", "your_intent"});
 
@@ -373,18 +353,21 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
     public void t2estCreateJaxWsEndpointWithoutIntents() {
         IMocksControl c = EasyMock.createNiceControl();
         BundleContext dswBC = c.createMock(BundleContext.class);
+        
         IntentManager intentManager = new DummyIntentManager();
         PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswBC,
                                                                                 intentManager,
                                                                                 dummyHttpServiceManager());
 
-        ServiceReference<?> sref = c.createMock(ServiceReference.class);
-
         Map<String, Object> sd = new HashMap<String, Object>();
         sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere");
-
+        BundleContext serviceBC = c.createMock(BundleContext.class);
+        Object myService = null;
         c.replay();
-        ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(sref, sd, 
+
+        ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(myService,
+                                                                           serviceBC, 
+                                                                           sd, 
                                                                            new Class[]{MyJaxWsEchoService.class});
         c.verify();
 
@@ -399,15 +382,15 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
     public void t2estCreateSimpleEndpointWithoutIntents() {
         IMocksControl c = EasyMock.createNiceControl();
         BundleContext dswBC = c.createMock(BundleContext.class);
+
         IntentManager intentManager = new DummyIntentManager();
         PojoConfigurationTypeHandler handler
             = new PojoConfigurationTypeHandler(dswBC, intentManager, dummyHttpServiceManager());
-        ServiceReference<?> sref = c.createMock(ServiceReference.class);
         Map<String, Object> sd = new HashMap<String, Object>();
         sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere_else");
-
+        BundleContext serviceBC = c.createMock(BundleContext.class);
         c.replay();
-        ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(sref, sd, 
+        ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(null, serviceBC, sd, 
                                                                           new Class[]{MySimpleEchoService.class});
         c.verify();
 


Mime
View raw message