You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2016/03/08 17:02:44 UTC

[1/2] cxf-dosgi git commit: [DOSGI-229] Move some property handling to RSA

Repository: cxf-dosgi
Updated Branches:
  refs/heads/master e01f0eee6 -> 80b4dc28f


[DOSGI-229] Move some property handling to RSA


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

Branch: refs/heads/master
Commit: 610ef4aac9c87121ab3636d155c1166e46ec85e0
Parents: e01f0ee
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Mar 8 17:01:42 2016 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Mar 8 17:01:42 2016 +0100

----------------------------------------------------------------------
 dsw/cxf-dosgi-provider-api/pom.xml              |  3 +
 dsw/cxf-dosgi-rsa/pom.xml                       |  4 +-
 .../cxf/dosgi/dsw/service/PackageUtil.java      | 85 ++++++++++++++++++++
 .../dsw/service/RemoteServiceAdminCore.java     | 37 ++++++++-
 .../dsw/service/RemoteServiceAdminCoreTest.java | 26 +++++-
 .../AbstractPojoConfigurationTypeHandler.java   | 58 +++----------
 .../dosgi/dsw/handlers/HttpServiceManager.java  |  9 +--
 .../JaxRSPojoConfigurationTypeHandler.java      | 25 +++---
 .../handlers/PojoConfigurationTypeHandler.java  | 33 ++++----
 .../handlers/WsdlConfigurationTypeHandler.java  | 15 ++--
 .../apache/cxf/dosgi/dsw/qos/IntentUtils.java   |  6 --
 .../dsw/handlers/HttpServiceManagerTest.java    |  2 +-
 .../PojoConfigurationTypeHandlerTest.java       | 29 +++----
 osgi-api/pom.xml                                | 15 ++--
 14 files changed, 227 insertions(+), 120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/dsw/cxf-dosgi-provider-api/pom.xml
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-provider-api/pom.xml b/dsw/cxf-dosgi-provider-api/pom.xml
index 9b248fb..0deab6c 100644
--- a/dsw/cxf-dosgi-provider-api/pom.xml
+++ b/dsw/cxf-dosgi-provider-api/pom.xml
@@ -24,10 +24,12 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
@@ -44,6 +46,7 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-jdk14</artifactId>
             <version>1.7.14</version>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/dsw/cxf-dosgi-rsa/pom.xml
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-rsa/pom.xml b/dsw/cxf-dosgi-rsa/pom.xml
index 149e287..b96828b 100644
--- a/dsw/cxf-dosgi-rsa/pom.xml
+++ b/dsw/cxf-dosgi-rsa/pom.xml
@@ -24,10 +24,12 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.cxf.dosgi</groupId>
@@ -49,6 +51,7 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-jdk14</artifactId>
             <version>1.7.14</version>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 
@@ -67,5 +70,4 @@
             </plugin>
         </plugins>
     </build>
-</project>
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/PackageUtil.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/PackageUtil.java b/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/PackageUtil.java
new file mode 100644
index 0000000..effcef1
--- /dev/null
+++ b/dsw/cxf-dosgi-rsa/src/main/java/org/apache/cxf/dosgi/dsw/service/PackageUtil.java
@@ -0,0 +1,85 @@
+/**
+ * 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.service;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("deprecation")
+public final class PackageUtil {
+
+    public static final Logger LOG = LoggerFactory.getLogger(PackageUtil.class);
+
+    private PackageUtil() {
+    }
+
+    /**
+     * Tries to retrieve the version of iClass via the PackageAdmin.
+     *
+     * @param iClass tThe interface for which the version should be found
+     * @param bc any valid BundleContext
+     * @return the version of the interface or "0.0.0" if no version information could be found or an error
+     *         occurred during the retrieval
+     */
+    public static String getVersion(Class<?> iClass, BundleContext bc) {
+        ServiceReference<PackageAdmin> paRef = bc.getServiceReference(PackageAdmin.class);
+        if (paRef != null) {
+            PackageAdmin pa = bc.getService(paRef);
+            try {
+                Bundle b = pa.getBundle(iClass);
+                if (b == null) {
+                    LOG.info("Unable to find interface version for interface " + iClass.getName()
+                            + ". Falling back to 0.0.0");
+                    return "0.0.0";
+                }
+                LOG.debug("Interface source bundle: {}", b.getSymbolicName());
+
+                ExportedPackage[] ep = pa.getExportedPackages(b);
+                LOG.debug("Exported Packages of the source bundle: {}", (Object)ep);
+
+                String pack = iClass.getPackage().getName();
+                LOG.debug("Looking for Package: {}", pack);
+                if (ep != null) {
+                    for (ExportedPackage p : ep) {
+                        if (p != null
+                            && pack.equals(p.getName())) {
+                            LOG.debug("found package -> Version: {}", p.getVersion());
+                            return p.getVersion().toString();
+                        }
+                    }
+                }
+            } finally {
+                if (pa != null) {
+                    bc.ungetService(paRef);
+                }
+            }
+        } else {
+            LOG.error("Was unable to obtain the package admin service -> can't resolve interface versions");
+        }
+
+        LOG.info("Unable to find interface version for interface " + iClass.getName()
+                 + ". Falling back to 0.0.0");
+        return "0.0.0";
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/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 aa6e4ee..d9bdabc 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
@@ -174,7 +174,8 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
         LOG.info("interfaces selected for export: " + interfaceNames);
         try {
             Class<?>[] interfaces = getInterfaces(interfaceNames, serviceReference.getBundle());
-            Endpoint endpoint = provider.exportService(serviceReference, serviceProperties, interfaces);
+            Map<String, Object> eprops = createEndpointProps(serviceProperties, interfaces);
+            Endpoint endpoint = provider.exportService(serviceReference, eprops, interfaces);
             return new ExportRegistrationImpl(serviceReference, endpoint, this);
         } catch (Exception e) {
             return new ExportRegistrationImpl(this, e);
@@ -550,4 +551,38 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
         }
         return props;
     }
