cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [2/3] cxf-dosgi git commit: [DOSGI-229] Refactor api and fix some issues
Date Thu, 03 Mar 2016 14:42:14 GMT
[DOSGI-229] Refactor api and fix some issues


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

Branch: refs/heads/master
Commit: b5f02ff5a70a94fb04918fc61e32775b234b3546
Parents: 7b4c8df
Author: Christian Schneider <chris@die-schneider.net>
Authored: Thu Mar 3 15:41:37 2016 +0100
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Thu Mar 3 15:41:58 2016 +0100

----------------------------------------------------------------------
 dsw/cxf-dsw/pom.xml                             |   5 +
 .../dosgi/dsw/api/ConfigurationTypeHandler.java |  43 ------
 .../cxf/dosgi/dsw/api/DistributionProvider.java |  52 +++++++
 .../org/apache/cxf/dosgi/dsw/api/Endpoint.java  |  27 ++++
 .../apache/cxf/dosgi/dsw/api/ExportResult.java  |  53 -------
 .../dosgi/dsw/decorator/DecorationParser.java   |  42 +++---
 .../dsw/decorator/ServiceDecoratorImpl.java     |   9 +-
 .../AbstractPojoConfigurationTypeHandler.java   |  14 +-
 .../dsw/handlers/ConfigTypeHandlerFactory.java  |  27 ++--
 .../JaxRSPojoConfigurationTypeHandler.java      |  35 +++--
 .../handlers/PojoConfigurationTypeHandler.java  |  59 ++++----
 .../cxf/dosgi/dsw/handlers/ServerWrapper.java   |  21 ++-
 .../handlers/WsdlConfigurationTypeHandler.java  |  19 ++-
 .../dosgi/dsw/service/ClientServiceFactory.java |  17 +--
 .../dsw/service/ConfigTypeHandlerFinder.java    |   6 +-
 .../dsw/service/ExportRegistrationImpl.java     |  14 +-
 .../dsw/service/RemoteServiceAdminCore.java     | 145 ++++++++-----------
 .../dsw/decorator/DecorationParserTest.java     |   7 +-
 .../dosgi/dsw/decorator/InterfaceRuleTest.java  |   1 +
 .../dsw/decorator/ServiceDecoratorImplTest.java |   1 +
 .../dsw/handlers/ClientServiceFactoryTest.java  |  26 ++--
 .../handlers/ConfigTypeHandlerFactoryTest.java  |  26 ++--
 .../PojoConfigurationTypeHandlerTest.java       | 101 +++++++------
 .../dosgi/dsw/service/EventProducerTest.java    |  31 ++--
 .../dsw/service/RemoteServiceAdminCoreTest.java |  43 +++---
 parent/pom.xml                                  |   6 +-
 .../dosgi/systests2/multi/MultiBundleTools.java |  13 --
 .../systests2/multi/TestImportService.java      |  27 ++--
 28 files changed, 425 insertions(+), 445 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/pom.xml
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/pom.xml b/dsw/cxf-dsw/pom.xml
index 52727ae..3693a23 100644
--- a/dsw/cxf-dsw/pom.xml
+++ b/dsw/cxf-dsw/pom.xml
@@ -97,6 +97,11 @@
             <artifactId>easymockclassextension</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <version>1.7.14</version>
