aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [03/50] [abbrv] aries-rsa git commit: [DOSGI-229] Use separate bundles for API and RSA impl. Remove dynamic import
Date Fri, 11 Mar 2016 19:43:02 GMT
http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
deleted file mode 100644
index 2b896db..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImpl.java
+++ /dev/null
@@ -1,230 +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.service;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.ImportReference;
-import org.osgi.service.remoteserviceadmin.ImportRegistration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@SuppressWarnings("rawtypes")
-public class ImportRegistrationImpl implements ImportRegistration, ImportReference {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ImportRegistrationImpl.class);
-
-    private volatile Throwable exception;
-    private volatile ServiceRegistration importedService; // used only in parent
-    private EndpointDescription endpoint;
-    private volatile ClientServiceFactory clientServiceFactory;
-    private RemoteServiceAdminCore rsaCore;
-    private boolean closed;
-    private boolean detached; // used only in parent
-
-    private ImportRegistrationImpl parent;
-    private List<ImportRegistrationImpl> children; // used only in parent
-
-    public ImportRegistrationImpl(Throwable ex) {
-        exception = ex;
-        initParent();
-    }
-
-    public ImportRegistrationImpl(EndpointDescription endpoint, RemoteServiceAdminCore rsac) {
-        this.endpoint = endpoint;
-        this.rsaCore = rsac;
-        initParent();
-    }
-
-    /**
-     * Creates a clone of the given parent instance.
-     */
-    public ImportRegistrationImpl(ImportRegistrationImpl ir) {
-        // we always want a link to the parent...
-        parent = ir.getParent();
-        exception = parent.getException();
-        endpoint = parent.getImportedEndpointDescription();
-        clientServiceFactory = parent.clientServiceFactory;
-        rsaCore = parent.rsaCore;
-
-        parent.instanceAdded(this);
-    }
-
-    private void initParent() {
-        parent = this;
-        children = new ArrayList<ImportRegistrationImpl>(1);
-    }
-
-    private void ensureParent() {
-        if (parent != this) {
-            throw new IllegalStateException("this method may only be called on the parent");
-        }
-    }
-
-    /**
-     * Called on parent when a child is added.
-     *
-     * @param iri the child
-     */
-    private synchronized void instanceAdded(ImportRegistrationImpl iri) {
-        ensureParent();
-        children.add(iri);
-    }
-
-    /**
-     * Called on parent when a child is closed.
-     *
-     * @param iri the child
-     */
-    private void instanceClosed(ImportRegistrationImpl iri) {
-        ensureParent();
-        synchronized (this) {
-            children.remove(iri);
-            if (!children.isEmpty() || detached || !closed) {
-                return;
-            }
-            detached = true;
-        }
-
-        LOG.debug("really closing ImportRegistration now");
-
-        if (importedService != null) {
-            try {
-                importedService.unregister();
-            } catch (IllegalStateException ise) {
-                LOG.debug("imported service is already unregistered");
-            }
-            importedService = null;
-        }
-        if (clientServiceFactory != null) {
-            clientServiceFactory.setCloseable(true);
-        }
-    }
-
-    public void close() {
-        LOG.debug("close() called");
-
-        synchronized (this) {
-            if (isInvalid()) {
-                return;
-            }
-            closed = true;
-        }
-        rsaCore.removeImportRegistration(this);
-        parent.instanceClosed(this);
-    }
-
-    /**
-     * Closes all ImportRegistrations which share the same parent as this one.
-     */
-    public void closeAll() {
-        if (this == parent) {
-            LOG.info("closing down all child ImportRegistrations");
-
-            // we must iterate over a copy of children since close() removes the child
-            // from the list (which would cause a ConcurrentModificationException)
-            for (ImportRegistrationImpl ir : copyChildren()) {
-                ir.close();
-            }
-            this.close();
-        } else {
-            parent.closeAll();
-        }
-    }
-
-    private List<ImportRegistrationImpl> copyChildren() {
-        synchronized (this) {
-            return new ArrayList<ImportRegistrationImpl>(children);
-        }
-    }
-
-    public EndpointDescription getImportedEndpointDescription() {
-        return isInvalid() ? null : endpoint;
-    }
-
-    @Override
-    public EndpointDescription getImportedEndpoint() {
-        return getImportedEndpointDescription();
-    }
-
-    @Override
-    public ServiceReference getImportedService() {
-        return isInvalid() || parent.importedService == null ? null : parent.importedService.getReference();
-    }
-
-    @Override
-    public ImportReference getImportReference() {
-        return this;
-    }
-
-    @Override
-    public Throwable getException() {
-        return exception;
-    }
-
-    public void setException(Throwable ex) {
-        exception = ex;
-    }
-
-    private synchronized boolean isInvalid() {
-        return exception != null || closed;
-    }
-
-    /**
-     * Sets the {@link ServiceRegistration} representing the locally
-     * registered {@link ClientServiceFactory} service which provides
-     * proxies to the remote imported service. It is set only on the parent.
-     *
-     * @param sreg the ServiceRegistration
-     */
-    public void setImportedServiceRegistration(ServiceRegistration sreg) {
-        ensureParent();
-        importedService = sreg;
-    }
-
-    /**
-     * Sets the {@link ClientServiceFactory} which is the implementation
-     * of the locally registered service which provides proxies to the
-     * remote imported service. It is set only on the parent.
-     *
-     * @param csf the ClientServiceFactory
-     */
-    public void setClientServiceFactory(ClientServiceFactory csf) {
-        ensureParent();
-        clientServiceFactory = csf;
-    }
-
-    public ImportRegistrationImpl getParent() {
-        return parent;
-    }
-
-    /**
-     * Returns the imported endpoint even if this
-     * instance is closed or has an exception.
-     *
-     * @return the imported endpoint
-     */
-    public EndpointDescription getImportedEndpointAlways() {
-        return endpoint;
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/PackageFinder.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/PackageFinder.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/PackageFinder.java
deleted file mode 100644
index cc7d4f8..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/PackageFinder.java
+++ /dev/null
@@ -1,47 +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.service;
-
-import java.util.List;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Version;
-import org.osgi.framework.wiring.BundleCapability;
-import org.osgi.framework.wiring.BundleWiring;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-
-public class PackageFinder {
-    private BundleContext context;
-
-    public PackageFinder(BundleContext context) {
-        this.context = context;
-    }
-
-    public void findPackageFor(String interfaceName, EndpointDescription epd) {
-        BundleWiring wiring = context.getBundle().adapt(BundleWiring.class);
-        List<BundleCapability> caps = wiring.getCapabilities("osgi.wiring.package");
-        Version version = epd.getPackageVersion(getPackageName(interfaceName));
-    }
-    
-
-    private String getPackageName(String interfaceName) {
-        return interfaceName.substring(0, interfaceName.lastIndexOf("."));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/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
deleted file mode 100644
index 9f4e5fa..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
+++ /dev/null
@@ -1,549 +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.service;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
-import org.apache.cxf.dosgi.dsw.api.Endpoint;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.ExportReference;
-import org.osgi.service.remoteserviceadmin.ExportRegistration;
-import org.osgi.service.remoteserviceadmin.ImportReference;
-import org.osgi.service.remoteserviceadmin.ImportRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RemoteServiceAdminCore implements RemoteServiceAdmin {
-
-    private static final Logger LOG = LoggerFactory.getLogger(RemoteServiceAdminCore.class);
-
-    private final Map<Map<String, Object>, Collection<ExportRegistration>> exportedServices
-        = new LinkedHashMap<Map<String, Object>, Collection<ExportRegistration>>();
-    private final Map<EndpointDescription, Collection<ImportRegistrationImpl>> importedServices
-        = new LinkedHashMap<EndpointDescription, Collection<ImportRegistrationImpl>>();
-
-    // Is stored in exportedServices while the export is in progress as a marker
-    private final List<ExportRegistration> exportInProgress = Collections.emptyList();
-
-    private final BundleContext bctx;
-    private final EventProducer eventProducer;
-    private final ServiceListener exportedServiceListener;
-    private DistributionProvider provider;
-
-    public RemoteServiceAdminCore(BundleContext bc, DistributionProvider provider) {
-        this.bctx = bc;
-        this.eventProducer = new EventProducer(bctx);
-        this.provider = provider;
-        // listen for exported services being unregistered so we can close the export
-        this.exportedServiceListener = new ServiceListener() {
-            public void serviceChanged(ServiceEvent event) {
-                if (event.getType() == ServiceEvent.UNREGISTERING) {
-                    removeServiceExports(event.getServiceReference());
-                }
-            }
-        };
-        try {
-            String filter = "(" + RemoteConstants.SERVICE_EXPORTED_INTERFACES + "=*)";
-            bc.addServiceListener(exportedServiceListener, filter);
-        } catch (InvalidSyntaxException ise) {
-            throw new RuntimeException(ise); // can never happen
-        }
-    }
-
-    @Override
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    public List<ExportRegistration> exportService(ServiceReference serviceReference, Map additionalProperties)
-        throws IllegalArgumentException, UnsupportedOperationException {
-        Map<String, Object> serviceProperties = getProperties(serviceReference);
-        if (additionalProperties != null) {
-            overlayProperties(serviceProperties, additionalProperties);
-        }
-        Map<String, Object> key = makeKey(serviceProperties);
-
-        List<String> interfaceNames = getInterfaceNames(serviceProperties);
-
-        if (isImportedService(serviceReference)) {
-            return Collections.emptyList();
-        }
-
-        List<ExportRegistration> exportRegs = getExistingAndLock(key, interfaceNames);
-        if (exportRegs != null) {
-            return exportRegs;
-        }
-
-        try {
-            ExportRegistration exportReg = exportService(interfaceNames, serviceReference, serviceProperties);
-            exportRegs = new ArrayList<>();
-            exportRegs.add(exportReg);
-            store(key, exportRegs);
-            return exportRegs;
-        } finally {
-            unlock(key);
-        }
-    }
-
-    private void store(Map<String, Object> key, List<ExportRegistration> exportRegs) {
-        if (!exportRegs.isEmpty()) {
-            // enlist initial export registrations in global list of exportRegistrations
-            synchronized (exportedServices) {
-                exportedServices.put(key, new ArrayList<ExportRegistration>(exportRegs));
-            }
-            eventProducer.publishNotification(exportRegs);
-        }
-    }
-
-    private void unlock(Map<String, Object> key) {
-        synchronized (exportedServices) {
-            if (exportedServices.get(key) == exportInProgress) {
-                exportedServices.remove(key);
-            }
-            exportedServices.notifyAll(); // in any case, always notify waiting threads
-        }
-    }
-
-    private List<ExportRegistration> getExistingAndLock(Map<String, Object> key, List<String> interfaces) {
-        synchronized (exportedServices) {
-            // check if it is already exported...
-            Collection<ExportRegistration> existingRegs = exportedServices.get(key);
-
-            // if the export is already in progress, wait for it to be complete
-            while (existingRegs == exportInProgress) {
-                try {
-                    exportedServices.wait();
-                    existingRegs = exportedServices.get(key);
-                } catch (InterruptedException ie) {
-                    LOG.debug("interrupted while waiting for export in progress");
-                    return Collections.emptyList();
-                }
-            }
-
-            // if the export is complete, return a copy of existing export
-            if (existingRegs != null) {
-                LOG.debug("already exported this service. Returning existing exportRegs {} ", interfaces);
-                return copyExportRegistration(existingRegs);
-            }
-
-            // mark export as being in progress
-            exportedServices.put(key, exportInProgress);
-        }
-        return null;
-    }
-
-    private ExportRegistration exportService(List<String> interfaceNames,
-            ServiceReference<?> serviceReference, Map<String, Object> serviceProperties) {
-        LOG.info("interfaces selected for export: " + interfaceNames);
-        try {
-            Class<?>[] interfaces = getInterfaces(interfaceNames, serviceReference.getBundle());
-            Endpoint endpoint = provider.exportService(serviceReference, serviceProperties, interfaces);
-            return new ExportRegistrationImpl(serviceReference, endpoint, this);
-        } catch (Exception e) {
-            return new ExportRegistrationImpl(this, e);
-        }
-    }
-    
-    private Class<?>[] getInterfaces(List<String> interfaceNames, 
-                                         Bundle serviceBundle) throws ClassNotFoundException {
-        List<Class<?>> interfaces = new ArrayList<>();
-        for (String interfaceName : interfaceNames) {
-            interfaces.add(serviceBundle.loadClass(interfaceName));
-        }
-        return interfaces.toArray(new Class[]{});
-    }
-
-    /**
-     * Determines which interfaces should be exported.
-     *
-     * @param serviceProperties the exported service properties
-     * @return the interfaces to be exported
-     * @throws IllegalArgumentException if the service parameters are invalid
-     * @see RemoteServiceAdmin#exportService
-     * @see org.osgi.framework.Constants#OBJECTCLASS
-     * @see RemoteConstants#SERVICE_EXPORTED_INTERFACES
-     */
-    private List<String> getInterfaceNames(Map<String, Object> serviceProperties) {
-        String[] providedInterfaces = (String[])serviceProperties.get(org.osgi.framework.Constants.OBJECTCLASS);
-        if (providedInterfaces == null || providedInterfaces.length == 0) {
-            throw new IllegalArgumentException("service is missing the objectClass property");
-        }
-
-        String[] exportedInterfaces
-            = StringPlus.normalize(serviceProperties.get(RemoteConstants.SERVICE_EXPORTED_INTERFACES));
-        if (exportedInterfaces == null || exportedInterfaces.length == 0) {
-            throw new IllegalArgumentException("service is missing the service.exported.interfaces property");
-        }
-
-        List<String> interfaces = new ArrayList<String>(1);
-        if (exportedInterfaces.length == 1 && "*".equals(exportedInterfaces[0])) {
-            // FIXME: according to the spec, this should only return the interfaces, and not
-            // non-interface classes (which are valid OBJECTCLASS values, even if discouraged)
-            Collections.addAll(interfaces, providedInterfaces);
-        } else {
-            List<String> providedList = Arrays.asList(providedInterfaces);
-            List<String> allowedList = Arrays.asList(exportedInterfaces);
-            if (!providedList.containsAll(allowedList)) {
-                throw new IllegalArgumentException(String.format(
-                    "exported interfaces %s must be a subset of the service's registered types %s",
-                    allowedList, providedList));
-            }
-
-            Collections.addAll(interfaces, exportedInterfaces);
-        }
-        return interfaces;
-    }
-
-    /**
-     * Converts the given properties map into one that can be used as a map key itself.
-     * For example, if a value is an array, it is converted into a list so that the
-     * equals method will compare it properly.
-     *
-     * @param properties a properties map
-     * @return a map that represents the given map, but can be safely used as a map key itself
-     */
-    private Map<String, Object> makeKey(Map<String, Object> properties) {
-        // FIXME: we should also make logically equal values actually compare as equal
-        // (e.g. String+ values should be normalized)
-        Map<String, Object> converted = new HashMap<String, Object>(properties.size());
-        for (Map.Entry<String, Object> entry : properties.entrySet()) {
-            Object val = entry.getValue();
-            // convert arrays into lists so that they can be compared via equals()
-            if (val instanceof Object[]) {
-                val = Arrays.asList((Object[])val);
-            }
-            converted.put(entry.getKey(), val);
-        }
-        return converted;
-    }
-
-    private List<ExportRegistration> copyExportRegistration(Collection<ExportRegistration> regs) {
-        Set<EndpointDescription> copiedEndpoints = new HashSet<EndpointDescription>();
-
-        // create a new list with copies of the exportRegistrations
-        List<ExportRegistration> copy = new ArrayList<ExportRegistration>(regs.size());
-        for (ExportRegistration exportRegistration : regs) {
-            if (exportRegistration instanceof ExportRegistrationImpl) {
-                ExportRegistrationImpl exportRegistrationImpl = (ExportRegistrationImpl) exportRegistration;
-                EndpointDescription epd = exportRegistration.getExportReference().getExportedEndpoint();
-                // create one copy for each distinct endpoint description
-                if (!copiedEndpoints.contains(epd)) {
-                    copiedEndpoints.add(epd);
-                    copy.add(new ExportRegistrationImpl(exportRegistrationImpl));
-                }
-            }
-        }
-
-        regs.addAll(copy);
-
-        eventProducer.publishNotification(copy);
-        return copy;
-    }
-
-    private boolean isImportedService(ServiceReference<?> sref) {
-        return sref.getProperty(RemoteConstants.SERVICE_IMPORTED) != null;
-    }
-
-    @Override
-    public Collection<ExportReference> getExportedServices() {
-        synchronized (exportedServices) {
-            List<ExportReference> ers = new ArrayList<ExportReference>();
-            for (Collection<ExportRegistration> exportRegistrations : exportedServices.values()) {
-                for (ExportRegistration er : exportRegistrations) {
-                    ers.add(new ExportReferenceImpl(er.getExportReference()));
-                }
-            }
-            return Collections.unmodifiableCollection(ers);
-        }
-    }
-
-    @Override
-    public Collection<ImportReference> getImportedEndpoints() {
-        synchronized (importedServices) {
-            List<ImportReference> irs = new ArrayList<ImportReference>();
-            for (Collection<ImportRegistrationImpl> irl : importedServices.values()) {
-                for (ImportRegistrationImpl impl : irl) {
-                    irs.add(impl.getImportReference());
-                }
-            }
-            return Collections.unmodifiableCollection(irs);
-        }
-    }
-
-    /**
-     * Importing form here...
-     */
-    @Override
-    public ImportRegistration importService(EndpointDescription endpoint) {
-        LOG.debug("importService() Endpoint: {}", endpoint.getProperties());
-
-        synchronized (importedServices) {
-            Collection<ImportRegistrationImpl> imRegs = importedServices.get(endpoint);
-            if (imRegs != null && !imRegs.isEmpty()) {
-                LOG.debug("creating copy of existing import registrations");
-                ImportRegistrationImpl irParent = imRegs.iterator().next();
-                ImportRegistrationImpl ir = new ImportRegistrationImpl(irParent);
-                imRegs.add(ir);
-                eventProducer.publishNotification(ir);
-                return ir;
-            }
-
-            if (determineConfigTypesForImport(endpoint).size() == 0) {
-                LOG.info("No matching handler can be found for remote endpoint {}.", endpoint.getId());
-                return null;
-            }
-            
-            // TODO: somehow select the interfaces that should be imported ---> job of the TopologyManager?
-            List<String> matchingInterfaces = endpoint.getInterfaces();
-            
-            if (matchingInterfaces.size() == 0) {
-                LOG.info("No matching interfaces found for remote endpoint {}.", endpoint.getId());
-                return null;
-            }
-            
-            LOG.info("Importing service {} with interfaces {} using handler {}.", 
-                     endpoint.getId(), endpoint.getInterfaces(), provider.getClass());
-
-            ImportRegistrationImpl imReg = exposeServiceFactory(matchingInterfaces.get(0), endpoint, provider);
-            if (imRegs == null) {
-                imRegs = new ArrayList<ImportRegistrationImpl>();
-                importedServices.put(endpoint, imRegs);
-            }
-            imRegs.add(imReg);
-            eventProducer.publishNotification(imReg);
-            return imReg;
-        }
-    }
-    
-    private List<String> determineConfigTypesForImport(EndpointDescription endpoint) {
-        List<String> remoteConfigurationTypes = endpoint.getConfigurationTypes();
-
-        List<String> usableConfigurationTypes = new ArrayList<String>();
-        for (String ct : provider.getSupportedTypes()) {
-            if (remoteConfigurationTypes.contains(ct)) {
-                usableConfigurationTypes.add(ct);
-            }
-        }
-
-        LOG.info("Ignoring endpoint {} as it has no compatible configuration types: {}.", 
-                 endpoint.getId(), remoteConfigurationTypes);
-        return usableConfigurationTypes;
-    }
-
-    protected ImportRegistrationImpl exposeServiceFactory(String interfaceName,
-                                            EndpointDescription epd,
-                                            DistributionProvider handler) {
-        ImportRegistrationImpl imReg = new ImportRegistrationImpl(epd, this);
-        try {
-            // 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();
-            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(endpoint, handler, imReg);
-            imReg.setClientServiceFactory(csf);
-            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;
-    }
-
-    /**
-     * Removes and closes all exports for the given service.
-     * This is called when the service is unregistered.
-     *
-     * @param sref the service whose exports should be removed and closed
-     */
-    protected void removeServiceExports(ServiceReference<?> sref) {
-        List<ExportRegistration> regs = new ArrayList<ExportRegistration>(1);
-        synchronized (exportedServices) {
-            for (Iterator<Collection<ExportRegistration>> it = exportedServices.values().iterator(); it.hasNext();) {
-                Collection<ExportRegistration> value = it.next();
-                for (Iterator<ExportRegistration> it2 = value.iterator(); it2.hasNext();) {
-                    ExportRegistration er = it2.next();
-                    if (er.getExportReference().getExportedService().equals(sref)) {
-                        regs.add(er);
-                    }
-                }
-            }
-            // do this outside of iteration to avoid concurrent modification
-            for (ExportRegistration er : regs) {
-                LOG.debug("closing export for service {}", sref);
-                er.close();
-            }
-        }
-
-    }
-
-    /**
-     * Removes the provided Export Registration from the internal management structures.
-     * This is called from the ExportRegistration itself when it is closed (so should
-     * not attempt to close it again here).
-     *
-     * @param eri the export registration to remove
-     */
-    protected void removeExportRegistration(ExportRegistrationImpl eri) {
-        synchronized (exportedServices) {
-            for (Iterator<Collection<ExportRegistration>> it = exportedServices.values().iterator(); it.hasNext();) {
-                Collection<ExportRegistration> value = it.next();
-                for (Iterator<ExportRegistration> it2 = value.iterator(); it2.hasNext();) {
-                    ExportRegistration er = it2.next();
-                    if (er.equals(eri)) {
-                        eventProducer.notifyRemoval(eri);
-                        it2.remove();
-                        if (value.isEmpty()) {
-                            it.remove();
-                        }
-                        return;
-                    }
-                }
-            }
-        }
-    }
-
-    // remove all export registrations associated with the given bundle
-    protected void removeExportRegistrations(Bundle exportingBundle) {
-        List<ExportRegistration> bundleExports = getExportsForBundle(exportingBundle);
-        for (ExportRegistration export : bundleExports) {
-            export.close();
-        }
-    }
-
-    // remove all import registrations
-    protected void removeImportRegistrations() {
-        Collection<ImportRegistrationImpl> copy = new ArrayList<ImportRegistrationImpl>();
-        synchronized (importedServices) {
-            for (Collection<ImportRegistrationImpl> irs : importedServices.values()) {
-                copy.addAll(irs);
-            }
-        }
-        for (ImportRegistrationImpl ir : copy) {
-            removeImportRegistration(ir);
-        }
-    }
-
-    private List<ExportRegistration> getExportsForBundle(Bundle exportingBundle) {
-        synchronized (exportedServices) {
-            List<ExportRegistration> bundleRegs = new ArrayList<ExportRegistration>();
-            for (Collection<ExportRegistration> regs : exportedServices.values()) {
-                if (!regs.isEmpty()) {
-                    ExportRegistration exportRegistration = regs.iterator().next();
-                    if (exportRegistration.getException() == null) {
-                        Bundle regBundle = exportRegistration.getExportReference().getExportedService().getBundle();
-                        if (exportingBundle.equals(regBundle)) {
-                            bundleRegs.addAll(regs);
-                        }
-                    }
-                }
-            }
-            return bundleRegs;
-        }
-    }
-
-    protected void removeImportRegistration(ImportRegistrationImpl iri) {
-        synchronized (importedServices) {
-            LOG.debug("Removing importRegistration {}", iri);
-
-            Collection<ImportRegistrationImpl> imRegs = importedServices.get(iri.getImportedEndpointAlways());
-            if (imRegs != null && imRegs.contains(iri)) {
-                imRegs.remove(iri);
-                eventProducer.notifyRemoval(iri);
-            }
-            if (imRegs == null || imRegs.isEmpty()) {
-                importedServices.remove(iri.getImportedEndpointAlways());
-            }
-        }
-    }
-
-    public void close() {
-        removeImportRegistrations();
-        bctx.removeServiceListener(exportedServiceListener);
-    }
-
-    static void overlayProperties(Map<String, Object> serviceProperties,
-                                         Map<String, Object> additionalProperties) {
-        Map<String, String> keysLowerCase = new HashMap<String, String>();
-        for (String key : serviceProperties.keySet()) {
-            keysLowerCase.put(key.toLowerCase(), key);
-        }
-    
-        for (Map.Entry<String, Object> e : additionalProperties.entrySet()) {
-            String key = e.getKey();
-            String lowerKey = key.toLowerCase();
-            if (org.osgi.framework.Constants.SERVICE_ID.toLowerCase().equals(lowerKey)
-                || org.osgi.framework.Constants.OBJECTCLASS.toLowerCase().equals(lowerKey)) {
-                // objectClass and service.id must not be overwritten
-                LOG.info("exportService called with additional properties map that contained illegal key: "
-                          + key + ", the key is ignored");
-            } else {
-                String origKey = keysLowerCase.get(lowerKey);
-                if (origKey != null) {
-                    LOG.debug("Overwriting property [{}] with value [{}]", origKey, e.getValue());
-                } else {
-                    origKey = key;
-                    keysLowerCase.put(lowerKey, origKey);
-                }
-                serviceProperties.put(origKey, e.getValue());
-            }
-        }
-    }
-
-    /**
-     * Returns a service's properties as a map.
-     *
-     * @param serviceReference a service reference
-     * @return the service's properties as a map
-     */
-    private Map<String, Object> getProperties(ServiceReference<?> serviceReference) {
-        String[] keys = serviceReference.getPropertyKeys();
-        Map<String, Object> props = new HashMap<String, Object>(keys.length);
-        for (String key : keys) {
-            Object val = serviceReference.getProperty(key);
-            props.put(key, val);
-        }
-        return props;
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
deleted file mode 100644
index fc3a67e..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminInstance.java
+++ /dev/null
@@ -1,99 +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.service;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.EndpointPermission;
-import org.osgi.service.remoteserviceadmin.ExportReference;
-import org.osgi.service.remoteserviceadmin.ExportRegistration;
-import org.osgi.service.remoteserviceadmin.ImportReference;
-import org.osgi.service.remoteserviceadmin.ImportRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
-
-public class RemoteServiceAdminInstance implements RemoteServiceAdmin {
-
-    private final BundleContext bctx;
-    private final RemoteServiceAdminCore rsaCore;
-
-    private boolean closed;
-
-    public RemoteServiceAdminInstance(BundleContext bc, RemoteServiceAdminCore core) {
-        bctx = bc;
-        rsaCore = core;
-    }
-
-    @Override
-    @SuppressWarnings("rawtypes")
-    public List<ExportRegistration> exportService(final ServiceReference ref, final Map properties) {
-        checkPermission(new EndpointPermission("*", EndpointPermission.EXPORT));
-        return AccessController.doPrivileged(new PrivilegedAction<List<ExportRegistration>>() {
-            public List<ExportRegistration> run() {
-                return closed ? Collections.<ExportRegistration>emptyList() : rsaCore.exportService(ref, properties);
-            }
-        });
-    }
-
-    @Override
-    public Collection<ExportReference> getExportedServices() {
-        checkPermission(new EndpointPermission("*", EndpointPermission.READ));
-        return closed ? null : rsaCore.getExportedServices();
-    }
-
-    @Override
-    public Collection<ImportReference> getImportedEndpoints() {
-        checkPermission(new EndpointPermission("*", EndpointPermission.READ));
-        return closed ? null : rsaCore.getImportedEndpoints();
-    }
-
-    @Override
-    public ImportRegistration importService(final EndpointDescription endpoint) {
-        String frameworkUUID = bctx.getProperty(Constants.FRAMEWORK_UUID);
-        checkPermission(new EndpointPermission(endpoint, frameworkUUID, EndpointPermission.IMPORT));
-        return AccessController.doPrivileged(new PrivilegedAction<ImportRegistration>() {
-            public ImportRegistration run() {
-                return closed ? null : rsaCore.importService(endpoint);
-            }
-        });
-    }
-
-    public void close(boolean closeAll) {
-        closed = true;
-        rsaCore.removeExportRegistrations(bctx.getBundle());
-        if (closeAll) {
-            rsaCore.close();
-        }
-    }
-
-    private void checkPermission(EndpointPermission permission) {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-            sm.checkPermission(permission);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
deleted file mode 100644
index 968ff16..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceadminFactory.java
+++ /dev/null
@@ -1,51 +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.service;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RemoteServiceadminFactory implements ServiceFactory<RemoteServiceAdmin> {
-
-    private static final Logger LOG = LoggerFactory.getLogger(RemoteServiceadminFactory.class);
-
-    private final RemoteServiceAdminCore rsaCore;
-    private int instances;
-
-    public RemoteServiceadminFactory(RemoteServiceAdminCore rsaCore) {
-        this.rsaCore = rsaCore;
-    }
-
-    public synchronized RemoteServiceAdmin getService(Bundle b, ServiceRegistration<RemoteServiceAdmin> sreg) {
-        LOG.debug("new RemoteServiceAdmin ServiceInstance created for Bundle {}", b.getSymbolicName());
-        instances++;
-        return new RemoteServiceAdminInstance(b.getBundleContext(), rsaCore);
-    }
-
-    public synchronized void ungetService(Bundle b, ServiceRegistration<RemoteServiceAdmin> sreg,
-                                          RemoteServiceAdmin serviceObject) {
-        LOG.debug("RemoteServiceAdmin ServiceInstance removed for Bundle {}", b.getSymbolicName());
-        instances--;
-        ((RemoteServiceAdminInstance)serviceObject).close(instances == 0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/StringPlus.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/StringPlus.java b/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/StringPlus.java
deleted file mode 100644
index e449f1d..0000000
--- a/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/StringPlus.java
+++ /dev/null
@@ -1,72 +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.service;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class StringPlus {
-
-    private static final Logger LOG = LoggerFactory.getLogger(StringPlus.class);
-
-    private StringPlus() {
-        // never constructed
-    }
-
-    @SuppressWarnings("rawtypes")
-    public static String[] normalize(Object object) {
-        if (object instanceof String) {
-            String s = (String)object;
-            String[] values = s.split(",");
-            List<String> list = new ArrayList<String>();
-            for (String val : values) {
-                String actualValue = val.trim();
-                if (!actualValue.isEmpty()) {
-                    list.add(actualValue);
-                }
-            }
-            return list.toArray(new String[list.size()]);
-        }
-
-        if (object instanceof String[]) {
-            return (String[])object;
-        }
-        
-        if (object instanceof Collection) {
-            Collection col = (Collection)object;
-            List<String> ar = new ArrayList<String>(col.size());
-            for (Object o : col) {
-                if (o instanceof String) {
-                    String s = (String)o;
-                    ar.add(s);
-                } else {
-                    LOG.warn("stringPlus contained non string element in list! Element was skipped");
-                }
-            }
-            return ar.toArray(new String[ar.size()]);
-        }
-
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
index 98e2cfc..65e93bc 100644
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
+++ b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
@@ -23,13 +23,13 @@ import java.util.Hashtable;
 
 import junit.framework.TestCase;
 
+import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
 
 public class ActivatorTest extends TestCase {
 
@@ -54,7 +54,7 @@ public class ActivatorTest extends TestCase {
         EasyMock.expect(bc.createFilter(EasyMock.<String>anyObject())).andReturn(filter);
         EasyMock.expectLastCall().atLeastOnce();
         ServiceRegistration sr = control.createMock(ServiceRegistration.class);
-        EasyMock.expect(bc.registerService(EasyMock.eq(RemoteServiceAdmin.class.getName()),
+        EasyMock.expect(bc.registerService(EasyMock.eq(DistributionProvider.class.getName()),
                                            EasyMock.anyObject(), (Dictionary<String, String>)EasyMock.anyObject()))
                                            .andReturn(sr).atLeastOnce();
 

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java
deleted file mode 100644
index 2f32ab7..0000000
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/ClientServiceFactoryTest.java
+++ /dev/null
@@ -1,90 +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.service;
-
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.cxf.dosgi.dsw.api.DistributionProvider;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.isA;
-
-
-public class ClientServiceFactoryTest extends TestCase {
-
-    @SuppressWarnings({
-     "rawtypes", "unchecked"
-    })
-    public void testGetService() throws ClassNotFoundException {
-        final Object myTestProxyObject = new Object();
-
-        IMocksControl control = EasyMock.createControl();
-        EndpointDescription endpoint = createTestEndpointDesc();
-        ImportRegistrationImpl iri = new ImportRegistrationImpl(endpoint, null);
-
-        BundleContext requestingContext = control.createMock(BundleContext.class);
-        Bundle requestingBundle = control.createMock(Bundle.class);
-        EasyMock.expect(requestingBundle.loadClass(String.class.getName())).andReturn((Class)String.class);
-        EasyMock.expect(requestingBundle.getBundleContext()).andReturn(requestingContext);
-        ServiceRegistration sreg = control.createMock(ServiceRegistration.class);
-
-
-        DistributionProvider handler = mockDistributionProvider(myTestProxyObject);
-        control.replay();
-
-        ClientServiceFactory csf = new ClientServiceFactory(endpoint, handler, iri);
-        assertSame(myTestProxyObject, csf.getService(requestingBundle, sreg));
-    }
-
-    /**
-     * Creating dummy class as I was not able to really mock it
-     * @param myTestProxyObject
-     * @return
-     */
-    private DistributionProvider mockDistributionProvider(final Object proxy) {
-        DistributionProvider handler = EasyMock.createMock(DistributionProvider.class);
-        EasyMock.expect(handler.importEndpoint(anyObject(BundleContext.class), 
-                                               isA(Class[].class), 
-                                               anyObject(EndpointDescription.class))).andReturn(proxy);
-        EasyMock.replay(handler);
-        return handler;
-    }
-
-    private EndpointDescription createTestEndpointDesc() {
-        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[]{String.class.getName()});
-        EndpointDescription endpoint = new EndpointDescription(map);
-        return endpoint;
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
deleted file mode 100644
index f3cf46d..0000000
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
+++ /dev/null
@@ -1,124 +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.service;
-
-import junit.framework.TestCase;
-
-public class DistributionProviderImplTest extends TestCase {
-
-    public void testDUMMY() {
-        assertTrue(true);
-    }
-
-//    public void testExposedServices() {
-//        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-//        EasyMock.replay(bc);
-//        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(bc);
-//
-//        assertEquals(0, dp.getExposedServices().size());
-//        assertEquals(0, dp.getRemoteServices().size());
-//        ServiceReference sr = new TestServiceReference();
-//        ServiceReference sr2 = new TestServiceReference();
-//
-//        dp.addExposedService(sr, null);
-//        assertEquals(1, dp.getExposedServices().size());
-//        assertEquals(0, dp.getRemoteServices().size());
-//        assertSame(sr, dp.getExposedServices().iterator().next());
-//
-//        dp.addExposedService(sr, null);
-//        assertEquals(1, dp.getExposedServices().size());
-//        assertEquals(0, dp.getRemoteServices().size());
-//        assertSame(sr, dp.getExposedServices().iterator().next());
-//
-//        dp.addExposedService(sr2, null);
-//        assertEquals(2, dp.getExposedServices().size());
-//        assertEquals(0, dp.getRemoteServices().size());
-//    }
-//
-//    public void testRemoteServices() {
-//        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-//        EasyMock.replay(bc);
-//        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(bc);
-//
-//        assertEquals(0, dp.getExposedServices().size());
-//        assertEquals(0, dp.getRemoteServices().size());
-//        ServiceReference sr = new TestServiceReference();
-//        ServiceReference sr2 = new TestServiceReference();
-//
-//        dp.addRemoteService(sr);
-//        assertEquals(0, dp.getExposedServices().size());
-//        assertEquals(1, dp.getRemoteServices().size());
-//        assertSame(sr, dp.getRemoteServices().iterator().next());
-//
-//        dp.addRemoteService(sr);
-//        assertEquals(0, dp.getExposedServices().size());
-//        assertEquals(1, dp.getRemoteServices().size());
-//        assertSame(sr, dp.getRemoteServices().iterator().next());
-//
-//        dp.addRemoteService(sr2);
-//        assertEquals(0, dp.getExposedServices().size());
-//        assertEquals(2, dp.getRemoteServices().size());
-//    }
-//
-//    public void testPublicationProperties() {
-//        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-//        EasyMock.replay(bc);
-//
-//        RemoteServiceAdminCore dp = new RemoteServiceAdminCore(bc);
-//        ServiceReference sr = new TestServiceReference();
-//        ServiceReference sr2 = new TestServiceReference();
-//
-//        assertNull(dp.getExposedProperties(sr));
-//
-//        dp.addExposedService(sr, null);
-//        Map<String, String> pp = new HashMap<String, String>();
-//        pp.put("a", "b");
-//        dp.addExposedService(sr2, pp);
-//
-//        assertEquals(0, dp.getExposedProperties(sr).size());
-//        assertEquals(pp, dp.getExposedProperties(sr2));
-//    }
-//
-//    private static class TestServiceReference implements ServiceReference {
-
-//        public Bundle getBundle() {
-//            return null;
-//        }
-//
-//        public Object getProperty(String arg0) {
-//            return null;
-//        }
-//
-//        public String[] getPropertyKeys() {
-//            return null;
-//        }
-//
-//        public Bundle[] getUsingBundles() {
-//            return null;
-//        }
-//
-//        public boolean isAssignableTo(Bundle arg0, String arg1) {
-//            return false;
-//        }
-//
-//        public int compareTo(Object o) {
-//            return 0;
-//        }
-//    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java
deleted file mode 100644
index 71d3ed7..0000000
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/EventProducerTest.java
+++ /dev/null
@@ -1,189 +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.service;
-
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.cxf.dosgi.dsw.api.Endpoint;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.junit.Assert;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
-import org.osgi.service.event.Event;
-import org.osgi.service.event.EventAdmin;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.ExportReference;
-import org.osgi.service.remoteserviceadmin.ExportRegistration;
-import org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent;
-
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class EventProducerTest {
-    
-    
-    @Test
-    public void testPublishNotification() throws Exception {
-        RemoteServiceAdminCore remoteServiceAdminCore = EasyMock.createNiceMock(RemoteServiceAdminCore.class);
-        EasyMock.replay(remoteServiceAdminCore);
-
-        final EndpointDescription epd = EasyMock.createNiceMock(EndpointDescription.class);
-        EasyMock.expect(epd.getServiceId()).andReturn(Long.MAX_VALUE).anyTimes();
-        final String uuid = UUID.randomUUID().toString();
-        EasyMock.expect(epd.getFrameworkUUID()).andReturn(uuid).anyTimes();
-        EasyMock.expect(epd.getId()).andReturn("foo://bar").anyTimes();
-        final List<String> interfaces = Arrays.asList("org.foo.Bar", "org.boo.Far");
-        EasyMock.expect(epd.getInterfaces()).andReturn(interfaces).anyTimes();
-        EasyMock.expect(epd.getConfigurationTypes()).andReturn(Arrays.asList("org.apache.cxf.ws")).anyTimes();
-        EasyMock.replay(epd);
-        final ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
-        EasyMock.replay(sref);
-
-        final Bundle bundle = EasyMock.createNiceMock(Bundle.class);
-        EasyMock.expect(bundle.getBundleId()).andReturn(42L).anyTimes();
-        EasyMock.expect(bundle.getSymbolicName()).andReturn("test.bundle").anyTimes();
-        Dictionary<String, String> headers = new Hashtable<String, String>();
-        headers.put("Bundle-Version", "1.2.3.test");
-        EasyMock.expect(bundle.getHeaders()).andReturn(headers).anyTimes();
-        EasyMock.replay(bundle);
-
-        EventAdmin ea = EasyMock.createNiceMock(EventAdmin.class);
-        ea.postEvent((Event) EasyMock.anyObject());
-        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                Event event = (Event) EasyMock.getCurrentArguments()[0];
-
-                Assert.assertEquals("org/osgi/service/remoteserviceadmin/EXPORT_REGISTRATION", event.getTopic());
-                Assert.assertSame(bundle, event.getProperty("bundle"));
-                Assert.assertEquals(42L, event.getProperty("bundle.id"));
-                Assert.assertEquals("test.bundle", event.getProperty("bundle.symbolicname"));
-                Assert.assertEquals(new Version(1, 2, 3, "test"), event.getProperty("bundle.version"));
-                Assert.assertNull(event.getProperty("cause"));
-                Assert.assertEquals(epd, event.getProperty("export.registration"));
-
-                Assert.assertEquals(Long.MAX_VALUE, event.getProperty("service.remote.id"));
-                Assert.assertEquals(uuid, event.getProperty("service.remote.uuid"));
-                Assert.assertEquals("foo://bar", event.getProperty("service.remote.uri"));
-                Assert.assertTrue(Arrays.equals(interfaces.toArray(new String[] {}),
-                                                (String[]) event.getProperty("objectClass")));
-
-                Assert.assertNotNull(event.getProperty("timestamp"));
-
-                RemoteServiceAdminEvent rsae = (RemoteServiceAdminEvent) event.getProperty("event");
-                Assert.assertNull(rsae.getException());
-                Assert.assertEquals(RemoteServiceAdminEvent.EXPORT_REGISTRATION, rsae.getType());
-                Assert.assertSame(bundle, rsae.getSource());
-                ExportReference er = rsae.getExportReference();
-                Assert.assertSame(epd, er.getExportedEndpoint());
-                Assert.assertSame(sref, er.getExportedService());
-
-                return null;
-            }
-        });
-        EasyMock.replay(ea);
-
-        ServiceReference eaSref = EasyMock.createNiceMock(ServiceReference.class);
-        EasyMock.replay(eaSref);
-
-        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-        EasyMock.expect(bc.getBundle()).andReturn(bundle).anyTimes();
-        EasyMock.expect(bc.getAllServiceReferences(EventAdmin.class.getName(), null))
-            .andReturn(new ServiceReference[] {eaSref}).anyTimes();
-        EasyMock.expect(bc.getService(eaSref)).andReturn(ea).anyTimes();
-        Endpoint endpoint = EasyMock.mock(Endpoint.class);
-        EasyMock.expect(endpoint.description()).andReturn(epd);
-        EasyMock.replay(endpoint);
-        EasyMock.replay(bc);
-        EventProducer eventProducer = new EventProducer(bc);
-
-        ExportRegistrationImpl ereg = new ExportRegistrationImpl(sref, endpoint, remoteServiceAdminCore);
-        eventProducer.publishNotification(ereg);
-    }
-
-    @Test
-    public void testPublishErrorNotification() throws Exception {
-        RemoteServiceAdminCore rsaCore = EasyMock.createNiceMock(RemoteServiceAdminCore.class);
-        EasyMock.replay(rsaCore);
-
-        final EndpointDescription endpoint = EasyMock.createNiceMock(EndpointDescription.class);
-        EasyMock.expect(endpoint.getInterfaces()).andReturn(Arrays.asList("org.foo.Bar")).anyTimes();
-        EasyMock.replay(endpoint);
-        final ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
-        EasyMock.replay(sref);
-
-        final Bundle bundle = EasyMock.createNiceMock(Bundle.class);
-        EasyMock.expect(bundle.getBundleId()).andReturn(42L).anyTimes();
-        EasyMock.expect(bundle.getSymbolicName()).andReturn("test.bundle").anyTimes();
-        EasyMock.expect(bundle.getHeaders()).andReturn(new Hashtable<String, String>()).anyTimes();
-        EasyMock.replay(bundle);
-
-        final Exception exportException = new Exception();
-
-        EventAdmin ea = EasyMock.createNiceMock(EventAdmin.class);
-        ea.postEvent((Event) EasyMock.anyObject());
-        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
-            @Override
-            public Object answer() throws Throwable {
-                Event event = (Event) EasyMock.getCurrentArguments()[0];
-
-                Assert.assertEquals("org/osgi/service/remoteserviceadmin/EXPORT_ERROR", event.getTopic());
-                Assert.assertSame(bundle, event.getProperty("bundle"));
-                Assert.assertEquals(42L, event.getProperty("bundle.id"));
-                Assert.assertEquals("test.bundle", event.getProperty("bundle.symbolicname"));
-                Assert.assertEquals(new Version("0"), event.getProperty("bundle.version"));
-                Assert.assertSame(exportException, event.getProperty("cause"));
-                Assert.assertEquals(endpoint, event.getProperty("export.registration"));
-                Assert.assertTrue(Arrays.equals(new String[] {"org.foo.Bar"},
-                                                (String[]) event.getProperty("objectClass")));
-
-                RemoteServiceAdminEvent rsae = (RemoteServiceAdminEvent) event.getProperty("event");
-                Assert.assertSame(exportException, rsae.getException());
-                Assert.assertEquals(RemoteServiceAdminEvent.EXPORT_ERROR, rsae.getType());
-                Assert.assertSame(bundle, rsae.getSource());
-                ExportReference er = rsae.getExportReference();
-                Assert.assertSame(endpoint, er.getExportedEndpoint());
-                Assert.assertSame(sref, er.getExportedService());
-
-                return null;
-            }
-        });
-        EasyMock.replay(ea);
-
-        ServiceReference eaSref = EasyMock.createNiceMock(ServiceReference.class);
-        EasyMock.replay(eaSref);
-
-        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
-        EasyMock.expect(bc.getBundle()).andReturn(bundle).anyTimes();
-        EasyMock.expect(bc.getAllServiceReferences(EventAdmin.class.getName(), null))
-            .andReturn(new ServiceReference[] {eaSref}).anyTimes();
-        EasyMock.expect(bc.getService(eaSref)).andReturn(ea).anyTimes();
-        EasyMock.replay(bc);
-        EventProducer eventProducer = new EventProducer(bc);
-
-        ExportRegistrationImpl ereg = new ExportRegistrationImpl(rsaCore, exportException);
-        eventProducer.publishNotification(Arrays.<ExportRegistration>asList(ereg));
-    }
-}

http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/4ed2614d/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImplTest.java
----------------------------------------------------------------------
diff --git a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImplTest.java b/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImplTest.java
deleted file mode 100644
index 23902a5..0000000
--- a/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/ImportRegistrationImplTest.java
+++ /dev/null
@@ -1,178 +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.service;
-
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-public class ImportRegistrationImplTest {
-
-    @Test
-    public void testException() {
-        IMocksControl c = EasyMock.createNiceControl();
-        Exception e = c.createMock(Exception.class);
-        c.replay();
-
-        ImportRegistrationImpl i = new ImportRegistrationImpl(e);
-
-        assertEquals(e, i.getException());
-        assertNull(i.getImportedEndpointDescription());
-        assertNull(i.getImportedService());
-        assertEquals(i, i.getParent());
-    }
-
-    @Test
-    public void testDefaultCtor() {
-        IMocksControl c = EasyMock.createNiceControl();
-        EndpointDescription endpoint = c.createMock(EndpointDescription.class);
-        RemoteServiceAdminCore rsac = c.createMock(RemoteServiceAdminCore.class);
-
-        c.replay();
-
-        ImportRegistrationImpl i = new ImportRegistrationImpl(endpoint, rsac);
-
-        assertNull(i.getException());
-        assertEquals(i, i.getParent());
-        assertEquals(endpoint, i.getImportedEndpointDescription());
-    }
-
-    @SuppressWarnings("rawtypes")
-    @Test
-    public void testCloneAndClose() {
-        IMocksControl c = EasyMock.createControl();
-        EndpointDescription endpoint = c.createMock(EndpointDescription.class);
-        RemoteServiceAdminCore rsac = c.createMock(RemoteServiceAdminCore.class);
-
-        ServiceRegistration sr = c.createMock(ServiceRegistration.class);
-        ServiceReference sref = c.createMock(ServiceReference.class);
-        EasyMock.expect(sr.getReference()).andReturn(sref).anyTimes();
-
-        c.replay();
-
-        ImportRegistrationImpl i1 = new ImportRegistrationImpl(endpoint, rsac);
-
-        ImportRegistrationImpl i2 = new ImportRegistrationImpl(i1);
-
-        ImportRegistrationImpl i3 = new ImportRegistrationImpl(i2);
-
-        try {
-            i2.setImportedServiceRegistration(sr);
-            assertTrue("An exception should be thrown here !", false);
-        } catch (IllegalStateException e) {
-            // must be thrown here
-        }
-
-        i1.setImportedServiceRegistration(sr);
-
-        assertEquals(i1, i1.getParent());
-        assertEquals(i1, i2.getParent());
-        assertEquals(i1, i3.getParent());
-
-        assertEquals(endpoint, i1.getImportedEndpointDescription());
-        assertEquals(endpoint, i2.getImportedEndpointDescription());
-        assertEquals(endpoint, i3.getImportedEndpointDescription());
-
-        c.verify();
-        c.reset();
-
-        rsac.removeImportRegistration(EasyMock.eq(i3));
-        EasyMock.expectLastCall().once();
-
-        c.replay();
-
-        i3.close();
-        i3.close(); // shouldn't change anything
-
-        assertNull(i3.getImportedEndpointDescription());
-
-        c.verify();
-        c.reset();
-
-        rsac.removeImportRegistration(EasyMock.eq(i1));
-        EasyMock.expectLastCall().once();
-
-        c.replay();
-
-        i1.close();
-
-        c.verify();
-        c.reset();
-
-        rsac.removeImportRegistration(EasyMock.eq(i2));
-        EasyMock.expectLastCall().once();
-
-        sr.unregister();
-        EasyMock.expectLastCall().once();
-
-        c.replay();
-
-        i2.close();
-
-        c.verify();
-    }
-
-    @Test
-    public void testCloseAll() {
-        IMocksControl c = EasyMock.createControl();
-        EndpointDescription endpoint = c.createMock(EndpointDescription.class);
-        RemoteServiceAdminCore rsac = c.createMock(RemoteServiceAdminCore.class);
-
-        c.replay();
-
-        ImportRegistrationImpl i1 = new ImportRegistrationImpl(endpoint, rsac);
-
-        ImportRegistrationImpl i2 = new ImportRegistrationImpl(i1);
-
-        ImportRegistrationImpl i3 = new ImportRegistrationImpl(i2);
-
-        assertEquals(i1, i1.getParent());
-        assertEquals(i1, i2.getParent());
-        assertEquals(i1, i3.getParent());
-
-        c.verify();
-        c.reset();
-
-        rsac.removeImportRegistration(EasyMock.eq(i2));
-        EasyMock.expectLastCall().once();
-
-        c.replay();
-
-        i2.close();
-
-        c.verify();
-        c.reset();
-
-        rsac.removeImportRegistration(EasyMock.eq(i1));
-        EasyMock.expectLastCall().once();
-        rsac.removeImportRegistration(EasyMock.eq(i3));
-        EasyMock.expectLastCall().once();
-
-        c.replay();
-        i3.closeAll();
-        c.verify();
-    }
-}


Mime
View raw message