+    
+    protected Map<String, Object> createEndpointProps(Map<String, Object> sd, 
+                                                      Class<?>[] ifaces) {
+        Map<String, Object> props = new HashMap<String, Object>();
+        copyEndpointProperties(sd, 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));
+        String frameworkUUID = bctx.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID);
+        props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, frameworkUUID);
+        for (Class<?> iface : ifaces) {
+            String pkg = iface.getPackage().getName();
+            props.put(RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + pkg, PackageUtil.getVersion(iface, bctx));
+        }
+        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();
+        for (Map.Entry<String, Object> entry : keys) {
+            String skey = entry.getKey();
+            if (!skey.startsWith(".")) {
+                endpointProps.put(skey, entry.getValue());
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/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 af7052f..13c34f0 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
@@ -33,6 +33,7 @@ import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
 import org.easymock.IMocksControl;
+import org.junit.Assert;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -41,6 +42,7 @@ import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.ExportRegistration;
 import org.osgi.service.remoteserviceadmin.ImportRegistration;
@@ -55,7 +57,7 @@ import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
 @SuppressWarnings({
-    "rawtypes", "unchecked"
+    "rawtypes", "unchecked", "deprecation"
    })
 public class RemoteServiceAdminCoreTest {
 
@@ -198,6 +200,8 @@ public class RemoteServiceAdminCoreTest {
         EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
         EasyMock.expect(bc.createFilter("(service.id=51)"))
             .andReturn(FrameworkUtil.createFilter("(service.id=51)")).anyTimes();
+        EasyMock.expect(bc.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID)).andReturn("1111");
+        EasyMock.expect(bc.getServiceReference(PackageAdmin.class)).andReturn(null);
         EasyMock.replay(bc);
 
         Map<String, Object> eProps = new HashMap<String, Object>(sProps);
@@ -488,4 +492,24 @@ public class RemoteServiceAdminCoreTest {
         }
         assertEquals("newValue", copy.get("MyProp"));
     }
+    
+    @Test
+    public void testCreateEndpointProps() {
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.expect(bc.getProperty("org.osgi.framework.uuid")).andReturn("some_uuid1");
+        EasyMock.replay(bc);
+
+        Map<String, Object> sd = new HashMap<String, Object>();
+        sd.put(org.osgi.framework.Constants.SERVICE_ID, 42);
+        DistributionProvider provider = null;
+        RemoteServiceAdminCore rsa = new RemoteServiceAdminCore(bc, bc, provider);
+        Map<String, Object> props = rsa.createEndpointProps(sd, new Class[]{String.class});
+
+        Assert.assertFalse(props.containsKey(org.osgi.framework.Constants.SERVICE_ID));
+        assertEquals(42, props.get(RemoteConstants.ENDPOINT_SERVICE_ID));
+        assertEquals("some_uuid1", props.get(RemoteConstants.ENDPOINT_FRAMEWORK_UUID));
+        assertEquals(Arrays.asList("java.lang.String"),
+                     Arrays.asList((Object[]) props.get(org.osgi.framework.Constants.OBJECTCLASS)));
+        assertEquals("0.0.0", props.get("endpoint.package.version.java.lang"));
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
index 9cbb839..9e1356c 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
@@ -20,10 +20,8 @@ package org.apache.cxf.dosgi.dsw.handlers;
 
 import java.lang.reflect.Proxy;
 import java.net.URL;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import javax.xml.namespace.QName;
 
@@ -36,6 +34,7 @@ import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.qos.IntentUtils;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
+import org.apache.cxf.dosgi.dsw.util.StringPlus;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.AbstractFeature;
@@ -45,15 +44,10 @@ import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Interceptor;
 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;
 
 public abstract class AbstractPojoConfigurationTypeHandler implements DistributionProvider {
-
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractPojoConfigurationTypeHandler.class);
     protected BundleContext bundleContext;
     protected IntentManager intentManager;
     protected HttpServiceManager httpServiceManager;
@@ -71,25 +65,11 @@ public abstract class AbstractPojoConfigurationTypeHandler implements Distributi
         }, new ServiceInvocationHandler(serviceProxy, iType));
     }
 
-    protected Map<String, Object> createEndpointProps(Map<String, Object> sd, Class<?> iClass,
-                                                      String[] importedConfigs, String address, String[] intents) {
-        Map<String, Object> props = new HashMap<String, Object>();
-
-        copyEndpointProperties(sd, props);
-
-        String[] sa = new String[] {
-            iClass.getName()
-        };
-        String pkg = iClass.getPackage().getName();
-
-        props.remove(org.osgi.framework.Constants.SERVICE_ID);
-        props.put(org.osgi.framework.Constants.OBJECTCLASS, sa);
-        props.put(RemoteConstants.ENDPOINT_SERVICE_ID, sd.get(org.osgi.framework.Constants.SERVICE_ID));
-        String frameworkUUID = bundleContext.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID);
-        props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, frameworkUUID);
+    protected EndpointDescription createEndpointDesc(Map<String, Object> props, 
+                                                     String[] importedConfigs,
+                                                     String address, 
+                                                     String[] intents) {
         props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
-        props.put(RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + pkg, OsgiUtils.getVersion(iClass, bundleContext));
-
         for (String configurationType : importedConfigs) {
             if (Constants.WS_CONFIG_TYPE.equals(configurationType)) {
                 props.put(Constants.WS_ADDRESS_PROPERTY, address);
@@ -100,26 +80,11 @@ public abstract class AbstractPojoConfigurationTypeHandler implements Distributi
                 props.put(Constants.WS_ADDRESS_PROPERTY, address);
             }
         }
-
-        String[] allIntents = IntentUtils.mergeArrays(intents, IntentUtils.getIntentsImplementedByTheService(sd));
+        String[] sIntents = StringPlus.normalize(props.get(RemoteConstants.SERVICE_INTENTS));
+        String[] allIntents = IntentUtils.mergeArrays(intents, sIntents);
         props.put(RemoteConstants.SERVICE_INTENTS, allIntents);
         props.put(RemoteConstants.ENDPOINT_ID, address);
-        return props;
-    }
-
-    private void copyEndpointProperties(Map<String, Object> sd, Map<String, Object> endpointProps) {
-        Set<Map.Entry<String, Object>> keys = sd.entrySet();
-        for (Map.Entry<String, Object> entry : keys) {
-            try {
-                String skey = entry.getKey();
-                if (!skey.startsWith(".")) {
-                    endpointProps.put(skey, entry.getValue());
-                }
-            } catch (ClassCastException e) {
-                LOG.warn("ServiceProperties Map contained non String key. Skipped " + entry + "   "
-                         + e.getLocalizedMessage());
-            }
-        }
+        return new EndpointDescription(props);
     }
 
     protected void setCommonWsdlProperties(AbstractWSDLBasedEndpointFactory factory, BundleContext context,
@@ -199,20 +164,19 @@ public abstract class AbstractPojoConfigurationTypeHandler implements Distributi
     }
 
     