+        </dependency>
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/ConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/ConfigurationTypeHandler.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/ConfigurationTypeHandler.java
deleted file mode 100644
index fb42606..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/ConfigurationTypeHandler.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.Map;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-
-public interface ConfigurationTypeHandler {
-
-    String[] getSupportedTypes();
-
-    ExportResult createServer(ServiceReference<?> serviceReference,
-                        BundleContext dswContext,
-                        BundleContext callingContext,
-                        Map<String, Object> sd,
-                        Class<?> iClass,
-                        Object serviceBean);
-
-    Object createProxy(ServiceReference<?> serviceReference,
-                       BundleContext dswContext,
-                       BundleContext callingContext,
-                       Class<?> iClass, 
-                       EndpointDescription endpoint) throws IntentUnsatisfiedException;
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java
new file mode 100644
index 0000000..a16f2bd
--- /dev/null
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/DistributionProvider.java
@@ -0,0 +1,52 @@
+/**
+ * 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.Map;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+
+public interface DistributionProvider {
+
+    String[] getSupportedTypes();
+
+    /**
+     * 
+     * @param sref reference of the service to be exported
+     * @param effectiveProperties combined properties of the service and additional properties from rsa
+     * @param exportedInterface name of the interface to be exported
+     * @return
+     */
+    Endpoint createServer(ServiceReference<?> sref,
+                          Map<String, Object> effectiveProperties,
+                          String exportedInterface);
+
+    /**
+     * 
+     * @param sref reference of the service offered to the requesting bundle
+     * @param iClass
+     * @param endpoint description of the remote endpoint
+     * @return service proxy to be given to the requesting bundle
+     * @throws IntentUnsatisfiedException
+     */
+    Object createProxy(ServiceReference<?> sref,
+                       Class<?> iClass, 
+                       EndpointDescription endpoint) throws IntentUnsatisfiedException;
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/Endpoint.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/Endpoint.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/Endpoint.java
new file mode 100644
index 0000000..f45b562
--- /dev/null
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/Endpoint.java
@@ -0,0 +1,27 @@
+/**
+ * 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.io.Closeable;
+
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+
+public interface Endpoint extends Closeable {
+    EndpointDescription description();
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/ExportResult.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/ExportResult.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/ExportResult.java
deleted file mode 100644
index 86acf8c..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/api/ExportResult.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.io.Closeable;
-import java.util.Map;
-
-public class ExportResult {
-
-    private final Map<String, Object> endpointProps;
-    private final Closeable server;
-    private final Exception exception;
-
-    public ExportResult(Map<String, Object> endpointProps, Closeable server) {
-        this.endpointProps = endpointProps;
-        this.server = server;
-        this.exception = null;
-    }
-
-    public ExportResult(Map<String, Object> endpointProps, Exception ex) {
-        this.endpointProps = endpointProps;
-        this.server = null;
-        this.exception = ex;
-    }
-
-    public Map<String, Object> getEndpointProps() {
-        return endpointProps;
-    }
-
-    public Closeable getServer() {
-        return server;
-    }
-
-    public Exception getException() {
-        return exception;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
index c7a8f96..82753b1 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParser.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.dosgi.dsw.decorator;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
@@ -28,19 +29,17 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 
-import org.xml.sax.SAXException;
 import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationType;
 import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationsType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 class DecorationParser {
-    private static final Logger LOG = LoggerFactory.getLogger(ServiceDecoratorImpl.class);
     private JAXBContext jaxbContext;
     private Schema schema;
 
@@ -51,29 +50,36 @@ class DecorationParser {
             SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
             URL resource = getClass().getResource("/service-decoration.xsd");
             schema = schemaFactory.newSchema(resource);
-        } catch (JAXBException e) {
-            throw new RuntimeException(e.getMessage(), e);
-        } catch (SAXException e) {
+        } catch (Exception e) {
             throw new RuntimeException("Error loading decorations schema", e);
         }
 
     }
 
-    List<ServiceDecorationType> getDecorations(URL resourceURL) {
-        if (resourceURL == null) {
+    List<ServiceDecorationType> getDecorations(URL resourceURL) throws JAXBException, IOException {
+        if (resourceURL == null || !decorationType(resourceURL)) {
             return new ArrayList<ServiceDecorationType>();
         }
+        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+        unmarshaller.setSchema(schema);
+        InputStream is = resourceURL.openStream();
+        Source source = new StreamSource(is);
+        JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class);
+        ServiceDecorationsType decorations = jaxb.getValue();
+        return decorations.getServiceDecoration();
+    }
+
+    private boolean decorationType(URL resourceURL) {
         try {
-            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-            unmarshaller.setSchema(schema);
             InputStream is = resourceURL.openStream();
-            Source source = new StreamSource(is);
-            JAXBElement<ServiceDecorationsType> jaxb = unmarshaller.unmarshal(source, ServiceDecorationsType.class);
-            ServiceDecorationsType decorations = jaxb.getValue();
-            return decorations.getServiceDecoration();
-        } catch (Exception ex) {
-            LOG.warn("Problem parsing: " + resourceURL, ex);
-            return new ArrayList<ServiceDecorationType>();
+            XMLInputFactory factory = XMLInputFactory.newInstance();
+            XMLStreamReader reader = factory.createXMLStreamReader(is);
+            reader.next();
+            String ns = reader.getNamespaceURI();
+            reader.close();
+            return ns.equals("http://cxf.apache.org/xmlns/service-decoration/1.0.0");
+        } catch (Exception e) {
+            return false;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
index cc8a2dc..20130c3 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImpl.java
@@ -32,8 +32,11 @@ import org.apache.cxf.xmlns.service_decoration._1_0.MatchType;
 import org.apache.cxf.xmlns.service_decoration._1_0.ServiceDecorationType;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ServiceDecoratorImpl implements ServiceDecorator {
+    private static final Logger LOG = LoggerFactory.getLogger(ServiceDecoratorImpl.class);
     final List<Rule> decorations = new CopyOnWriteArrayList<Rule>();
 
     private DecorationParser parser;
@@ -75,7 +78,11 @@ public class ServiceDecoratorImpl implements ServiceDecorator {
         }
         List<ServiceDecorationType> elements = new ArrayList<ServiceDecorationType>();
         while (entries.hasMoreElements()) {
-            elements.addAll(parser.getDecorations((URL)entries.nextElement()));
+            try {
+                elements.addAll(parser.getDecorations((URL)entries.nextElement()));
+            } catch (Exception e) {
+                LOG.warn("Error parsing remote-service descriptions in bundle" + bundle.getSymbolicName(), e);
+            }
         }
         return elements;
     }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/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 7992062..b1dffff 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
@@ -31,8 +31,8 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.api.ConfigurationTypeHandler;
-import org.apache.cxf.dosgi.dsw.api.ExportResult;
+import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
+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.ClassUtils;
@@ -47,11 +47,12 @@ 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 ConfigurationTypeHandler {
+public abstract class AbstractPojoConfigurationTypeHandler implements DistributionProvider {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractPojoConfigurationTypeHandler.class);
     protected BundleContext bundleContext;
@@ -206,14 +207,13 @@ public abstract class AbstractPojoConfigurationTypeHandler implements Configurat
         return bus;
     }
 
-    protected ExportResult createServerFromFactory(ServerFactoryBean factory, Map<String, Object> endpointProps) {
+    protected Endpoint createServerFromFactory(ServerFactoryBean factory, Map<String, Object> endpointProps) {
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
             Server server = factory.create();
-            return new ExportResult(endpointProps, new ServerWrapper(server));
-        } catch (Exception e) {
-            return new ExportResult(endpointProps, e);
+            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/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
index 8c0a881..5d92eeb 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
@@ -25,7 +25,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.api.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.service.ConfigTypeHandlerFinder;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
@@ -65,19 +65,19 @@ public class ConfigTypeHandlerFactory implements ConfigTypeHandlerFinder {
     }
 
     @Override
-    public ConfigurationTypeHandler getHandler(BundleContext dswBC,
+    public DistributionProvider getHandler(BundleContext dswBC,
             Map<String, Object> serviceProperties) {
         List<String> configurationTypes = determineConfigurationTypes(serviceProperties);
         return getHandler(dswBC, configurationTypes, serviceProperties);
     }
 
     @Override
-    public ConfigurationTypeHandler getHandler(BundleContext dswBC, EndpointDescription endpoint) {
+    public DistributionProvider getHandler(BundleContext dswBC, EndpointDescription endpoint) {
         List<String> configurationTypes = determineConfigTypesForImport(endpoint);
         return getHandler(dswBC, configurationTypes, endpoint.getProperties());
     }
 
-    private ConfigurationTypeHandler getHandler(BundleContext dswBC,
+    private DistributionProvider getHandler(BundleContext dswBC,
                                                List<String> configurationTypes,
                                                Map<String, Object> serviceProperties) {
         intentManager.assertAllIntentsSupported(serviceProperties);
@@ -89,7 +89,8 @@ public class ConfigTypeHandlerFactory implements ConfigTypeHandlerFinder {
         } else if (configurationTypes.contains(Constants.WSDL_CONFIG_TYPE)) {
             return wsdlConfigurationTypeHandler;
         }
-        throw new RuntimeException("None of the configuration types in " + configurationTypes + " is supported.");
+        LOG.info("None of the configuration types in " + configurationTypes + " is supported.");
+        return null;
     }
 
     private boolean isJaxrsRequested(Collection<String> types, Map<String, Object> serviceProperties) {
@@ -138,20 +139,13 @@ public class ConfigTypeHandlerFactory implements ConfigTypeHandlerFinder {
                 configurationTypes.add(rct);
             }
         }
-        LOG.info("configuration types selected for export: " + configurationTypes);
-        if (configurationTypes.isEmpty()) {
-            throw new RuntimeException("the requested configuration types are not supported");
-        }
+        LOG.info("Configuration types selected for export: {}.", configurationTypes);
         return configurationTypes;
     }
 
     private List<String> determineConfigTypesForImport(EndpointDescription endpoint) {
         List<String> remoteConfigurationTypes = endpoint.getConfigurationTypes();
 
-        if (remoteConfigurationTypes == null) {
-            throw new RuntimeException("The supplied endpoint has no configuration type");
-        }
-
         List<String> usableConfigurationTypes = new ArrayList<String>();
         for (String ct : supportedConfigurationTypes) {
             if (remoteConfigurationTypes.contains(ct)) {
@@ -159,11 +153,8 @@ public class ConfigTypeHandlerFactory implements ConfigTypeHandlerFinder {
             }
         }
 
-        if (usableConfigurationTypes.isEmpty()) {
-            throw new RuntimeException("The supplied endpoint has no compatible configuration type. "
-                    + "Supported types are: " + supportedConfigurationTypes
-                    + "    Types needed by the endpoint: " + remoteConfigurationTypes);
-        }
+        LOG.info("Ignoring endpoint {} as it has no compatible configuration types: {}.", 
+                 endpoint.getId(), remoteConfigurationTypes);
         return usableConfigurationTypes;
     }
 

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/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 bf15c1c..7fc5956 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
@@ -25,9 +25,10 @@ import java.util.Map;
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.util.ProxyClassLoader;
 import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.api.ExportResult;
+import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.apache.cxf.dosgi.dsw.api.IntentUnsatisfiedException;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
+import org.apache.cxf.dosgi.dsw.util.ClassUtils;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
@@ -55,18 +56,18 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
         return new String[] {Constants.RS_CONFIG_TYPE};
     }
 
-    public Object createProxy(ServiceReference<?> serviceReference, BundleContext dswContext,
-                              BundleContext callingContext, Class<?> iClass,
-                              EndpointDescription endpoint) throws IntentUnsatisfiedException {
+    public Object createProxy(ServiceReference<?> sref,
+                              Class<?> iClass,
+                              EndpointDescription endpoint) {
+        BundleContext callingContext = sref.getBundle().getBundleContext();
         String address = getPojoAddress(endpoint, iClass);
         if (address == null) {
             LOG.warn("Remote address is unavailable");
             return null;
         }
-
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         try {
-            return createJaxrsProxy(address, callingContext, dswContext, iClass, null, endpoint);
+            return createJaxrsProxy(address, callingContext, iClass, null, endpoint);
         } catch (Throwable e) {
             Thread.currentThread().setContextClassLoader(oldClassLoader);
         }
@@ -74,7 +75,7 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
         try {
             ProxyClassLoader cl = new ProxyClassLoader(iClass.getClassLoader());
             cl.addLoader(Client.class.getClassLoader());
-            return createJaxrsProxy(address, callingContext, dswContext, iClass, cl, endpoint);
+            return createJaxrsProxy(address, callingContext, iClass, cl, endpoint);
         } catch (Throwable e) {
             LOG.warn("proxy creation failed", e);
         }
@@ -83,7 +84,6 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
     }
 
     protected Object createJaxrsProxy(String address,
-                                      BundleContext dswContext,
                                       BundleContext callingContext,
                                       Class<?> iClass,
                                       ClassLoader loader,
@@ -110,11 +110,12 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
         return getProxy(bean.create(), iClass);
     }
 
-    public ExportResult createServer(ServiceReference<?> sref,
-                                     BundleContext dswContext,
-                                     BundleContext callingContext,
-                                     Map<String, Object> sd, Class<?> iClass,
-                                     Object serviceBean) throws IntentUnsatisfiedException {
+    public Endpoint createServer(ServiceReference<?> sref,
+                                     Map<String, Object> sd,
+                                     String exportedInterface) throws IntentUnsatisfiedException {
+        BundleContext callingContext = sref.getBundle().getBundleContext();
+        Object serviceBean = callingContext.getService(sref);
+        Class<?> iClass = ClassUtils.getInterfaceClass(serviceBean, exportedInterface);
         String contextRoot = getServletContextRoot(sd);
         String address;
         if (contextRoot == null) {
@@ -125,7 +126,6 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
                 address = "/";
             }
         }
-
         Bus bus = createBus(sref, callingContext, contextRoot);
 
         LOG.info("Creating a " + iClass.getName()
@@ -141,15 +141,14 @@ public class JaxRSPojoConfigurationTypeHandler extends AbstractPojoConfiguration
         return createServerFromFactory(factory, endpointProps);
     }
 
-    private ExportResult createServerFromFactory(JAXRSServerFactoryBean factory,
+    private Endpoint createServerFromFactory(JAXRSServerFactoryBean factory,
                                                        Map<String, Object> endpointProps) {
         ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
             Server server = factory.create();
-            return new ExportResult(endpointProps, new ServerWrapper(server));
-        } catch (Exception e) {
-            return new ExportResult(endpointProps, e);
+            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/b5f02ff5/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 dcea099..f57fcf3 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
@@ -26,9 +26,10 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.api.ExportResult;
+import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.apache.cxf.dosgi.dsw.api.IntentUnsatisfiedException;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
+import org.apache.cxf.dosgi.dsw.util.ClassUtils;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.jaxb.JAXBDataBinding;
@@ -54,8 +55,9 @@ public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
         return new String[] {Constants.WS_CONFIG_TYPE, Constants.WS_CONFIG_TYPE_OLD};
     }
 
-    public Object createProxy(ServiceReference<?> sref, BundleContext dswContext, BundleContext callingContext,
-                              Class<?> iClass, EndpointDescription endpoint) throws IntentUnsatisfiedException {
+    public Object createProxy(ServiceReference<?> sref,
+                              Class<?> iClass,
+                              EndpointDescription endpoint) throws IntentUnsatisfiedException {
         Map<String, Object> sd = endpoint.getProperties();
         String address = getClientAddress(sd);
         if (address == null) {
@@ -72,8 +74,9 @@ public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
             factory.getServiceFactory().setDataBinding(getDataBinding(sd, iClass));
             factory.setServiceClass(iClass);
             factory.setAddress(address);
+            BundleContext callingContext = sref.getBundle().getBundleContext();
             addWsInterceptorsFeaturesProps(factory.getClientFactoryBean(), callingContext, sd);
-            setClientWsdlProperties(factory.getClientFactoryBean(), dswContext, sd, false);
+            setClientWsdlProperties(factory.getClientFactoryBean(), bundleContext, sd, false);
 
             intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd);
 
@@ -87,37 +90,35 @@ public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
         return null;
     }
 
-    public ExportResult createServer(ServiceReference<?> sref,
-                                     BundleContext dswContext,
-                                     BundleContext callingContext,
+    public Endpoint createServer(ServiceReference<?> sref,
                                      Map<String, Object> sd,
-                                     Class<?> iClass,
-                                     Object serviceBean) throws IntentUnsatisfiedException {
-        try {
-            String address = getPojoAddress(sd, iClass);
-            ServerFactoryBean factory = createServerFactoryBean(sd, iClass);
-            factory.setDataBinding(getDataBinding(sd, iClass));
-            String contextRoot = getServletContextRoot(sd);
-            Bus bus = createBus(sref, 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);
-
-            String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
+                                     String exportedInterface) throws IntentUnsatisfiedException {
+        BundleContext callingContext = sref.getBundle().getBundleContext();
+        Object serviceBean = callingContext.getService(sref);
+        Class<?> iClass = ClassUtils.getInterfaceClass(serviceBean, exportedInterface);
+        String address = getPojoAddress(sd, iClass);
+        ServerFactoryBean factory = createServerFactoryBean(sd, iClass);
+        factory.setDataBinding(getDataBinding(sd, iClass));
+        String contextRoot = getServletContextRoot(sd);
+
+        Bus bus = createBus(sref, 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);
+
+        String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
 
             // The properties for the EndpointDescription
-            Map<String, Object> endpointProps = createEndpointProps(sd, iClass,
+        Map<String, Object> endpointProps = createEndpointProps(sd, iClass,
                                                                     new String[]{Constants.WS_CONFIG_TYPE},
                                                                     completeEndpointAddress, intents);
 
-            return createServerFromFactory(factory, endpointProps);
-        } catch (RuntimeException re) {
-            return new ExportResult(sd, re);
-        }
+        return createServerFromFactory(factory, endpointProps);
     }
 
     private String getPojoAddress(Map<String, Object> sd, Class<?> iClass) {

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServerWrapper.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServerWrapper.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServerWrapper.java
index 1c85a4e..67bcc63 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServerWrapper.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServerWrapper.java
@@ -18,27 +18,32 @@
  */
 package org.apache.cxf.dosgi.dsw.handlers;
 
-import java.io.Closeable;
 import java.io.IOException;
 
+import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.apache.cxf.endpoint.Server;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
 
-public class ServerWrapper implements Closeable {
+public class ServerWrapper implements Endpoint {
+    private EndpointDescription desc;
     private Server server;
 
-    public ServerWrapper(Server server) {
+    public ServerWrapper(EndpointDescription desc, Server server) {
+        this.desc = desc;
         this.server = server;
     }
     
     public Server getServer() {
-        return server;
+        return this.server;
     }
 
     @Override
     public void close() throws IOException {
-        server.stop();
-        server.destroy();
+        this.server.destroy();
+    }
+
+    @Override
+    public EndpointDescription description() {
+        return this.desc;
     }
-    
-    
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/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 2c9e34f..3c5e80e 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
@@ -29,8 +29,9 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.api.ExportResult;
+import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
+import org.apache.cxf.dosgi.dsw.util.ClassUtils;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
@@ -55,8 +56,6 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
     }
 
     public Object createProxy(ServiceReference<?> serviceReference,
-                              BundleContext dswContext,
-                              BundleContext callingContext,
                               Class<?> iClass,
                               EndpointDescription endpoint) {
         String wsdlAddressProp = getWsdlAddress(endpoint, iClass);
@@ -101,17 +100,17 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
         return Service.create(wsdlAddress, serviceQname);
     }
 
-    public ExportResult createServer(ServiceReference<?> sref,
-                               BundleContext dswContext,
-                               BundleContext callingContext,
+    public Endpoint createServer(ServiceReference<?> sref,
                                Map<String, Object> sd,
-                               Class<?> iClass,
-                               Object serviceBean) {
+                               String exportedInterface) {
+        BundleContext callingContext = sref.getBundle().getBundleContext();
+        Object serviceBean = callingContext.getService(sref);
+        Class<?> iClass = ClassUtils.getInterfaceClass(serviceBean, exportedInterface);
         String location = OsgiUtils.getProperty(sd, Constants.WSDL_LOCATION);
         if (location == null) {
             throw new RuntimeException("WSDL location property is unavailable");
         }
-        URL wsdlURL = dswContext.getBundle().getResource(location);
+        URL wsdlURL = callingContext.getBundle().getResource(location);
         if (wsdlURL == null) {
             throw new RuntimeException("WSDL resource at " + location + " is unavailable");
         }
@@ -132,7 +131,7 @@ public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeH
         factory.setServiceClass(iClass);
         factory.setAddress(address != null ? address : "/");
         factory.getServiceFactory().setDataBinding(databinding);
-        factory.setServiceBean(serviceBean);
+        factory.setServiceBean(callingContext.getService(sref));
 
         addWsInterceptorsFeaturesProps(factory, callingContext, sd);
 

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java
index c6c4ee0..df62627 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactory.java
@@ -23,10 +23,9 @@ import java.security.PrivilegedAction;
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.cxf.dosgi.dsw.api.ConfigurationTypeHandler;
+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.service.remoteserviceadmin.EndpointDescription;
@@ -38,19 +37,15 @@ public class ClientServiceFactory implements ServiceFactory {
 
     private static final Logger LOG = LoggerFactory.getLogger(ClientServiceFactory.class);
 
-    private BundleContext dswContext;
-    private Class<?> iClass;
     private EndpointDescription endpoint;
-    private ConfigurationTypeHandler handler;
+    private DistributionProvider handler;
     private ImportRegistrationImpl importRegistration;
 
     private boolean closeable;
     private int serviceCounter;
 
-    public ClientServiceFactory(BundleContext dswContext, Class<?> iClass, EndpointDescription endpoint,
-                                ConfigurationTypeHandler handler, ImportRegistrationImpl ir) {
-        this.dswContext = dswContext;
-        this.iClass = iClass;
+    public ClientServiceFactory(EndpointDescription endpoint,
+                                DistributionProvider handler, ImportRegistrationImpl ir) {
         this.endpoint = endpoint;
         this.handler = handler;
         this.importRegistration = ir;
@@ -61,10 +56,10 @@ public class ClientServiceFactory implements ServiceFactory {
         String interfaceName = interfaces == null || interfaces.isEmpty() ? null : interfaces.get(0);
         LOG.debug("getService() from serviceFactory for {}", interfaceName);
         try {
+            final Class<?> iClass = requestingBundle.loadClass(interfaceName);
             Object proxy = AccessController.doPrivileged(new PrivilegedAction<Object>() {
                 public Object run() {
-                    return handler.createProxy(sreg.getReference(), dswContext,
-                            requestingBundle.getBundleContext(), iClass, endpoint);
+                    return handler.createProxy(sreg.getReference(), iClass, endpoint);
                 }
             });
 

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ConfigTypeHandlerFinder.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ConfigTypeHandlerFinder.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ConfigTypeHandlerFinder.java
index 322bc1c..11e9514 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ConfigTypeHandlerFinder.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ConfigTypeHandlerFinder.java
@@ -21,15 +21,15 @@ package org.apache.cxf.dosgi.dsw.service;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.cxf.dosgi.dsw.api.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 
 public interface ConfigTypeHandlerFinder {
 
-    ConfigurationTypeHandler getHandler(BundleContext dswBC, Map<String, Object> serviceProperties);
+    DistributionProvider getHandler(BundleContext dswBC, Map<String, Object> serviceProperties);
 
-    ConfigurationTypeHandler getHandler(BundleContext dswBC, EndpointDescription endpoint);
+    DistributionProvider getHandler(BundleContext dswBC, EndpointDescription endpoint);
 
     List<String> getSupportedConfigurationTypes();
 

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
index d6e5774..d80bd40 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ExportRegistrationImpl.java
@@ -24,6 +24,7 @@ import java.util.Arrays;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.ExportReference;
@@ -62,15 +63,13 @@ public class ExportRegistrationImpl implements ExportRegistration {
     }
 
     // create a new (parent) instance which was exported successfully with the given server
-    public ExportRegistrationImpl(ServiceReference sref, EndpointDescription endpoint,
-            RemoteServiceAdminCore rsaCore, Closeable server) {
-        this(null, rsaCore, new ExportReferenceImpl(sref, endpoint), server, null);
+    public ExportRegistrationImpl(ServiceReference sref, Endpoint endpoint, RemoteServiceAdminCore rsaCore) {
+        this(null, rsaCore, new ExportReferenceImpl(sref, endpoint.description()), endpoint, null);
     }
 
     // create a new (parent) instance which failed to be exported with the given exception
-    public ExportRegistrationImpl(ServiceReference sref, EndpointDescription endpoint,
-            RemoteServiceAdminCore rsaCore, Throwable exception) {
-        this(null, rsaCore, new ExportReferenceImpl(sref, endpoint), null, exception);
+    public ExportRegistrationImpl(RemoteServiceAdminCore rsaCore, Throwable exception) {
+        this(null, rsaCore, null, null, exception);
     }
 
     private void ensureParent() {
@@ -80,6 +79,9 @@ public class ExportRegistrationImpl implements ExportRegistration {
     }
 
     public ExportReference getExportReference() {
+        if (exportReference == null) {
+            throw new IllegalStateException(getException());
+        }
         return closed ? null : exportReference;
     }
 

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
index 2007ec2..d561079 100644
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
+++ b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
@@ -32,9 +32,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.cxf.dosgi.dsw.api.ConfigurationTypeHandler;
-import org.apache.cxf.dosgi.dsw.api.ExportResult;
-import org.apache.cxf.dosgi.dsw.util.ClassUtils;
+import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
+import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.util.Utils;
 import org.osgi.framework.Bundle;
@@ -158,43 +157,28 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
     private List<ExportRegistration> exportInterfaces(List<String> interfaces,
             ServiceReference<?> serviceReference, Map<String, Object> serviceProperties) {
         LOG.info("interfaces selected for export: " + interfaces);
-        ConfigurationTypeHandler handler;
+        DistributionProvider handler;
         try {
-            handler = findHandler(serviceProperties);
+            handler = configTypeHandlerFinder.getHandler(bctx, serviceProperties);
         } catch (RuntimeException e) {
             LOG.error(e.getMessage(), e);
             return Collections.emptyList();
         }
         List<ExportRegistration> exportRegs = new ArrayList<ExportRegistration>(1);
-        Object service = bctx.getService(serviceReference);
-        Bundle bundle = serviceReference.getBundle();
-
-        // if service has been unregistered in the meantime
-        if (service == null || bundle == null) {
-            LOG.info("service has been unregistered, aborting export");
-            return exportRegs;
-        }
-
         for (String iface : interfaces) {
-            LOG.info("creating server for interface " + iface);
-            // this is an extra sanity check, but do we really need it now?
-            Class<?> interfaceClass = ClassUtils.getInterfaceClass(service, iface);
-            if (interfaceClass != null) {
-                ExportResult exportResult = handler.createServer(serviceReference, bctx, bundle.getBundleContext(),
-                    serviceProperties, interfaceClass, service);
-                EndpointDescription endpoint = new EndpointDescription(exportResult.getEndpointProps());
-                ExportRegistrationImpl exportRegistration;
-                if (exportResult.getException() == null) {
-                    LOG.info("created server for interface " + iface);
-                    exportRegistration = new ExportRegistrationImpl(serviceReference, endpoint, this,
-                            exportResult.getServer());
-                } else {
-                    LOG.error("failed to create server for interface " + iface, exportResult.getException());
-                    exportRegistration = new ExportRegistrationImpl(serviceReference, endpoint, this,
-                            exportResult.getException());
-                }
-                exportRegs.add(exportRegistration);
+            ExportRegistrationImpl exportRegistration;
+            try {
+                LOG.info("creating server for interface " + iface);
+                Endpoint endpoint = handler.createServer(serviceReference, serviceProperties, iface);
+                exportRegistration = new ExportRegistrationImpl(serviceReference, endpoint, this);
+                LOG.info("created server for interface " + iface);
+            } catch (Exception e) {
+                LOG.debug("failed to create server for interface " + iface, e);
+                serviceProperties.put(RemoteConstants.ENDPOINT_ID, "failed");
+                serviceProperties.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "none");
+                exportRegistration = new ExportRegistrationImpl(this, e);
             }
+            exportRegs.add(exportRegistration);
         }
         return exportRegs;
     }
@@ -334,65 +318,64 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
                 return ir;
             }
 
-            ConfigurationTypeHandler handler = findHandler(endpoint);
+            DistributionProvider handler = configTypeHandlerFinder.getHandler(bctx, endpoint);
 
             // TODO: somehow select the interfaces that should be imported ---> job of the TopologyManager?
             List<String> matchingInterfaces = endpoint.getInterfaces();
+            
+            if (handler == null) {
+                LOG.info("No matching handler can be found for remote endpoint {}.", endpoint.getId());
+                return null;
+            }
+            if (matchingInterfaces.size() == 0) {
+                LOG.info("No matching interfaces found for remote endpoint {}.", endpoint.getId());
+                return null;
+            }
+            if (matchingInterfaces.size() > 1) {
+                LOG.info("More than one interface {} found for remote endpoint {}. This is not supported.", 
+                         endpoint.getInterfaces(),
+                         endpoint.getId());
+                return null;
+            }
 
-            LOG.info("Matching Interfaces for import: " + matchingInterfaces);
-
-            if (handler != null && matchingInterfaces.size() == 1) {
-                LOG.info("Proxifying interface: " + matchingInterfaces.get(0));
-
-                ImportRegistrationImpl imReg = new ImportRegistrationImpl(endpoint, this);
+            LOG.info("Importing service {} with interfaces {} using handler {}.", 
+                     endpoint.getId(), endpoint.getInterfaces(), handler.getClass());
 
-                proxifyMatchingInterface(matchingInterfaces.get(0), imReg, handler, bctx);
-                if (imRegs == null) {
-                    imRegs = new ArrayList<ImportRegistrationImpl>();
-                    importedServices.put(endpoint, imRegs);
-                }
-                imRegs.add(imReg);
-                eventProducer.publishNotification(imReg);
-                return imReg;
+            ImportRegistrationImpl imReg = exposeServiceFactory(matchingInterfaces.get(0), endpoint, handler);
+            if (imRegs == null) {
+                imRegs = new ArrayList<ImportRegistrationImpl>();
+                importedServices.put(endpoint, imRegs);
             }
-            return null;
+            imRegs.add(imReg);
+            eventProducer.publishNotification(imReg);
+            return imReg;
         }
     }
 
-    protected void proxifyMatchingInterface(String interfaceName, ImportRegistrationImpl imReg,
-                                            ConfigurationTypeHandler handler, BundleContext requestingContext) {
+    protected ImportRegistrationImpl exposeServiceFactory(String interfaceName,
+                                            EndpointDescription epd,
+                                            DistributionProvider handler) {
+        ImportRegistrationImpl imReg = new ImportRegistrationImpl(epd, this);
         try {
-            // MARC: relies on dynamic imports?
-            Class<?> iClass = bctx.getBundle().loadClass(interfaceName);
-            if (iClass == null) {
-                throw new ClassNotFoundException("Cannot load interface class");
-            }
-
-            BundleContext actualContext = bctx;
-            Class<?> actualClass = requestingContext.getBundle().loadClass(interfaceName);
-            if (actualClass != iClass) {
-                LOG.info("Class " + interfaceName + " loaded by DSW's bundle context is not "
-                             + "equal to the one loaded by the requesting bundle context, "
-                             + "DSW will use the requesting bundle context to register a proxy service");
-                iClass = actualClass;
-                actualContext = requestingContext;
-            }
-
+            // FIXME This should not be done here but without it the service factory
+            // does not seem to be picked up by the consumers
+            bctx.getBundle().loadClass(interfaceName);
+            
             EndpointDescription endpoint = imReg.getImportedEndpointDescription();
-            /* TODO: add additional local params... */
             Dictionary<String, Object> serviceProps = new Hashtable<String, Object>(endpoint.getProperties());
             serviceProps.put(RemoteConstants.SERVICE_IMPORTED, true);
             serviceProps.remove(RemoteConstants.SERVICE_EXPORTED_INTERFACES);
 
-            ClientServiceFactory csf = new ClientServiceFactory(actualContext, iClass, endpoint, handler, imReg);
+            ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, imReg);
             imReg.setClientServiceFactory(csf);
-            ServiceRegistration<?> proxyReg = actualContext.registerService(interfaceName, csf, serviceProps);
-            imReg.setImportedServiceRegistration(proxyReg);
+            ServiceRegistration<?> csfReg = bctx.registerService(interfaceName, csf, serviceProps);
+            imReg.setImportedServiceRegistration(csfReg);
         } catch (Exception ex) {
             // Only logging at debug level as this might be written to the log at the TopologyManager
             LOG.debug("Can not proxy service with interface " + interfaceName + ": " + ex.getMessage(), ex);
             imReg.setException(ex);
         }
+        return imReg;
     }
 
     /**
@@ -474,9 +457,12 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
             List<ExportRegistration> bundleRegs = new ArrayList<ExportRegistration>();
             for (Collection<ExportRegistration> regs : exportedServices.values()) {
                 if (!regs.isEmpty()) {
-                    Bundle regBundle = regs.iterator().next().getExportReference().getExportedService().getBundle();
-                    if (exportingBundle.equals(regBundle)) {
-                        bundleRegs.addAll(regs);
+                    ExportRegistration exportRegistration = regs.iterator().next();
+                    if (exportRegistration.getException() == null) {
+                        Bundle regBundle = exportRegistration.getExportReference().getExportedService().getBundle();
+                        if (exportingBundle.equals(regBundle)) {
+                            bundleRegs.addAll(regs);
+                        }
                     }
                 }
             }
@@ -503,17 +489,4 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
         removeImportRegistrations();
         bctx.removeServiceListener(exportedServiceListener);
     }
-    
-    private ConfigurationTypeHandler findHandler(EndpointDescription endpoint) {
-        try {
-            return configTypeHandlerFinder.getHandler(bctx, endpoint);
-        } catch (RuntimeException e) {
-            LOG.error("No handler found: " + e.getMessage(), e);
-            return null;
-        }
-    }
-
-    private ConfigurationTypeHandler findHandler(Map<String, Object> serviceProperties) {
-        return configTypeHandlerFinder.getHandler(bctx, serviceProperties);
-    }
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java
index 37c018a..270c7fa 100644
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java
+++ b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/DecorationParserTest.java
@@ -18,9 +18,12 @@
  */
 package org.apache.cxf.dosgi.dsw.decorator;
 
+import java.io.IOException;
 import java.net.URL;
 import java.util.List;
 
+import javax.xml.bind.JAXBException;
+
 import org.apache.cxf.xmlns.service_decoration._1_0.AddPropertyType;
 import org.apache.cxf.xmlns.service_decoration._1_0.MatchPropertyType;
 import org.apache.cxf.xmlns.service_decoration._1_0.MatchType;
@@ -33,7 +36,7 @@ import static org.junit.Assert.assertEquals;
 public class DecorationParserTest {
 
     @Test
-    public void testGetDecoratorForSD() {
+    public void testGetDecoratorForSD() throws JAXBException, IOException {
         URL resource = getClass().getResource("/test-resources/sd.xml");
         List<ServiceDecorationType> elements = new DecorationParser().getDecorations(resource);
         assertEquals(1, elements.size());
@@ -53,7 +56,7 @@ public class DecorationParserTest {
     }
 
     @Test
-    public void testGetDecorationForNull() {
+    public void testGetDecorationForNull() throws JAXBException, IOException {
         List<ServiceDecorationType> elements = new DecorationParser().getDecorations(null);
         Assert.assertEquals(0, elements.size());
     }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRuleTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRuleTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRuleTest.java
index 8b45d28..c66642b 100644
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRuleTest.java
+++ b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/InterfaceRuleTest.java
@@ -29,6 +29,7 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 
+@SuppressWarnings("rawtypes")
 public class InterfaceRuleTest extends TestCase {
 
     public void testDUMMY() {

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
index 5c59a55..400d793 100644
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
+++ b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/decorator/ServiceDecoratorImplTest.java
@@ -173,6 +173,7 @@ public class ServiceDecoratorImplTest extends TestCase {
         Bundle b = EasyMock.createMock(Bundle.class);
         EasyMock.expect(b.findEntries("OSGI-INF/remote-service", "*.xml", false)).andReturn(
             Collections.enumeration(Arrays.asList(resources))).anyTimes();
+        EasyMock.expect(b.getSymbolicName()).andReturn("bundlename");
         EasyMock.replay(b);
         return b;
     }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
index 7d07227..bdbb93d 100644
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
+++ b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ClientServiceFactoryTest.java
@@ -23,7 +23,7 @@ import java.util.Map;
 
 import junit.framework.TestCase;
 
-import org.apache.cxf.dosgi.dsw.api.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
 import org.apache.cxf.dosgi.dsw.service.ClientServiceFactory;
 import org.apache.cxf.dosgi.dsw.service.ImportRegistrationImpl;
 import org.easymock.EasyMock;
@@ -38,35 +38,39 @@ import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
 public class ClientServiceFactoryTest extends TestCase {
 
-    @SuppressWarnings("rawtypes")
-    public void testGetService() {
+    @SuppressWarnings({
+     "rawtypes", "unchecked"
+    })
+    public void testGetService() throws ClassNotFoundException {
         Object myTestProxyObject = new Object();
 
-        IMocksControl control = EasyMock.createNiceControl();
-        BundleContext dswContext = control.createMock(BundleContext.class);
+        IMocksControl control = EasyMock.createControl();
         Map<String, Object> map = new HashMap<String, Object>();
         map.put(RemoteConstants.ENDPOINT_ID, "http://google.de");
         map.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myGreatConfiguration");
-        map.put(Constants.OBJECTCLASS, new String[]{"my.class"});
+        map.put(Constants.OBJECTCLASS, new String[]{String.class.getName()});
 
         EndpointDescription endpoint = new EndpointDescription(map);
-        ConfigurationTypeHandler handler = control.createMock(ConfigurationTypeHandler.class);
+        
 
         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);
 
-        ServiceReference sr = control.createMock(ServiceReference.class);
+        ServiceReference sref = control.createMock(ServiceReference.class);
+        EasyMock.expect(sref.getBundle()).andReturn(requestingBundle);
         ServiceRegistration sreg = control.createMock(ServiceRegistration.class);
-        EasyMock.expect(sreg.getReference()).andReturn(sr);
+        EasyMock.expect(sreg.getReference()).andReturn(sref);
 
-        handler.createProxy(sr, dswContext, requestingContext, String.class, endpoint);
+        DistributionProvider handler = control.createMock(DistributionProvider.class);
+        handler.createProxy(sref, String.class, endpoint);
         EasyMock.expectLastCall().andReturn(myTestProxyObject);
         control.replay();
 
-        ClientServiceFactory csf = new ClientServiceFactory(dswContext, String.class, endpoint, handler, iri);
+        ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, iri);
         assertSame(myTestProxyObject, csf.getService(requestingBundle, sreg));
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/b5f02ff5/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
index 1508277..c96874e 100644
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
+++ b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
@@ -22,13 +22,14 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.api.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
 import org.apache.cxf.dosgi.dsw.qos.DefaultIntentMapFactory;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
 import org.apache.cxf.dosgi.dsw.qos.IntentMap;
 import org.apache.cxf.dosgi.dsw.service.ConfigTypeHandlerFinder;
 import org.easymock.EasyMock;
+import org.junit.Assert;
 import org.junit.Test;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
@@ -39,54 +40,55 @@ public class ConfigTypeHandlerFactoryTest {
 
     @Test
     public void testGetDefaultHandlerNoIntents() {
-        ConfigurationTypeHandler handler = getHandlerWith(null, null);
+        DistributionProvider handler = getHandlerWith(null, null);
         assertTrue(handler instanceof PojoConfigurationTypeHandler);
     }
 
     @Test
     public void testGetJaxrsHandlerNoIntents() {
-        ConfigurationTypeHandler handler = getHandlerWith(Constants.RS_CONFIG_TYPE, null);
+        DistributionProvider handler = getHandlerWith(Constants.RS_CONFIG_TYPE, null);
         assertTrue(handler instanceof JaxRSPojoConfigurationTypeHandler);
     }
 
     @Test
     public void testGetJaxrsHandlerHttpIntents() {
-        ConfigurationTypeHandler handler = getHandlerWith(Constants.RS_CONFIG_TYPE, "HTTP");
+        DistributionProvider handler = getHandlerWith(Constants.RS_CONFIG_TYPE, "HTTP");
         assertTrue(handler instanceof JaxRSPojoConfigurationTypeHandler);
     }
 
     @Test
     public void testJaxrsPropertyIgnored() {
-        ConfigurationTypeHandler handler = getHandlerWith(Constants.RS_CONFIG_TYPE, "SOAP HTTP");
+        DistributionProvider handler = getHandlerWith(Constants.RS_CONFIG_TYPE, "SOAP HTTP");
         assertTrue(handler instanceof PojoConfigurationTypeHandler);
         assertTrue(!(handler instanceof JaxRSPojoConfigurationTypeHandler));
     }
 
     @Test
     public void testJaxrsPropertyIgnored2() {
-        ConfigurationTypeHandler handler = getHandlerWith2(Constants.RS_CONFIG_TYPE, new String[] {"HTTP", "SOAP"});
+        DistributionProvider handler = getHandlerWith2(Constants.RS_CONFIG_TYPE, new String[] {"HTTP", "SOAP"});
         assertTrue(handler instanceof PojoConfigurationTypeHandler);
         assertTrue(!(handler instanceof JaxRSPojoConfigurationTypeHandler));
     }
 
     @Test
     public void testGetPojoHandler() {
-        ConfigurationTypeHandler handler = getHandlerWith(Constants.WS_CONFIG_TYPE, null);
+        DistributionProvider handler = getHandlerWith(Constants.WS_CONFIG_TYPE, null);
         assertTrue(handler instanceof PojoConfigurationTypeHandler);
     }
 
     @Test
     public void testGetWSDLHandler() {
-        ConfigurationTypeHandler handler = getHandlerWith(Constants.WSDL_CONFIG_TYPE, null);
+        DistributionProvider handler = getHandlerWith(Constants.WSDL_CONFIG_TYPE, null);
         assertTrue(handler instanceof WsdlConfigurationTypeHandler);
     }
 
-    @Test(expected = RuntimeException.class)
+    @Test
     public void testUnsupportedConfiguration() {
-        getHandlerWith("notSupportedConfig", null);
+        DistributionProvider handler = getHandlerWith("notSupportedConfig", null);
+        Assert.assertNull(handler);
     }
 
-    private ConfigurationTypeHandler getHandlerWith(String configType, String intents) {
+    private DistributionProvider getHandlerWith(String configType, String intents) {
         BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.replay(bc);
         Map<String, Object> serviceProps = new HashMap<String, Object>();
@@ -99,7 +101,7 @@ public class ConfigTypeHandlerFactoryTest {
         return f.getHandler(bc, serviceProps);
     }
 
-    private ConfigurationTypeHandler getHandlerWith2(String configType, String[] intents) {
+    private DistributionProvider getHandlerWith2(String configType, String[] 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/b5f02ff5/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 2c97b86..69f194d 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
@@ -18,7 +18,6 @@
  */
 package org.apache.cxf.dosgi.dsw.handlers;
 
-import java.io.Closeable;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
@@ -29,16 +28,13 @@ import javax.xml.namespace.QName;
 import junit.framework.TestCase;
 
 import org.apache.cxf.dosgi.dsw.Constants;
-import org.apache.cxf.dosgi.dsw.api.ExportResult;
+import org.apache.cxf.dosgi.dsw.api.Endpoint;
 import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoService;
-import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoServiceImpl;
 import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoService;
-import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoServiceImpl;
 import org.apache.cxf.dosgi.dsw.qos.IntentManager;
 import org.apache.cxf.dosgi.dsw.qos.IntentManagerImpl;
 import org.apache.cxf.dosgi.dsw.qos.IntentMap;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.Feature;
@@ -53,11 +49,15 @@ 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.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.RemoteConstants;
 
+@SuppressWarnings({
+    "unchecked", "rawtypes"
+   })
 public class PojoConfigurationTypeHandlerTest extends TestCase {
 
     public void testGetPojoAddressEndpointURI() {
@@ -110,9 +110,13 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
     public void testCreateProxy() {
         IMocksControl c = EasyMock.createNiceControl();
         BundleContext bc1 = c.createMock(BundleContext.class);
-        BundleContext bc2 = c.createMock(BundleContext.class);
 
-        ServiceReference sref = c.createMock(ServiceReference.class);
+        
+        ServiceReference<?> sref = c.createMock(ServiceReference.class);
+        Bundle requestingBundle = c.createMock(Bundle.class);
+        BundleContext requestingContext = c.createMock(BundleContext.class);
+        EasyMock.expect(requestingBundle.getBundleContext()).andReturn(requestingContext);
+        EasyMock.expect(sref.getBundle()).andReturn(requestingBundle);
 
         final ClientProxyFactoryBean cpfb = c.createMock(ClientProxyFactoryBean.class);
         ReflectionServiceFactoryBean sf = c.createMock(ReflectionServiceFactoryBean.class);
@@ -148,13 +152,13 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
         EasyMock.expectLastCall().atLeastOnce();
 
         c.replay();
-        Object proxy = p.createProxy(sref, bc1, bc2, CharSequence.class, endpoint);
+        Object proxy = p.createProxy(sref, CharSequence.class, endpoint);
         assertNotNull(proxy);
         assertTrue("Proxy is not of the requested type! ", proxy instanceof CharSequence);
         c.verify();
     }
 
-    public void testCreateServerWithAddressProperty() {
+    public void testCreateServerWithAddressProperty() throws Exception {
         BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
         EasyMock.replay(dswContext);
 
@@ -176,18 +180,23 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
                 return sfb;
             }
         };
-
-        ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
-        BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
-        EasyMock.replay(sr);
-        EasyMock.replay(callingContext);
-
+        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);
+        
         Map<String, Object> props = new HashMap<String, Object>();
         props.put(Constants.WS_ADDRESS_PROPERTY, "http://alternate_host:80/myString");
 
-        ExportResult exportResult = p.createServer(sr, dswContext, callingContext, props, String.class, myService);
-
-        Map<String, Object> edProps = exportResult.getEndpointProps();
+        Endpoint exportResult = p.createServer(sref, props, String.class.getName());
+        Map<String, Object> edProps = exportResult.description().getProperties();
 
         assertNotNull(edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
         assertEquals(1, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS)).length);
@@ -226,23 +235,29 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
                                                                                 intentManager,
                                                                                 dummyHttpServiceManager()) {
             @Override
-            protected ExportResult createServerFromFactory(ServerFactoryBean factory,
+            protected Endpoint createServerFromFactory(ServerFactoryBean factory,
                                                            Map<String, Object> endpointProps) {
-                return new ExportResult(endpointProps, (Closeable) null);
+                EndpointDescription epd = new EndpointDescription(endpointProps);
+                return new ServerWrapper(epd, null);
             }
         };
-
+        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);
 
-        Runnable myService = EasyMock.createMock(Runnable.class);
-        EasyMock.replay(myService);
-        ExportResult result = handler.createServer(sref, null, null, properties, Runnable.class, myService);
-        if (result.getException() != null) {
-            throw result.getException();
-        }
 
-        Map<String, Object> props = result.getEndpointProps();
+        Endpoint result = handler.createServer(sref, properties, Runnable.class.getName());
+        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")));
@@ -261,22 +276,25 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
                                                                                 intentManager,
                                                                                 dummyHttpServiceManager()) {
             @Override
-            protected ExportResult createServerFromFactory(ServerFactoryBean factory,
+            protected Endpoint createServerFromFactory(ServerFactoryBean factory,
                                                            Map<String, Object> endpointProps) {
                 throw new TestException();
             }
         };
 
-        ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
+        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);
-        ExportResult result = handler.createServer(sref, null, null, props, Runnable.class, myService);
-        Assert.assertTrue(result.getException() instanceof TestException);
-        Assert.assertEquals(props, result.getEndpointProps());
+        try {
+            handler.createServer(sref, props, Runnable.class.getName());
+            fail("Expected TestException");
+        } catch (TestException e) {
+            // Expected
+        }
     }
 
     private ServerFactoryBean createMockServerFactoryBean() {
@@ -366,18 +384,16 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
                                                                                 intentManager,
                                                                                 dummyHttpServiceManager());
 
-        Object serviceBean = new MyJaxWsEchoServiceImpl();
-        ServiceReference sref = c.createMock(ServiceReference.class);
+        ServiceReference<?> sref = c.createMock(ServiceReference.class);
 
         Map<String, Object> sd = new HashMap<String, Object>();
         sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere");
 
         c.replay();
-        ExportResult exportResult = handler.createServer(sref, dswBC, null, sd, MyJaxWsEchoService.class, serviceBean);
+        ServerWrapper serverWrapper = (ServerWrapper)handler.createServer(sref, sd, MyJaxWsEchoService.class.getName());
         c.verify();
 
-        ServerWrapper serverWrapper = (ServerWrapper)exportResult.getServer();
-        Endpoint ep = serverWrapper.getServer().getEndpoint();
+        org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
         QName bindingName = ep.getEndpointInfo().getBinding().getName();
         Assert.assertEquals(JaxWsEndpointImpl.class, ep.getClass());
         Assert.assertEquals(new QName("http://jaxws.handlers.dsw.dosgi.cxf.apache.org/",
@@ -391,17 +407,16 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
         IntentManager intentManager = new DummyIntentManager();
         PojoConfigurationTypeHandler handler
             = new PojoConfigurationTypeHandler(dswBC, intentManager, dummyHttpServiceManager());
-        Object serviceBean = new MySimpleEchoServiceImpl();
-        ServiceReference sref = c.createMock(ServiceReference.class);
+        ServiceReference<?> sref = c.createMock(ServiceReference.class);
         Map<String, Object> sd = new HashMap<String, Object>();
         sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere_else");
 
         c.replay();
-        ExportResult exportResult = handler.createServer(sref, dswBC, null, sd, MySimpleEchoService.class, serviceBean);
-        ServerWrapper serverWrapper = (ServerWrapper)exportResult.getServer();
+        ServerWrapper serverWrapper = (ServerWrapper)handler.createServer(sref, sd, 
+                                                                          MySimpleEchoService.class.getName());
         c.verify();
 
-        Endpoint ep = serverWrapper.getServer().getEndpoint();
+        org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
         QName bindingName = ep.getEndpointInfo().getBinding().getName();
         Assert.assertEquals(EndpointImpl.class, ep.getClass());
         Assert.assertEquals(new QName("http://simple.handlers.dsw.dosgi.cxf.apache.org/",


Mime
View raw message