-    protected Bus createBus(ServiceReference<?> sref, BundleContext callingContext, String contextRoot) {
+    protected Bus createBus(Long sid, BundleContext callingContext, String contextRoot) {
         Bus bus = BusFactory.newInstance().createBus();
         if (contextRoot != null) {
-            httpServiceManager.registerServlet(bus, contextRoot, callingContext, sref);
+            httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid);
         }
         return bus;
     }
 
-    protected Endpoint createServerFromFactory(ServerFactoryBean factory, Map<String, Object> endpointProps) {
+    protected Endpoint createServerFromFactory(ServerFactoryBean factory, EndpointDescription epd) {
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
             Server server = factory.create();
-            EndpointDescription epd = new EndpointDescription(endpointProps);
             return new ServerWrapper(epd, server);
         } finally {
             Thread.currentThread().setContextClassLoader(oldClassLoader);

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
index 77de3de..eca5460 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
@@ -70,8 +70,7 @@ public class HttpServiceManager {
         return value == null ? defaultValue : value;
     }
 
-    public Bus registerServlet(Bus bus, String contextRoot, BundleContext callingContext,
-            ServiceReference<?> sref) {
+    public Bus registerServlet(Bus bus, String contextRoot, BundleContext callingContext, Long sid) {
         bus.setExtension(new DestinationRegistryImpl(), DestinationRegistry.class);
         CXFNonSpringServlet cxf = new CXFNonSpringServlet();
         cxf.setBus(bus);
@@ -79,7 +78,8 @@ public class HttpServiceManager {
             HttpService httpService = getHttpService();
             httpService.registerServlet(contextRoot, cxf, new Hashtable<String, String>(),
                                        getHttpContext(callingContext, httpService));
-            registerUnexportHook(sref, contextRoot);
+
+            registerUnexportHook(sid, contextRoot);
 
             LOG.info("Successfully registered CXF DOSGi servlet at " + contextRoot);
         } catch (Exception e) {
@@ -113,8 +113,7 @@ public class HttpServiceManager {
      * @param sref the service reference to track
      * @param alias the HTTP servlet context alias
      */
-    private void registerUnexportHook(ServiceReference<?> sref, String alias) {
-        final Long sid = (Long) sref.getProperty(org.osgi.framework.Constants.SERVICE_ID);
+    private void registerUnexportHook(Long sid, String alias) {
         LOG.debug("Registering service listener for service with ID {}", sid);
 
         String previous = exportedAliases.put(sid, alias);

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/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 3068e8b..c90d7df 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
@@ -38,6 +38,7 @@ 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;
 import org.slf4j.LoggerFactory;
 
@@ -55,6 +56,7 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
         return new String[] {Constants.RS_CONFIG_TYPE};
     }
 
+    @SuppressWarnings("rawtypes")
     public Object importEndpoint(BundleContext consumerContext,
                               Class[] interfaces,
                               EndpointDescription endpoint) {
@@ -109,44 +111,45 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
         return getProxy(bean.create(), iClass);
     }
 
+    @SuppressWarnings("rawtypes")
     public Endpoint exportService(ServiceReference<?> sref,
-                                     Map<String, Object> sd,
+                                     Map<String, Object> endpointProps,
                                      Class[] exportedInterfaces) throws IntentUnsatisfiedException {
         BundleContext callingContext = sref.getBundle().getBundleContext();
         Object serviceBean = callingContext.getService(sref);
-        String contextRoot = getServletContextRoot(sd);
+        String contextRoot = getServletContextRoot(endpointProps);
         String address;
         Class<?> iClass = exportedInterfaces[0];
         if (contextRoot == null) {
-            address = getServerAddress(sd, iClass);
+            address = getServerAddress(endpointProps, iClass);
         } else {
-            address = getClientAddress(sd);
+            address = getClientAddress(endpointProps);
             if (address == null) {
                 address = "/";
             }
         }
-        Bus bus = createBus(sref, callingContext, contextRoot);
+        final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
+        Bus bus = createBus(sid, callingContext, contextRoot);
 
         LOG.info("Creating a " + iClass.getName()
                  + " endpoint via JaxRSPojoConfigurationTypeHandler, address is " + address);
 
-        JAXRSServerFactoryBean factory = createServerFactory(callingContext, sd, iClass, serviceBean, address, bus);
+        JAXRSServerFactoryBean factory = createServerFactory(callingContext, endpointProps, 
+                                                             iClass, serviceBean, address, bus);
         String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
 
-        // The properties for the EndpointDescription
-        Map<String, Object> endpointProps = createEndpointProps(sd, iClass, new String[] {Constants.RS_CONFIG_TYPE},
+        EndpointDescription epd = createEndpointDesc(endpointProps, new String[] {Constants.RS_CONFIG_TYPE},
                 completeEndpointAddress, new String[] {"HTTP"});
 
-        return createServerFromFactory(factory, endpointProps);
+        return createServerFromFactory(factory, epd);
     }
 
     private Endpoint createServerFromFactory(JAXRSServerFactoryBean factory,
-                                                       Map<String, Object> endpointProps) {
+                                                       EndpointDescription epd) {
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
             Server server = factory.create();
-            EndpointDescription epd = new EndpointDescription(endpointProps);
             return new ServerWrapper(epd, server);
         } finally {
             Thread.currentThread().setContextClassLoader(oldClassLoader);

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/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 129b579..e929a2d 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
@@ -37,6 +37,7 @@ 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;
 
@@ -54,6 +55,7 @@ public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
         return new String[] {Constants.WS_CONFIG_TYPE, Constants.WS_CONFIG_TYPE_OLD};
     }
 
+    @SuppressWarnings("rawtypes")
     public Object importEndpoint(BundleContext consumerContext,
                               Class[] interfaces,
                               EndpointDescription endpoint) throws IntentUnsatisfiedException {
@@ -89,35 +91,34 @@ public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
         return null;
     }
 
+    @SuppressWarnings("rawtypes")
     public Endpoint exportService(ServiceReference<?> sref,
-                                     Map<String, Object> sd,
+                                     Map<String, Object> endpointProps,
                                      Class[] exportedInterfaces) throws IntentUnsatisfiedException {
         BundleContext callingContext = sref.getBundle().getBundleContext();
         Object serviceBean = callingContext.getService(sref);
         Class<?> iClass = exportedInterfaces[0];
-        String address = getPojoAddress(sd, iClass);
-        ServerFactoryBean factory = createServerFactoryBean(sd, iClass);
-        factory.setDataBinding(getDataBinding(sd, iClass));
-        String contextRoot = getServletContextRoot(sd);
+        String address = getPojoAddress(endpointProps, iClass);
+        ServerFactoryBean factory = createServerFactoryBean(endpointProps, iClass);
+        factory.setDataBinding(getDataBinding(endpointProps, iClass));
+        String contextRoot = getServletContextRoot(endpointProps);
 
-        Bus bus = createBus(sref, callingContext, contextRoot);
+        final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
+        Bus bus = createBus(sid, callingContext, contextRoot);
         factory.setBus(bus);
         factory.setServiceClass(iClass);
         factory.setAddress(address);
         
         factory.setServiceBean(serviceBean);
-        addWsInterceptorsFeaturesProps(factory, callingContext, sd);
-        setWsdlProperties(factory, callingContext, sd, false);
-        String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
+        addWsInterceptorsFeaturesProps(factory, callingContext, endpointProps);
+        setWsdlProperties(factory, callingContext, endpointProps, false);
+        String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, endpointProps);
 
         String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
-
-            // The properties for the EndpointDescription
-        Map<String, Object> endpointProps = createEndpointProps(sd, iClass,
-                                                                    new String[]{Constants.WS_CONFIG_TYPE},
-                                                                    completeEndpointAddress, intents);
-
-        return createServerFromFactory(factory, endpointProps);
+        EndpointDescription epd = createEndpointDesc(endpointProps,
+                                                     new String[]{Constants.WS_CONFIG_TYPE},
+                                                     completeEndpointAddress, intents);
+        return createServerFromFactory(factory, epd);
     }
 
     private String getPojoAddress(Map<String, Object> sd, Class<?> iClass) {

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/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 dd477b6..3bd89da 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
@@ -54,6 +54,7 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
         return new String[] {Constants.WSDL_CONFIG_TYPE};
     }
 
+    @SuppressWarnings("rawtypes")
     public Object importEndpoint(BundleContext consumerContext,
                               Class[] interfaces,
                               EndpointDescription endpoint) {
@@ -100,6 +101,7 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
         return Service.create(wsdlAddress, serviceQname);
     }
 
+    @SuppressWarnings("rawtypes")
     public Endpoint exportService(ServiceReference<?> sref,
                                Map<String, Object> sd,
                                Class[] exportedInterfaces) {
@@ -125,8 +127,8 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
 
         DataBinding databinding = new JAXBDataBinding();
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
-        
-        Bus bus = createBus(sref, callingContext, contextRoot);
+        final Long sid = (Long) sref.getProperty(org.osgi.framework.Constants.SERVICE_ID);
+        Bus bus = createBus(sid, callingContext, contextRoot);
         factory.setBus(bus);
         factory.setServiceClass(iClass);
         factory.setAddress(address != null ? address : "/");
@@ -139,11 +141,10 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
 
         String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
 
-        // The properties for the EndpointDescription
-        Map<String, Object> endpointProps = createEndpointProps(sd, iClass,
-                                                                new String[]{Constants.WS_CONFIG_TYPE},
-                                                                address, intents);
-        return createServerFromFactory(factory, endpointProps);
+        EndpointDescription epd = createEndpointDesc(sd,
+                                                     new String[]{Constants.WS_CONFIG_TYPE},
+                                                     address, intents);
+        return createServerFromFactory(factory, epd);
     }
 
     private String getWsdlAddress(EndpointDescription endpoint, Class<?> iClass) {

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
index e41dadc..31b1e42 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
@@ -29,7 +29,6 @@ import java.util.Set;
 
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
-import org.apache.cxf.dosgi.dsw.util.StringPlus;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
 public final class IntentUtils {
@@ -38,11 +37,6 @@ public final class IntentUtils {
         // never constructed
     }
 
-    public static String[] getIntentsImplementedByTheService(Map<String, Object> serviceProperties) {
-        // Get the Intents that are implemented by the service
-        return StringPlus.normalize(serviceProperties.get(RemoteConstants.SERVICE_INTENTS));
-    }
-
     public static String[] mergeArrays(String[] a1, String[] a2) {
         if (a1 == null) {
             return a2;

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java
index a792bd6..10fba12 100644
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java
+++ b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManagerTest.java
@@ -89,7 +89,7 @@ public class HttpServiceManagerTest extends TestCase {
             }
         };
         Bus bus = BusFactory.newInstance().createBus();
-        h.registerServlet(bus, "/myService", dswContext, sr);
+        h.registerServlet(bus, "/myService", dswContext, 12345L);
 
         ServiceEvent event = new ServiceEvent(ServiceEvent.UNREGISTERING, sr);
         captured.getValue().serviceChanged(event);

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/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 93b1171..bd8c9ae 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
@@ -53,6 +53,7 @@ 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;
 
@@ -189,6 +190,7 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
         EasyMock.replay(sref);
         
         Map<String, Object> props = new HashMap<String, Object>();
+        props.put(org.osgi.framework.Constants.OBJECTCLASS, new String[]{String.class.getName()});
         props.put(Constants.WS_ADDRESS_PROPERTY, "http://alternate_host:80/myString");
 
         Endpoint exportResult = p.exportService(sref, props, new Class[]{String.class});
@@ -221,6 +223,7 @@ 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()});
         BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
         String expectedUUID = UUID.randomUUID().toString();
         EasyMock.expect(dswContext.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID)).andReturn(expectedUUID);
@@ -234,8 +237,7 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
                                                                                 dummyHttpServiceManager()) {
             @Override
             protected Endpoint createServerFromFactory(ServerFactoryBean factory,
-                                                           Map<String, Object> endpointProps) {
-                EndpointDescription epd = new EndpointDescription(endpointProps);
+                                                       EndpointDescription epd) {
                 return new ServerWrapper(epd, null);
             }
         };
@@ -258,10 +260,8 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
         Endpoint result = handler.exportService(sref, properties, new Class[]{Runnable.class});
         Map<String, Object> props = result.description().getProperties();
         assertEquals(expectedAddress, props.get("org.apache.cxf.ws.address"));
-        assertEquals("Version of java. package is always 0", "0.0.0", props.get("endpoint.package.version.java.lang"));
         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")));
-        assertEquals(expectedUUID, props.get("endpoint.framework.uuid"));
     }
 
     public void t2estCreateServerException() {
@@ -276,7 +276,7 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
                                                                                 dummyHttpServiceManager()) {
             @Override
             protected Endpoint createServerFromFactory(ServerFactoryBean factory,
-                                                           Map<String, Object> endpointProps) {
+                                                       EndpointDescription epd) {
                 throw new TestException();
             }
         };
@@ -359,20 +359,15 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
 
         Map<String, Object> sd = new HashMap<String, Object>();
         sd.put(org.osgi.framework.Constants.SERVICE_ID, 42);
-        Map<String, Object> props = pch.createEndpointProps(sd, String.class, new String[] {"org.apache.cxf.ws"},
+        sd.put(org.osgi.framework.Constants.OBJECTCLASS, new String[]{String.class.getName()});
+        EndpointDescription epd = pch.createEndpointDesc(sd, new String[] {"org.apache.cxf.ws"},
                 "http://localhost:12345", new String[] {"my_intent", "your_intent"});
 
-        assertFalse(props.containsKey(org.osgi.framework.Constants.SERVICE_ID));
-        assertEquals(42, props.get(RemoteConstants.ENDPOINT_SERVICE_ID));
-        assertEquals("some_uuid1", props.get(RemoteConstants.ENDPOINT_FRAMEWORK_UUID));
-        assertEquals("http://localhost:12345", props.get(RemoteConstants.ENDPOINT_ID));
-        assertEquals(Arrays.asList("java.lang.String"),
-                     Arrays.asList((Object[]) props.get(org.osgi.framework.Constants.OBJECTCLASS)));
-        assertEquals(Arrays.asList("org.apache.cxf.ws"),
-                     Arrays.asList((Object[]) props.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS)));
-        assertEquals(Arrays.asList("my_intent", "your_intent"),
-                     Arrays.asList((Object[]) props.get(RemoteConstants.SERVICE_INTENTS)));
-        assertEquals("0.0.0", props.get("endpoint.package.version.java.lang"));
+        assertEquals("http://localhost:12345", epd.getId());
+        assertEquals(Arrays.asList("java.lang.String"), epd.getInterfaces());
+        assertEquals(Arrays.asList("org.apache.cxf.ws"), epd.getConfigurationTypes());
+        assertEquals(Arrays.asList("my_intent", "your_intent"), epd.getIntents());
+        assertEquals(new Version("0.0.0"), epd.getPackageVersion("java.lang"));
     }
 
     public void t2estCreateJaxWsEndpointWithoutIntents() {

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/610ef4aa/osgi-api/pom.xml
----------------------------------------------------------------------
diff --git a/osgi-api/pom.xml b/osgi-api/pom.xml
index 44e09f4..6a123eb 100644
--- a/osgi-api/pom.xml
+++ b/osgi-api/pom.xml
@@ -39,6 +39,14 @@
         <!-- the minimal set of OSGi Compendium packages that is required for DOSGi to run -->
         <required-packages>org.osgi.service.remoteserviceadmin,org.osgi.service.event</required-packages>
     </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
 
     <build>
         <plugins>
@@ -59,11 +67,4 @@
         </plugins>
     </build>
 
-    <dependencies>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-        </dependency>
-    </dependencies>
-
 </project>


[2/2] cxf-dosgi git commit: [DOSGI-230] Add tcp provider

Posted by cs...@apache.org.
[DOSGI-230] Add tcp provider


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

Branch: refs/heads/master
Commit: 80b4dc28f45ac01c12989db1ac8e063c6a2027a1
Parents: 610ef4a
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Mar 8 17:02:03 2016 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Mar 8 17:02:03 2016 +0100

----------------------------------------------------------------------
 .../features/src/main/resources/features.xml    |  18 ++-
 distribution/multi-bundle/pom.xml               |   2 +
 dsw/cxf-dosgi-tcp/pom.xml                       |  72 ++++++++++++
 .../aries/rsa/provider/tcp/Activator.java       |  42 +++++++
 .../provider/tcp/LoaderObjectInputStream.java   |  43 +++++++
 .../aries/rsa/provider/tcp/LocalHostUtil.java   |  92 +++++++++++++++
 .../aries/rsa/provider/tcp/TCPProvider.java     |  79 +++++++++++++
 .../aries/rsa/provider/tcp/TCPServer.java       | 117 +++++++++++++++++++
 .../aries/rsa/provider/tcp/TcpEndpoint.java     |  57 +++++++++
 .../rsa/provider/tcp/TcpInvocationHandler.java  |  66 +++++++++++
 .../aries/rsa/provider/tcp/TcpProviderTest.java | 102 ++++++++++++++++
 .../rsa/provider/tcp/myservice/MyService.java   |  30 +++++
 .../provider/tcp/myservice/MyServiceImpl.java   |  36 ++++++
 dsw/pom.xml                                     |   1 +
 .../dosgi/systests2/multi/TestCustomIntent.java |   3 +-
 15 files changed, 754 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/distribution/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/distribution/features/src/main/resources/features.xml b/distribution/features/src/main/resources/features.xml
index b39562b..d8f74d4 100644
--- a/distribution/features/src/main/resources/features.xml
+++ b/distribution/features/src/main/resources/features.xml
@@ -16,6 +16,19 @@
     </feature>
 
     <feature name="cxf-dosgi-core" version="${project.version}">
+        <bundle start-level="8">mvn:${project.groupId}/cxf-dosgi-ri-osgi-api/${project.version}</bundle>
+        <bundle>mvn:${project.groupId}/cxf-dosgi-ri-provider-api/${project.version}</bundle>
+        <bundle>mvn:${project.groupId}/cxf-dosgi-ri-rsa/${project.version}</bundle>
+        <bundle>mvn:${project.groupId}/cxf-dosgi-ri-topology-manager/${project.version}</bundle>
+    </feature>
+    
+    <feature name="cxf-dosgi-provider-tcp" version="${project.version}">
+        <feature>cxf-dosgi-core</feature>
+        <bundle>mvn:${project.groupId}/cxf-dosgi-ri-tcp/${project.version}</bundle>
+    </feature>
+    
+    <feature name="cxf-dosgi-provider-cxf" version="${project.version}">
+        <feature>cxf-dosgi-core</feature>
         <feature>cxf-specs</feature>
         <feature>cxf-jaxws</feature>
         <feature>cxf-jaxrs</feature>
@@ -23,12 +36,9 @@
         <feature>cxf-http-jetty</feature>
         <feature>cxf-http</feature>
         <feature>http</feature>
-        <bundle start-level="8">mvn:${project.groupId}/cxf-dosgi-ri-osgi-api/${project.version}</bundle>
-        <bundle>mvn:${project.groupId}/cxf-dosgi-ri-provider-api/${project.version}</bundle>
-        <bundle>mvn:${project.groupId}/cxf-dosgi-ri-rsa/${project.version}</bundle>
-        <bundle>mvn:${project.groupId}/cxf-dosgi-ri-topology-manager/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/cxf-dosgi-ri-dsw-cxf/${project.version}</bundle>
     </feature>
+    
 
     <feature name="cxf-dosgi-discovery-local" version="${project.version}">
         <feature>cxf-dosgi-core</feature>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/distribution/multi-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/multi-bundle/pom.xml b/distribution/multi-bundle/pom.xml
index 07d1f2d..1b835ff 100644
--- a/distribution/multi-bundle/pom.xml
+++ b/distribution/multi-bundle/pom.xml
@@ -66,6 +66,8 @@
               </descriptors>
               <features>
                 <feature>cxf-dosgi-base</feature>
+                <feature>cxf-dosgi-core</feature>
+                <feature>cxf-dosgi-provider-cxf</feature>
                 <feature>cxf-dosgi-discovery-distributed</feature>
                 <feature>cxf-dosgi-zookeeper-server</feature>
               </features>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/dsw/cxf-dosgi-tcp/pom.xml
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/pom.xml b/dsw/cxf-dosgi-tcp/pom.xml
new file mode 100644
index 0000000..2d2e5f3
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/pom.xml
@@ -0,0 +1,72 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.cxf.dosgi</groupId>
+        <artifactId>cxf-dosgi-ri-parent</artifactId>
+        <version>1.8-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+    <artifactId>cxf-dosgi-ri-tcp</artifactId>
+    <packaging>bundle</packaging>
+    <name>CXF dOSGi Remote Service Admin TCP provider</name>
+    <description>Provider for Java Serialization over TCP</description>
+
+    <properties>
+        <topDirectoryLocation>../..</topDirectoryLocation>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf.dosgi</groupId>
+            <artifactId>cxf-dosgi-ri-provider-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymockclassextension</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <version>1.7.14</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Activator>org.apache.cxf.dosgi.dsw.service.Activator</Bundle-Activator>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/Activator.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/Activator.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/Activator.java
new file mode 100644
index 0000000..71d54f4
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/Activator.java
@@ -0,0 +1,42 @@
+/**
+ * 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.aries.rsa.provider.tcp;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+    @Override
+    public void start(BundleContext context) throws Exception {
+        DistributionProvider provider = new TCPProvider();
+        Dictionary<String, ?> props = new Hashtable<>();
+        context.registerService(DistributionProvider.class, provider, props);
+    }
+
+    @Override
+    public void stop(BundleContext context) throws Exception {
+        // unregister happens automatically
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LoaderObjectInputStream.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LoaderObjectInputStream.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LoaderObjectInputStream.java
new file mode 100644
index 0000000..ac60950
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LoaderObjectInputStream.java
@@ -0,0 +1,43 @@
+/**
+ * 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.aries.rsa.provider.tcp;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+
+public class LoaderObjectInputStream extends ObjectInputStream {
+
+    private ClassLoader loader;
+
+    public LoaderObjectInputStream(InputStream in, ClassLoader loader) throws IOException {
+        super(in);
+        this.loader = loader;
+    }
+
+    @Override
+    protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
+        try {
+            return loader.loadClass(desc.getName());
+        } catch (ClassNotFoundException e) {
+            return super.resolveClass(desc);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java
new file mode 100644
index 0000000..3f40bd8
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java
@@ -0,0 +1,92 @@
+/**
+ * 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.aries.rsa.provider.tcp;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * Utility methods to get the local address even on a linux host.
+ */
+public final class LocalHostUtil {
+
+    private LocalHostUtil() {
+        // Util Class
+    }
+
+    /**
+     * Returns an InetAddress representing the address of the localhost. Every
+     * attempt is made to find an address for this host that is not the loopback
+     * address. If no other address can be found, the loopback will be returned.
+     *
+     * @return InetAddress the address of localhost
+     * @throws UnknownHostException if there is a problem determining the address
+     */
+    public static InetAddress getLocalHost() throws UnknownHostException {
+        InetAddress localHost = InetAddress.getLocalHost();
+        if (!localHost.isLoopbackAddress()) {
+            return localHost;
+        }
+        InetAddress[] addrs = getAllLocalUsingNetworkInterface();
+        for (InetAddress addr : addrs) {
+            if (!addr.isLoopbackAddress() && !addr.getHostAddress().contains(":")) {
+                return addr;
+            }
+        }
+        return localHost;
+    }
+
+    /**
+     * Utility method that delegates to the methods of NetworkInterface to
+     * determine addresses for this machine.
+     *
+     * @return all addresses found from the NetworkInterfaces
+     * @throws UnknownHostException if there is a problem determining addresses
+     */
+    private static InetAddress[] getAllLocalUsingNetworkInterface() throws UnknownHostException {
+        try {
+            List<InetAddress> addresses = new ArrayList<InetAddress>();
+            Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
+            while (e.hasMoreElements()) {
+                NetworkInterface ni = e.nextElement();
+                for (Enumeration<InetAddress> e2 = ni.getInetAddresses(); e2.hasMoreElements();) {
+                    addresses.add(e2.nextElement());
+                }
+            }
+            return addresses.toArray(new InetAddress[] {});
+        } catch (SocketException ex) {
+            throw new UnknownHostException("127.0.0.1");
+        }
+    }
+
+    public static String getLocalIp() {
+        String localIP;
+        try {
+            localIP = getLocalHost().getHostAddress();
+        } catch (Exception e) {
+            localIP = "localhost";
+        }
+        return localIP;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/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
new file mode 100644
index 0000000..9877f10
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPProvider.java
@@ -0,0 +1,79 @@
+/**
+ * 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.aries.rsa.provider.tcp;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.net.URI;
+import java.util.Map;
+
+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;
+
+@SuppressWarnings("rawtypes")
+public class TCPProvider implements DistributionProvider {
+
+    private static final String TCP_CONFIG_TYPE = "aries.tcp";
+
+    @Override
+    public String[] getSupportedTypes() {
+        return new String[] {TCP_CONFIG_TYPE};
+    }
+    
+    Endpoint exportService(Object service, Map<String, Object> effectiveProperties,
+                                  Class[] exportedInterfaces) {
+        effectiveProperties.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, getSupportedTypes());
+        return new TcpEndpoint(service, 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,
+                                 EndpointDescription endpoint)
+        throws IntentUnsatisfiedException {
+        try {
+            URI address = new URI(endpoint.getId());
+            InvocationHandler handler = new TcpInvocationHandler(cl, address.getHost(), address.getPort());
+            return Proxy.newProxyInstance(cl, interfaces, handler);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @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/80b4dc28/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPServer.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPServer.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPServer.java
new file mode 100644
index 0000000..0eeebc9
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TCPServer.java
@@ -0,0 +1,117 @@
+/**
+ * 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.aries.rsa.provider.tcp;
+
+import java.io.Closeable;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+public class TCPServer implements Closeable, Runnable {
+    private ServerSocket serverSocket;
+    private Object service;
+    private boolean running;
+    private ExecutorService executor;
+
+    public TCPServer(Object service, String localip, Integer port) {
+        this.service = service;
+        try {
+            this.serverSocket = new ServerSocket(port);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        this.running = true;
+        this.executor = Executors.newCachedThreadPool();
+        for (int c = 0; c < 100; c++) {
+            this.executor.execute(this);
+        }
+    }
+    
+    int getPort() {
+        return this.serverSocket.getLocalPort();
+    }
+    
+    
+
+    public void run() {
+        ClassLoader serviceCL = service.getClass().getClassLoader();
+        while (running) {
+            try (
+                Socket socket = this.serverSocket.accept();
+                ObjectInputStream ois = new LoaderObjectInputStream(socket.getInputStream(), serviceCL);
+                ObjectOutputStream objectOutput = new ObjectOutputStream(socket.getOutputStream())
+                ) {
+                String methodName = (String)ois.readObject();
+                Object[] args = (Object[])ois.readObject();
+                Object result = invoke(methodName, args);
+                objectOutput.writeObject(result);
+            } catch (SocketException e) {
+                running = false;
+            } catch (EOFException e) {
+                // This is normal
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    private Object invoke(String methodName, Object[] args)
+        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+        Class<?>[] parameterTypesAr = getTypes(args);
+        Method method = service.getClass().getMethod(methodName, parameterTypesAr);
+        try {
+            return method.invoke(service, args);
+        } catch (Throwable e) {
+            return e;
+        }
+    }
+
+    private Class<?>[] getTypes(Object[] args) {
+        List<Class<?>> parameterTypes = new ArrayList<>();
+        for (Object arg : args) {
+            parameterTypes.add(arg.getClass());
+        }
+        Class<?>[] parameterTypesAr = parameterTypes.toArray(new Class[]{});
+        return parameterTypesAr;
+    }
+
+    @Override
+    public void close() throws IOException {
+        this.serverSocket.close();
+        this.running = false;
+        this.executor.shutdown();
+        try {
+            this.executor.awaitTermination(10, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+        }
+        this.executor.shutdownNow();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpEndpoint.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpEndpoint.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpEndpoint.java
new file mode 100644
index 0000000..b45347a
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpEndpoint.java
@@ -0,0 +1,57 @@
+/**
+ * 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.aries.rsa.provider.tcp;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.cxf.dosgi.dsw.api.Endpoint;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+
+public class TcpEndpoint implements Endpoint {
+    private EndpointDescription epd;
+    private TCPServer tcpServer;
+    
+    public TcpEndpoint(Object service, Map<String, Object> effectiveProperties) {
+        Integer port = getInt(effectiveProperties, "port");
+        String localip = LocalHostUtil.getLocalIp();
+        tcpServer = new TCPServer(service, localip, port);
+        effectiveProperties.put(RemoteConstants.ENDPOINT_ID, "tcp://" + localip + ":" + tcpServer.getPort());
+        effectiveProperties.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, "");
+        this.epd = new EndpointDescription(effectiveProperties);
+    }
+    
+
+    private Integer getInt(Map<String, Object> effectiveProperties, String key) {
+        String value = (String)effectiveProperties.get(key);
+        return value != null ? Integer.parseInt(value) : 0;
+    }
+
+    @Override
+    public EndpointDescription description() {
+        return this.epd;
+    }
+
+
+    @Override
+    public void close() throws IOException {
+        tcpServer.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java
new file mode 100644
index 0000000..37ed11e
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java
@@ -0,0 +1,66 @@
+/**
+ * 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.aries.rsa.provider.tcp;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+public class TcpInvocationHandler implements InvocationHandler {
+    private String host;
+    private int port;
+    private ClassLoader cl;
+
+    public TcpInvocationHandler(ClassLoader cl, String host, int port)
+        throws UnknownHostException, IOException {
+        this.cl = cl;
+        this.host = host;
+        this.port = port;
+
+    }
+
+    @Override
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+        try (
+            Socket socket = new Socket(this.host, this.port);
+            ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream())
+            ) {
+            out.writeObject(method.getName());
+            out.writeObject(args);
+            out.flush();
+            return parseResult(socket);
+        }
+    }
+
+    private Object parseResult(Socket socket) throws IOException, ClassNotFoundException, Throwable {
+        try (ObjectInputStream in = new LoaderObjectInputStream(socket.getInputStream(), cl)) {
+            Object result = in.readObject();
+            if (result instanceof Throwable) {
+                throw (Throwable)result;
+            } else {
+                return result;
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/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
new file mode 100644
index 0000000..570bc85
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
@@ -0,0 +1,102 @@
+/**
+ * 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.aries.rsa.provider.tcp;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+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.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Constants;
+
+public class TcpProviderTest {
+
+    private static final int NUM_CALLS = 10000;
+    private MyService myServiceProxy;
+    private Endpoint ep;
+    
+    @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};
+        MyService myService = new MyServiceImpl();
+        ep = provider.exportService(myService, effectiveProperties, exportedInterfaces);
+        myServiceProxy = (MyService)provider.importEndpoint(MyService.class.getClassLoader(), 
+                                                                      exportedInterfaces, ep.description());
+    }
+
+    @Test
+    public void testPerf() throws IOException, InterruptedException {
+        //runPerfTest(myServiceProxy);
+        String msg = "test";
+        String result = myServiceProxy.echo(msg);
+        Assert.assertEquals(msg, result);
+    }
+    
+    @Test
+    public void testCall() throws IOException, InterruptedException {
+        myServiceProxy.call("test");
+    }
+    
+    @Test
+    public void testCallOneway() throws IOException, InterruptedException {
+        myServiceProxy.callOneWay("test");
+    }
+    
+    @After
+    public void close() throws IOException {
+        ep.close();
+    }
+
+    private void runPerfTest(final MyService myServiceProxy2) throws InterruptedException {
+        StringBuilder msg = new StringBuilder();
+        for (int c = 0; c < 1000; c++) {
+            msg.append("testing123");
+        }
+        final String msg2 = msg.toString();
+        ExecutorService executor = Executors.newFixedThreadPool(100);
+        Runnable task = new Runnable() {
+            
+            @Override
+            public void run() {
+                String result = myServiceProxy2.echo(msg2);
+                Assert.assertEquals(msg2, result);
+            }
+        };
+        long start = System.currentTimeMillis();
+        for (int c = 0; c < NUM_CALLS; c++) {
+            executor.execute(task);
+        }
+        executor.shutdown();
+        executor.awaitTermination(100, TimeUnit.SECONDS);
+        long tps = NUM_CALLS * 1000 / (System.currentTimeMillis() - start);
+        System.out.println(tps);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyService.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyService.java b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyService.java
new file mode 100644
index 0000000..e9d56bf
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyService.java
@@ -0,0 +1,30 @@
+/**
+ * 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.aries.rsa.provider.tcp.myservice;
+
+import javax.jws.Oneway;
+
+public interface MyService {
+    String echo(String msg);
+    void call(String msg);
+
+    // Oneway not yet supported
+    @Oneway
+    void callOneWay(String msg);
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java
new file mode 100644
index 0000000..5f469ed
--- /dev/null
+++ b/dsw/cxf-dosgi-tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java
@@ -0,0 +1,36 @@
+/**
+ * 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.aries.rsa.provider.tcp.myservice;
+
+public class MyServiceImpl implements MyService {
+
+    @Override
+    public String echo(String msg) {
+        return msg;
+    }
+
+    @Override
+    public void call(String msg) {
+    }
+
+    @Override
+    public void callOneWay(String msg) {
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/dsw/pom.xml
----------------------------------------------------------------------
diff --git a/dsw/pom.xml b/dsw/pom.xml
index 5913585..375d8fc 100644
--- a/dsw/pom.xml
+++ b/dsw/pom.xml
@@ -41,5 +41,6 @@
       <module>cxf-dosgi-provider-api</module>
       <module>cxf-dosgi-rsa</module>
       <module>cxf-dsw</module>
+      <module>cxf-dosgi-tcp</module>
     </modules>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/80b4dc28/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
index 2200567..04ddcdc 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
@@ -23,8 +23,6 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
-import junit.framework.Assert;
-
 import org.apache.cxf.dosgi.samples.greeter.GreeterService;
 import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase;
 import org.apache.cxf.dosgi.systests2.multi.customintent.AddGreetingPhraseInterceptor;
@@ -33,6 +31,7 @@ import org.apache.cxf.dosgi.systests2.multi.customintent.CustomIntentActivator;
 import org.apache.cxf.dosgi.systests2.multi.customintent.service.EmptyGreeterService;
 import org.apache.cxf.dosgi.systests2.multi.customintent.service.GreeterServiceWithCustomIntentActivator;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;