Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=345352
diff --git a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
index 65a1878..4d3e46c 100644
--- a/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
+++ b/framework/bundles/org.eclipse.ecf.provider/src/org/eclipse/ecf/provider/generic/GenericContainerInstantiator.java
@@ -36,6 +36,10 @@
 
 	private static final int CREATE_INSTANCE_ERROR_CODE = 4441;
 
+	private static final String ID_PROP = "id"; //$NON-NLS-1$
+
+	private static final String KEEPALIVE_PROP = "keepAlive"; //$NON-NLS-1$
+
 	public GenericContainerInstantiator() {
 		super();
 	}
@@ -98,7 +102,14 @@
 		ID newID = null;
 		Integer ka = null;
 		if (args != null && args.length > 0) {
-			if (args.length > 1) {
+			if (args[0] instanceof Map) {
+				Map map = (Map) args[0];
+				Object idVal = map.get(ID_PROP);
+				if (idVal == null)
+					throw new IDCreateException("Cannot create ID.  No property with key=" + ID_PROP + " found in configuration=" + map); //$NON-NLS-1$ //$NON-NLS-2$
+				newID = getIDFromArg(idVal);
+				ka = getIntegerFromArg(map.get(KEEPALIVE_PROP));
+			} else if (args.length > 1) {
 				if (args[0] instanceof String || args[0] instanceof ID)
 					newID = getIDFromArg(args[0]);
 				if (args[1] instanceof String || args[1] instanceof Integer)
@@ -126,7 +137,14 @@
 		ID newID = null;
 		Integer ka = null;
 		if (args != null && args.length > 0) {
-			if (args.length > 1) {
+			if (args[0] instanceof Map) {
+				Map map = (Map) args[0];
+				Object idVal = map.get(ID_PROP);
+				if (idVal == null)
+					throw new IDCreateException("Cannot create ID.  No property with key=" + ID_PROP + " found in configuration=" + map); //$NON-NLS-1$ //$NON-NLS-2$
+				newID = getIDFromArg(idVal);
+				ka = getIntegerFromArg(map.get(KEEPALIVE_PROP));
+			} else if (args.length > 1) {
 				if (args[0] instanceof String || args[0] instanceof ID)
 					newID = getIDFromArg(args[0]);
 				if (args[1] instanceof String || args[1] instanceof Integer)
@@ -199,7 +217,7 @@
 			Trace.catching(ProviderPlugin.PLUGIN_ID, ECFProviderDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "createInstance", e); //$NON-NLS-1$
 			ProviderPlugin.getDefault().log(new Status(IStatus.ERROR, ProviderPlugin.PLUGIN_ID, CREATE_INSTANCE_ERROR_CODE, "createInstance", e)); //$NON-NLS-1$
 			Trace.throwing(ProviderPlugin.PLUGIN_ID, ECFProviderDebugOptions.EXCEPTIONS_THROWING, this.getClass(), "createInstance", e); //$NON-NLS-1$
-			throw new ContainerCreateException("createInstance", e); //$NON-NLS-1$
+			throw new ContainerCreateException("Create of containerType=" + description.getName() + " failed.", e); //$NON-NLS-1$ //$NON-NLS-2$
 		}
 	}
 
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
index 6294130..6c59b63 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
@@ -94,9 +94,8 @@
 			// stop it

 			try {

 				proxyServiceFactoryBundleContext.getBundle().stop();

-			} catch (BundleException e) {

-				// print to error stream

-				e.printStackTrace(System.err);

+			} catch (Exception e) {

+				// we don't care

 			}

 			proxyServiceFactoryBundleContext = null;

 		}

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java
index 417317d..2221298 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java
@@ -324,16 +324,16 @@
 

 		public void startElement(String name, Attributes attributes)

 				throws SAXException {

-			if (ENDPOINT_DESCRIPTION.equals(name)) 

-				new EndpointDescriptionHandler(

-						this, attributes, endpointDescriptions);

+			if (ENDPOINT_DESCRIPTION.equals(name))

+				new EndpointDescriptionHandler(this, attributes,

+						endpointDescriptions);

 			else

 				invalidElement(name, attributes);

 		}

 

 		public void endElement(String namespaceURI, String localName,

 				String qName) {

-			if (elementHandled.equals(localName)) 

+			if (elementHandled.equals(localName))

 				super.endElement(namespaceURI, localName, qName);

 		}

 

@@ -357,7 +357,7 @@
 

 		public void startElement(String name, Attributes attributes)

 				throws SAXException {

-			if (ENDPOINT_PROPERTY.equals(name)) 

+			if (ENDPOINT_PROPERTY.equals(name))

 				new EndpointPropertyHandler(this, attributes, properties);

 		}

 

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java
index 04ca0b6..f52e009 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java
@@ -21,6 +21,7 @@
 import java.util.Map;

 import java.util.Properties;

 import java.util.Set;

+import java.util.TreeMap;

 

 import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants;

 import org.eclipse.ecf.remoteservice.IRemoteServiceReference;

@@ -127,12 +128,14 @@
 			return objectClass;

 		else {

 			final String[] stringArrayValue = getStringArrayFromPropertyValue(propValue);

-			if (stringArrayValue == null) return null;

+			if (stringArrayValue == null)

+				return null;

 			else if (stringArrayValue.length == 1

 					&& stringArrayValue[0].equals("*")) { //$NON-NLS-1$

-				// this will support the idiom:  new String[] { "*" }

+				// this will support the idiom: new String[] { "*" }

 				return objectClass;

-			} else return stringArrayValue;

+			} else

+				return stringArrayValue;

 		}

 	}

 

@@ -239,14 +242,15 @@
 	public static boolean isECFProperty(String key) {

 		return ecfProperties.contains(key);

 	}

-	

+

 	// skip dotted (private) properties (R4.2 enterprise spec. table 122.1)

 	public static boolean isPrivateProperty(String key) {

 		return (key.startsWith(".")); //$NON-NLS-N$

 	}

 

 	public static boolean isReservedProperty(String key) {

-		return isOSGiProperty(key) || isECFProperty(key) || isPrivateProperty(key);

+		return isOSGiProperty(key) || isECFProperty(key)

+				|| isPrivateProperty(key);

 	}

 

 	public static Map createMapFromDictionary(Dictionary input) {

@@ -371,18 +375,19 @@
 				target.put(keys[i], rsReference.getProperty(keys[i]));

 		return target;

 	}

-	

+

 	public static Map mergeProperties(final ServiceReference serviceReference,

 			final Map<String, Object> overrides) {

 		return mergeProperties(copyProperties(serviceReference, new HashMap()),

 				overrides);

 	}

-	

+

 	public static Map mergeProperties(final Map<String, Object> source,

 			final Map<String, Object> overrides) {

 

 		// copy to target from service reference

-		final Map target = copyProperties(source, new HashMap());

+		final Map target = copyProperties(source, new TreeMap<String, Object>(

+				String.CASE_INSENSITIVE_ORDER));

 

 		// now do actual merge

 		final Set<String> keySet = overrides.keySet();

@@ -393,7 +398,7 @@
 				continue;

 			}

 			target.remove(key.toLowerCase());

-			target.put(key, overrides.get(key));

+			target.put(key.toLowerCase(), overrides.get(key));

 		}

 

 		return target;

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
index c6119dd..3eb2bce 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
@@ -16,6 +16,7 @@
 import java.util.Map;

 

 import org.eclipse.ecf.core.ContainerConnectException;

+import org.eclipse.ecf.core.ContainerCreateException;

 import org.eclipse.ecf.core.ContainerTypeDescription;

 import org.eclipse.ecf.core.IContainer;

 import org.eclipse.ecf.core.IContainerFactory;

@@ -134,7 +135,8 @@
 	}

 

 	protected IRemoteServiceContainer createAndConfigureConsumerContainer(

-			String[] remoteSupportedConfigs, Map remoteExportedProperties) {

+			String[] remoteSupportedConfigs, Map remoteExportedProperties)

+			throws SelectContainerException {

 		if (remoteSupportedConfigs == null

 				|| remoteSupportedConfigs.length == 0)

 			return null;

@@ -169,6 +171,7 @@
 				// If we have one to use, then create the container

 				if (selectedConfig != null) {

 					IRemoteServiceContainer rsContainer = createContainer(

+							desc,

 							selectedConfig,

 							PropertiesUtil

 									.createMapFromDictionary(importedConfigProperties));

@@ -186,18 +189,26 @@
 	}

 

 	protected IRemoteServiceContainer createContainer(

-			String containerTypeDescriptionName, Map properties) {

+			ContainerTypeDescription containerTypeDescription,

+			String containerTypeDescriptionName, Map properties)

+			throws SelectContainerException {

 		try {

 			IContainer container = (properties == null) ? getContainerFactory()

 					.createContainer(containerTypeDescriptionName)

 					: getContainerFactory().createContainer(

 							containerTypeDescriptionName, properties);

+			IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container

+					.getAdapter(IRemoteServiceContainerAdapter.class);

+			if (adapter == null)

+				throw new SelectContainerException(

+						"Container does not implement IRemoteServiceContainerAdapter", null, containerTypeDescription); //$NON-NLS-1$

 			return new RemoteServiceContainer(container);

-		} catch (Exception e) {

-			logException(

-					"Cannot create container with container type description name=" //$NON-NLS-1$

-							+ containerTypeDescriptionName, e);

-			return null;

+		} catch (ContainerCreateException e) {

+			String message = "Cannot create container with container type description name=" //$NON-NLS-1$

+					+ containerTypeDescriptionName;

+			logException(message, e);

+			throw new SelectContainerException(message, e,

+					containerTypeDescription);

 		}

 	}

 

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java
index 69e7223..1b24898 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java
@@ -10,6 +10,7 @@
 package org.eclipse.ecf.osgi.services.remoteserviceadmin;

 

 import java.util.ArrayList;

+import java.util.HashMap;

 import java.util.List;

 import java.util.Map;

 

@@ -120,24 +121,65 @@
 	 * @since 2.0

 	 */

 	protected IContainer createContainer(ServiceReference serviceReference,

-			Map<String, Object> properties, ContainerTypeDescription containerTypeDescription)

-			throws ContainerCreateException {

+			Map<String, Object> properties,

+			ContainerTypeDescription containerTypeDescription)

+			throws SelectContainerException {

 

 		IContainerFactory containerFactory = getContainerFactory();

 

+		final Object containerFactoryArguments = getContainerFactoryArguments(

+				serviceReference, properties, containerTypeDescription);

+

+		try {

+			if (containerFactoryArguments instanceof String) {

+				return containerFactory.createContainer(

+						containerTypeDescription,

+						(String) containerFactoryArguments);

+			} else if (containerFactoryArguments instanceof ID) {

+				return containerFactory.createContainer(

+						containerTypeDescription,

+						(ID) containerFactoryArguments);

+			} else if (containerFactoryArguments instanceof Object[]) {

+				return containerFactory.createContainer(

+						containerTypeDescription,

+						(Object[]) containerFactoryArguments);

+			} else if (containerFactoryArguments instanceof Map) {

+				return containerFactory.createContainer(

+						containerTypeDescription,

+						(Map) containerFactoryArguments);

+			}

+			return containerFactory.createContainer(containerTypeDescription);

+		} catch (ContainerCreateException e) {

+			throw new SelectContainerException(

+					"Exception creating or configuring container", e,

+					containerTypeDescription);

+		}

+	}

+

+	protected Object getContainerFactoryArguments(

+			ServiceReference serviceReference, Map<String, Object> properties,

+			ContainerTypeDescription containerTypeDescription) {

+		// If the RemoteConstants.SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS is set

+		// than use it.

 		final Object containerFactoryArguments = properties

 				.get(RemoteConstants.SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS);

-		if (containerFactoryArguments instanceof String) {

-			return containerFactory.createContainer(containerTypeDescription,

-					(String) containerFactoryArguments);

-		} else if (containerFactoryArguments instanceof ID) {

-			return containerFactory.createContainer(containerTypeDescription,

-					(ID) containerFactoryArguments);

-		} else if (containerFactoryArguments instanceof Object[]) {

-			return containerFactory.createContainer(containerTypeDescription,

-					(Object[]) containerFactoryArguments);

+		if (containerFactoryArguments != null)

+			return containerFactoryArguments;

+

+		String exportedConfig = containerTypeDescription.getName();

+		// If not, then we look through the properties that start with

+		// <containerTypeDescription.name>.

+		Map<String, Object> results = new HashMap<String, Object>();

+		for (String origKey : properties.keySet()) {

+			if (origKey.startsWith(exportedConfig + ".")) {

+				String key = origKey.substring(exportedConfig.length() + 1);

+				if (key != null)

+					results.put(key, properties.get(origKey));

+			}

 		}

-		return containerFactory.createContainer(containerTypeDescription);

+		if (results.size() == 0)

+			return null;

+		return results;

 	}

 

 	protected ID createTargetID(IContainer container, String target) {

@@ -152,8 +194,8 @@
 	 * @since 2.0

 	 */

 	protected IConnectContext createConnectContext(

-			ServiceReference serviceReference, Map<String, Object> properties, IContainer container,

-			Object context) {

+			ServiceReference serviceReference, Map<String, Object> properties,

+			IContainer container, Object context) {

 		if (context instanceof IConnectContext)

 			return (IConnectContext) context;

 		return null;

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java
index 65fdb81..201394d 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java
@@ -50,7 +50,8 @@
 	 */

 	protected Collection selectExistingHostContainers(

 			ServiceReference serviceReference,

-			Map<String, Object> overridingProperties, String[] serviceExportedInterfaces,

+			Map<String, Object> overridingProperties,

+			String[] serviceExportedInterfaces,

 			String[] serviceExportedConfigs, String[] serviceIntents) {

 		List results = new ArrayList();

 		// Get all existing containers

@@ -76,9 +77,9 @@
 				continue;

 			}

 

-			if (matchExistingHostContainer(serviceReference, overridingProperties, containers[i],

-					adapter, description, serviceExportedConfigs,

-					serviceIntents)) {

+			if (matchExistingHostContainer(serviceReference,

+					overridingProperties, containers[i], adapter, description,

+					serviceExportedConfigs, serviceIntents)) {

 				trace("selectExistingHostContainers", "INCLUDING containerID=" //$NON-NLS-1$ //$NON-NLS-2$

 						+ containers[i].getID()

 						+ " configs=" //$NON-NLS-1$

@@ -106,8 +107,8 @@
 	 * @since 2.0

 	 */

 	protected boolean matchHostContainerToConnectTarget(

-			ServiceReference serviceReference,

-			Map<String, Object> properties, IContainer container) {

+			ServiceReference serviceReference, Map<String, Object> properties,

+			IContainer container) {

 		String target = (String) properties

 				.get(RemoteConstants.ENDPOINT_CONNECTTARGET_ID);

 		if (target == null)

@@ -121,8 +122,8 @@
 		if (connectedID == null) {

 			// connect to the target and we have a match

 			try {

-				connectHostContainer(serviceReference, properties,

-						container, target);

+				connectHostContainer(serviceReference, properties, container,

+						target);

 			} catch (Exception e) {

 				logException("doConnectContainer containerID=" //$NON-NLS-1$

 						+ container.getID() + " target=" + target, e); //$NON-NLS-1$

@@ -143,17 +144,15 @@
 	 * @since 2.0

 	 */

 	protected boolean matchExistingHostContainer(

-			ServiceReference serviceReference,

-			Map<String, Object> properties, IContainer container,

-			IRemoteServiceContainerAdapter adapter,

+			ServiceReference serviceReference, Map<String, Object> properties,

+			IContainer container, IRemoteServiceContainerAdapter adapter,

 			ContainerTypeDescription description, String[] requiredConfigTypes,

 			String[] requiredServiceIntents) {

 

 		return matchHostSupportedConfigTypes(requiredConfigTypes, description)

 				&& matchHostSupportedIntents(requiredServiceIntents,

 						description)

-				&& matchHostContainerID(serviceReference, properties,

-						container)

+				&& matchHostContainerID(serviceReference, properties, container)

 				&& matchHostContainerToConnectTarget(serviceReference,

 						properties, container);

 	}

@@ -226,9 +225,9 @@
 	 * @since 2.0

 	 */

 	protected Collection createAndConfigureHostContainers(

-			ServiceReference serviceReference,

-			Map<String, Object> properties, String[] serviceExportedInterfaces, String[] requiredConfigs,

-			String[] requiredIntents) {

+			ServiceReference serviceReference, Map<String, Object> properties,

+			String[] serviceExportedInterfaces, String[] requiredConfigs,

+			String[] requiredIntents) throws SelectContainerException {

 

 		List results = new ArrayList();

 		ContainerTypeDescription[] descriptions = getContainerTypeDescriptions();

@@ -236,7 +235,9 @@
 			return Collections.EMPTY_LIST;

 		// If there are no required configs specified, then create any defaults

 		if (requiredConfigs == null || requiredConfigs.length == 0) {

-			createAndAddDefaultContainers(serviceReference, properties, serviceExportedInterfaces, requiredIntents, descriptions, results);

+			createAndAddDefaultContainers(serviceReference, properties,

+					serviceExportedInterfaces, requiredIntents, descriptions,

+					results);

 		} else {

 			// See if we have a match

 			for (int i = 0; i < descriptions.length; i++) {

@@ -251,17 +252,23 @@
 		return results;

 	}

 

-	private void createAndAddDefaultContainers(ServiceReference serviceReference, Map<String, Object> properties, String[] serviceExportedInterfaces, String[] requiredIntents, ContainerTypeDescription[] descriptions, Collection results) {

+	private void createAndAddDefaultContainers(

+			ServiceReference serviceReference, Map<String, Object> properties,

+			String[] serviceExportedInterfaces, String[] requiredIntents,

+			ContainerTypeDescription[] descriptions, Collection results)

+			throws SelectContainerException {

 		ContainerTypeDescription[] ctds = getContainerTypeDescriptionsForDefaultConfigTypes(descriptions);

 		if (ctds != null) {

 			for (int i = 0; i < ctds.length; i++) {

-				IRemoteServiceContainer matchingContainer = createMatchingContainer(ctds[i], serviceReference, properties, serviceExportedInterfaces, null, requiredIntents);

+				IRemoteServiceContainer matchingContainer = createMatchingContainer(

+						ctds[i], serviceReference, properties,

+						serviceExportedInterfaces, null, requiredIntents);

 				if (matchingContainer != null)

 					results.add(matchingContainer);

 			}

 		}

 	}

-	

+

 	protected ContainerTypeDescription[] getContainerTypeDescriptionsForDefaultConfigTypes(

 			ContainerTypeDescription[] descriptions) {

 		String[] defaultConfigTypes = getDefaultConfigTypes();

@@ -296,44 +303,41 @@
 	}

 

 	/**

+	 * @throws ContainerCreateException

 	 * @since 2.0

 	 */

 	protected IRemoteServiceContainer createMatchingContainer(

 			ContainerTypeDescription containerTypeDescription,

-			ServiceReference serviceReference,

-			Map<String, Object> properties, String[] serviceExportedInterfaces, String[] requiredConfigs,

-			String[] requiredIntents) {

+			ServiceReference serviceReference, Map<String, Object> properties,

+			String[] serviceExportedInterfaces, String[] requiredConfigs,

+			String[] requiredIntents) throws SelectContainerException {

 

 		if (matchHostSupportedConfigTypes(requiredConfigs,

 				containerTypeDescription)

 				&& matchHostSupportedIntents(requiredIntents,

 						containerTypeDescription)) {

-			return createRSContainer(serviceReference, properties, containerTypeDescription);

+			return createRSContainer(serviceReference, properties,

+					containerTypeDescription);

 		}

 		return null;

 	}

 

 	/**

+	 * @throws ContainerCreateException

 	 * @since 2.0

 	 */

 	protected IRemoteServiceContainer createRSContainer(

-			ServiceReference serviceReference,

-			Map<String, Object> properties, ContainerTypeDescription containerTypeDescription) {

-		try {

-			IContainer container = createContainer(serviceReference, properties,

-					containerTypeDescription);

-			IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container

-					.getAdapter(IRemoteServiceContainerAdapter.class);

-			if (adapter == null)

-				throw new ContainerCreateException(

-						"Container does not implement IRemoteServiceContainerAdapter"); //$NON-NLS-1$

-			return new RemoteServiceContainer(container, adapter);

-		} catch (Exception e) {

-			logException(

-					"Exception creating container from ContainerTypeDescription=" //$NON-NLS-1$

-							+ containerTypeDescription, e);

-			return null;

-		}

+			ServiceReference serviceReference, Map<String, Object> properties,

+			ContainerTypeDescription containerTypeDescription)

+			throws SelectContainerException {

+		IContainer container = createContainer(serviceReference, properties,

+				containerTypeDescription);

+		IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container

+				.getAdapter(IRemoteServiceContainerAdapter.class);

+		if (adapter == null)

+			throw new SelectContainerException(

+					"Container does not implement IRemoteServiceContainerAdapter", null, containerTypeDescription); //$NON-NLS-1$

+		return new RemoteServiceContainer(container, adapter);

 	}

 

 	/**

@@ -350,8 +354,8 @@
 				.get(RemoteConstants.SERVICE_EXPORTED_CONTAINER_CONNECT_CONTEXT);

 		IConnectContext connectContext = null;

 		if (context != null) {

-			connectContext = createConnectContext(serviceReference, properties, container,

-					context);

+			connectContext = createConnectContext(serviceReference, properties,

+					container, context);

 		}

 		// connect the container

 		container.connect(targetID, connectContext);

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java
index 1698795..e06dff7 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java
@@ -29,50 +29,40 @@
 	}

 

 	public IRemoteServiceContainer selectConsumerContainer(

-			EndpointDescription endpointDescription) {

+			EndpointDescription endpointDescription)

+			throws SelectContainerException {

 		trace("selectConsumerContainers", "endpointDescription=" + endpointDescription); //$NON-NLS-1$ //$NON-NLS-2$

 

 		// Get service.imported.configs

-		List<String> serviceImportedConfigs = PropertiesUtil

+		List<String> sic = PropertiesUtil

 				.getStringPlusProperty(

 						endpointDescription.getProperties(),

 						org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS);

-		// For ECF providers this endpoint description property should always contain the constant 

-		// org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_IMPORTED_CONFIGS_VALUE

-		if (serviceImportedConfigs

-				.contains(RemoteConstants.ENDPOINT_SERVICE_IMPORTED_CONFIGS_VALUE)) {

-			// Get the endpointID

-			ID endpointContainerID = endpointDescription.getContainerID();

+		String[] serviceImportedConfigs = sic.toArray(new String[sic.size()]);

+		// Get the endpointID

+		ID endpointContainerID = endpointDescription.getContainerID();

 

-			String[] remoteSupportedConfigs = (String[]) endpointDescription

-					.getProperties()

-					.get(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED);

+		// Get connect targetID

+		ID connectTargetID = endpointDescription.getConnectTargetID();

 

-			// Get connect targetID

-			ID connectTargetID = endpointDescription.getConnectTargetID();

+		IRemoteServiceContainer rsContainer = selectExistingConsumerContainer(

+				endpointContainerID, serviceImportedConfigs, connectTargetID);

 

-			IRemoteServiceContainer rsContainer = selectExistingConsumerContainer(

-					endpointContainerID, remoteSupportedConfigs,

-					connectTargetID);

+		// If we haven't found any existing containers then we create one

+		// from the remoteSupportedConfigs...*iff* autoCreateContainer is

+		// set to true

+		if (rsContainer == null && autoCreateContainer)

+			rsContainer = createAndConfigureConsumerContainer(

+					serviceImportedConfigs, endpointDescription.getProperties());

 

-			// If we haven't found any existing containers then we create one

-			// from the remoteSupportedConfigs...*iff* autoCreateContainer is

-			// set to true

-			if (rsContainer == null && autoCreateContainer)

-				rsContainer = createAndConfigureConsumerContainer(

-						remoteSupportedConfigs,

-						endpointDescription.getProperties());

+		// Get the connect target ID from the endpointDescription

+		// and connect the given containers to the connect targetID

+		// This is only needed when when the endpointID is different from

+		// the connect targetID, and the containers are not already

+		// connected

+		connectContainerToTarget(rsContainer, connectTargetID);

 

-			// Get the connect target ID from the endpointDescription

-			// and connect the given containers to the connect targetID

-			// This is only needed when when the endpointID is different from

-			// the connect targetID, and the containers are not already

-			// connected

-			connectContainerToTarget(rsContainer, connectTargetID);

-

-			return rsContainer;

-		}

-		return null;

+		return rsContainer;

 	}

 

 	public void close() {

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
index 6052669..e30a413 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
@@ -17,6 +17,7 @@
 
 import org.eclipse.ecf.core.identity.ID;
 import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.core.identity.IDFactory;
 import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.IDUtil;
 import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
 import org.osgi.framework.ServiceReference;
@@ -129,11 +130,7 @@
 		try {
 			return IDUtil.createID(idNamespace, idName);
 		} catch (IDCreateException e) {
-			IllegalArgumentException iae = new IllegalArgumentException(
-					"cannot create a valid ID: idNamespace=" + idNamespace //$NON-NLS-1$
-							+ ", idName=" + idName); //$NON-NLS-1$
-			iae.initCause(e);
-			throw iae;
+			return IDFactory.getDefault().createStringID(idName);
 		}
 	}
 
@@ -240,12 +237,15 @@
 				propertiesOverrides);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.osgi.service.remoteserviceadmin.EndpointDescription#getProperties()
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.osgi.service.remoteserviceadmin.EndpointDescription#getProperties()
 	 */
 	@Override
 	public Map<String, Object> getProperties() {
-		if(overrides != null) 
+		if (overrides != null)
 			return overrides;
 		return super.getProperties();
 	}
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
index 7348a28..9e2fe27 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
@@ -604,8 +604,8 @@
 			if (filters.size() > 0) {

 				String matchingFilter = isMatch(description, filters);

 				if (matchingFilter != null)

-					results.add(new EndpointListenerHolder(listener, description,

-							matchingFilter));

+					results.add(new EndpointListenerHolder(listener,

+							description, matchingFilter));

 			}

 		}

 		return (EndpointListenerHolder[]) results

@@ -615,9 +615,11 @@
 	private String isMatch(EndpointDescription description, List<String> filters) {

 		for (String filter : filters) {

 			try {

-				if (description.matches(filter)) return filter;

+				if (description.matches(filter))

+					return filter;

 			} catch (IllegalArgumentException e) {

-				logError("isMatch", "invalid endpoint listener filter="+filters, e);

+				logError("isMatch", "invalid endpoint listener filter="

+						+ filters, e);

 			}

 		}

 		return null;

@@ -823,6 +825,8 @@
 		}

 

 		void handleService(IServiceInfo serviceInfo, boolean discovered) {

+			logInfo("handleService", "serviceInfo=" + serviceInfo

+					+ ",discovered=" + discovered);

 			IServiceID serviceID = serviceInfo.getServiceID();

 			if (matchServiceID(serviceID))

 				handleOSGiServiceEndpoint(serviceID, serviceInfo, discovered);

@@ -866,6 +870,12 @@
 			}

 		}

 

+		private void logInfo(String methodName, String message) {

+			LogUtility.logWarning(methodName,

+					DebugOptions.ENDPOINT_DESCRIPTION_LOCATOR, this.getClass(),

+					message);

+		}

+

 		private void logWarning(String methodName, String message) {

 			LogUtility.logWarning(methodName,

 					DebugOptions.ENDPOINT_DESCRIPTION_LOCATOR, this.getClass(),

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/HostContainerSelector.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/HostContainerSelector.java
index 53f11a3..28873c1 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/HostContainerSelector.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/HostContainerSelector.java
@@ -36,14 +36,17 @@
 	// thread safe to deal with bug

 	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=331836

 	/**

-	 * @see org.eclipse.ecf.osgi.services.remoteserviceadmin.IHostContainerSelector#selectHostContainers(org.osgi.framework.ServiceReference, java.util.Map, java.lang.String[], java.lang.String[], java.lang.String[])

+	 * @see org.eclipse.ecf.osgi.services.remoteserviceadmin.IHostContainerSelector#selectHostContainers(org.osgi.framework.ServiceReference,

+	 *      java.util.Map, java.lang.String[], java.lang.String[],

+	 *      java.lang.String[])

 	 * @since 2.0

 	 */

 	public synchronized IRemoteServiceContainer[] selectHostContainers(

 			ServiceReference serviceReference,

 			Map<String, Object> overridingProperties,

 			String[] serviceExportedInterfaces,

-			String[] serviceExportedConfigs, String[] serviceIntents) {

+			String[] serviceExportedConfigs, String[] serviceIntents)

+			throws SelectContainerException {

 		// Find previously created containers that match the given

 		// serviceExportedConfigs and serviceIntents

 		Collection rsContainers = selectExistingHostContainers(

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IConsumerContainerSelector.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IConsumerContainerSelector.java
index 732c445..fce1ddb 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IConsumerContainerSelector.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IConsumerContainerSelector.java
@@ -41,8 +41,12 @@
 	 * @return IRemoteServiceContainer to be used for importing the remote

 	 *         service. May be <code>null</code> if not container is available

 	 *         for use as a consumer for the given endpointDescription.

+	 * @throws SelectContainerException

+	 *             thrown if the host container selection or

+	 *             creation/configuration fails.

 	 */

 	public IRemoteServiceContainer selectConsumerContainer(

-			EndpointDescription endpointDescription);

+			EndpointDescription endpointDescription)

+			throws SelectContainerException;

 

 }

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IHostContainerSelector.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IHostContainerSelector.java
index 5fa4e2d..f7ecdf3 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IHostContainerSelector.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/IHostContainerSelector.java
@@ -66,9 +66,14 @@
 	 *         should be used to export the given remote service (typically via

 	 *         {@link IRemoteServiceContainerAdapter#registerRemoteService(String[], Object, java.util.Dictionary)}

 	 *         ). Will not be <code>null</code>, but may be empty array.

+	 * @throws SelectContainerException

+	 *             thrown if the host container selection or

+	 *             creation/configuration fails.

 	 * @since 2.0

 	 */

 	IRemoteServiceContainer[] selectHostContainers(

-			ServiceReference serviceReference, Map<String, Object> overridingProperties, String[] exportedInterfaces,

-			String[] exportedConfigs, String[] serviceIntents);

+			ServiceReference serviceReference,

+			Map<String, Object> overridingProperties,

+			String[] exportedInterfaces, String[] exportedConfigs,

+			String[] serviceIntents) throws SelectContainerException;

 }

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
index 0c03392..96eacbd 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
@@ -160,13 +160,19 @@
 		}

 	}

 

-	private boolean validExportedInterfaces(ServiceReference serviceReference, String[] exportedInterfaces) {

-		if (exportedInterfaces == null || exportedInterfaces.length == 0) return false;

-		List<String> objectClassList = Arrays.asList((String[]) serviceReference.getProperty(org.osgi.framework.Constants.OBJECTCLASS));

-		for(int i=0; i < exportedInterfaces.length; i++) if (!objectClassList.contains(exportedInterfaces[i])) return false;

+	private boolean validExportedInterfaces(ServiceReference serviceReference,

+			String[] exportedInterfaces) {

+		if (exportedInterfaces == null || exportedInterfaces.length == 0)

+			return false;

+		List<String> objectClassList = Arrays

+				.asList((String[]) serviceReference

+						.getProperty(org.osgi.framework.Constants.OBJECTCLASS));

+		for (int i = 0; i < exportedInterfaces.length; i++)

+			if (!objectClassList.contains(exportedInterfaces[i]))

+				return false;

 		return true;

 	}

-	

+

 	// RemoteServiceAdmin service interface impl methods

 	public Collection<org.osgi.service.remoteserviceadmin.ExportRegistration> exportService(

 			ServiceReference serviceReference,

@@ -187,9 +193,9 @@
 					org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES

 							+ " not set"); //$NON-NLS-1$

 		// verifyExportedInterfaces

-		if (!validExportedInterfaces(serviceReference, exportedInterfaces)) return Collections.EMPTY_LIST;

-		

-		

+		if (!validExportedInterfaces(serviceReference, exportedInterfaces))

+			return Collections.EMPTY_LIST;

+

 		// Get optional exported configs

 		String[] exportedConfigs = PropertiesUtil

 				.getStringArrayFromPropertyValue(overridingProperties

@@ -206,22 +212,30 @@
 

 		// Get a host container selector, and use it to

 		IHostContainerSelector hostContainerSelector = getHostContainerSelector();

-		if (hostContainerSelector == null) {

-			logError("handleServiceRegistering", //$NON-NLS-1$

-					"No defaultHostContainerSelector available"); //$NON-NLS-1$

-			return Collections.EMPTY_LIST;

-		}

 		// select ECF remote service containers that match given exported

 		// interfaces, configs, and intents

-		IRemoteServiceContainer[] rsContainers = hostContainerSelector

-				.selectHostContainers(serviceReference, overridingProperties,

-						exportedInterfaces, exportedConfigs, serviceIntents);

-		// If none found, log a warning and we're done

+		IRemoteServiceContainer[] rsContainers = null;

+		try {

+			rsContainers = hostContainerSelector.selectHostContainers(

+					serviceReference, overridingProperties, exportedInterfaces,

+					exportedConfigs, serviceIntents);

+		} catch (SelectContainerException e) {

+			ExportRegistration errorRegistration = createErrorExportRegistration(

+					serviceReference, overridingProperties,

+					"Error selecting or creating host container for serviceReference="

+							+ serviceReference + " properties="

+							+ overridingProperties, e);

+			Collection<org.osgi.service.remoteserviceadmin.ExportRegistration> result = new ArrayList<org.osgi.service.remoteserviceadmin.ExportRegistration>();

+			result.add(errorRegistration);

+			publishExportEvent(errorRegistration);

+			return result;

+		}

+		// If none found, log warning and return

 		if (rsContainers == null || rsContainers.length == 0) {

-			logWarning(

-					"handleServiceRegistered", "No remote service containers found for serviceReference=" //$NON-NLS-1$ //$NON-NLS-2$

-							+ serviceReference

-							+ ". Remote service NOT EXPORTED"); //$NON-NLS-1$

+			String errorMessage = "No containers found for serviceReference=" //$NON-NLS-1$ 

+					+ serviceReference

+					+ " properties=" + overridingProperties + ". Remote service NOT EXPORTED";//$NON-NLS-2$

+			logWarning("exportService", errorMessage); //$NON-NLS-1$

 			return Collections.EMPTY_LIST;

 		}

 		Collection<ExportRegistration> exportRegistrations = new ArrayList<ExportRegistration>();

@@ -239,13 +253,26 @@
 				if (exportEndpoint != null)

 					exportRegistration = new ExportRegistration(exportEndpoint);

 				else {

+					Map endpointDescriptionProperties = createExportEndpointDescriptionProperties(

+							serviceReference, overridingProperties,

+							exportedInterfaces, serviceIntents, rsContainers[i]);

 					// otherwise, actually export the service to create a new

-					// ExportEndpoint

-					// and use it to create a new ExportRegistration

-					exportRegistration = new ExportRegistration(

-							exportService(serviceReference,

-									overridingProperties, exportedInterfaces,

-									serviceIntents, rsContainers[i]));

+					// ExportEndpoint and use it to create a new

+					// ExportRegistration

+					EndpointDescription endpointDescription = new EndpointDescription(

+							serviceReference, endpointDescriptionProperties);

+					try {

+						// Check security access for export

+						checkEndpointPermission(endpointDescription,

+								EndpointPermission.EXPORT);

+						// Actually do the export and return export registration

+						exportRegistration = exportService(serviceReference,

+								overridingProperties, exportedInterfaces,

+								rsContainers[i], endpointDescriptionProperties);

+					} catch (Exception e) {

+						exportRegistration = new ExportRegistration(e,

+								endpointDescription);

+					}

 				}

 				// If no exception, we add it to our known set of exported

 				// registrations

@@ -255,7 +282,7 @@
 				exportRegistrations.add(exportRegistration);

 			}

 		}

-		// publish all exportRegistrations

+		// publish all activeExportRegistrations

 		for (ExportRegistration exportReg : exportRegistrations)

 			publishExportEvent(exportReg);

 		// and return

@@ -263,6 +290,21 @@
 				exportRegistrations);

 	}

 

+	private ExportRegistration createErrorExportRegistration(

+			ServiceReference serviceReference,

+			Map<String, Object> overridingProperties, String errorMessage,

+			SelectContainerException exception) {

+		ContainerTypeDescription ctd = exception.getContainerTypeDescription();

+		overridingProperties

+				.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID,

+						"noendpoint");

+		overridingProperties

+				.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,

+						(ctd == null) ? "noconfig" : ctd.getName());

+		return new ExportRegistration(exception, new EndpointDescription(

+				serviceReference, overridingProperties));

+	}

+

 	public org.osgi.service.remoteserviceadmin.ImportRegistration importService(

 			org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {

 

@@ -287,8 +329,14 @@
 			return null;

 		}

 		// Select the rsContainer to handle the endpoint description

-		IRemoteServiceContainer rsContainer = consumerContainerSelector

-				.selectConsumerContainer(ed);

+		IRemoteServiceContainer rsContainer = null;

+		try {

+			rsContainer = consumerContainerSelector.selectConsumerContainer(ed);

+		} catch (SelectContainerException e) {

+			ImportRegistration errorRegistration = new ImportRegistration(ed, e);

+			publishImportEvent(errorRegistration);

+			return errorRegistration;

+		}

 		// If none found, log a warning and we're done

 		if (rsContainer == null) {

 			logWarning(

@@ -305,8 +353,7 @@
 			if (importEndpoint != null)

 				importRegistration = new ImportRegistration(importEndpoint);

 			else {

-				importEndpoint = importService(ed, rsContainer);

-				importRegistration = new ImportRegistration(importEndpoint);

+				importRegistration = importService(ed, rsContainer);

 				if (importRegistration.getException() == null)

 					addImportRegistration(importRegistration);

 			}

@@ -450,9 +497,7 @@
 		private EndpointDescription endpointDescription;

 

 		private IRemoteServiceRegistration rsRegistration;

-		private Set<ExportRegistration> exportRegistrations = new HashSet<ExportRegistration>();

-

-		private Throwable exception;

+		private Set<ExportRegistration> activeExportRegistrations = new HashSet<ExportRegistration>();

 

 		ExportEndpoint(ServiceReference serviceReference,

 				EndpointDescription endpointDescription,

@@ -465,19 +510,6 @@
 			this.rsRegistration = reg;

 		}

 

-		ExportEndpoint(ServiceReference serviceReference,

-				EndpointDescription endpointDescription, Throwable t) {

-			Assert.isNotNull(serviceReference);

-			this.serviceReference = serviceReference;

-			Assert.isNotNull(endpointDescription);

-			this.endpointDescription = endpointDescription;

-			this.exception = t;

-		}

-

-		synchronized Throwable getException() {

-			return exception;

-		}

-

 		synchronized ID getContainerID() {

 			return endpointDescription.getContainerID();

 		}

@@ -494,14 +526,15 @@
 			return rsRegistration;

 		}

 

-		synchronized boolean add(ExportRegistration exportRegistration) {

-			return this.exportRegistrations.add(exportRegistration);

+		synchronized boolean addExportRegistration(

+				ExportRegistration exportRegistration) {

+			return this.activeExportRegistrations.add(exportRegistration);

 		}

 

 		synchronized boolean close(ExportRegistration exportRegistration) {

-			boolean removed = this.exportRegistrations

+			boolean removed = this.activeExportRegistrations

 					.remove(exportRegistration);

-			if (removed && exportRegistrations.size() == 0) {

+			if (removed && activeExportRegistrations.size() == 0) {

 				if (rsRegistration != null) {

 					rsRegistration.unregister();

 					rsRegistration = null;

@@ -511,41 +544,38 @@
 			}

 			return removed;

 		}

-

-		public synchronized String toString() {

-			return "ExportEndpoint[rsRegistration=" + rsRegistration + "]"; //$NON-NLS-1$ //$NON-NLS-2$

-		}

-

 	}

 

 	class ExportRegistration implements

 			org.osgi.service.remoteserviceadmin.ExportRegistration {

 

-		private ExportEndpoint exportEndpoint;

 		private ExportReference exportReference;

 

+		private boolean closed = false;

+

 		ExportRegistration(ExportEndpoint exportEndpoint) {

 			Assert.isNotNull(exportEndpoint);

-			this.exportEndpoint = exportEndpoint;

-			// Add ourselves to this exported endpoint

-			this.exportEndpoint.add(this);

-			ServiceReference sr = this.exportEndpoint.getServiceReference();

-			EndpointDescription ed = this.exportEndpoint

-					.getEndpointDescription();

-			this.exportReference = new ExportReference(sr, ed);

+			exportEndpoint.addExportRegistration(this);

+			this.exportReference = new ExportReference(exportEndpoint);

 		}

 

-		synchronized ID getContainerID() {

-			return (exportEndpoint == null) ? null : exportEndpoint

-					.getContainerID();

+		ExportRegistration(Throwable exception,

+				EndpointDescription errorEndpointDescription) {

+			Assert.isNotNull(exception);

+			this.exportReference = new ExportReference(exception,

+					errorEndpointDescription);

+			this.closed = true;

 		}

 

-		synchronized ServiceReference getServiceReference() {

-			return (exportEndpoint == null) ? null : exportEndpoint

-					.getServiceReference();

+		ID getContainerID() {

+			return exportReference.getContainerID();

 		}

 

-		public synchronized org.osgi.service.remoteserviceadmin.ExportReference getExportReference() {

+		ServiceReference getServiceReference() {

+			return exportReference.getExportedService();

+		}

+

+		public org.osgi.service.remoteserviceadmin.ExportReference getExportReference() {

 			Throwable t = getException();

 			if (t != null)

 				throw new IllegalStateException(

@@ -554,11 +584,11 @@
 			return exportReference;

 		}

 

-		synchronized boolean match(ServiceReference serviceReference) {

+		boolean match(ServiceReference serviceReference) {

 			return match(serviceReference, null);

 		}

 

-		synchronized boolean match(ServiceReference serviceReference,

+		boolean match(ServiceReference serviceReference,

 				ID containerID) {

 			ServiceReference ourServiceReference = getServiceReference();

 			if (ourServiceReference == null)

@@ -578,53 +608,45 @@
 

 		synchronized ExportEndpoint getExportEndpoint(

 				ServiceReference serviceReference, ID containerID) {

-			return match(serviceReference, containerID) ? exportEndpoint : null;

+			return match(serviceReference, containerID) ? exportReference

+					.getExportEndpoint() : null;

 		}

 

-		synchronized IRemoteServiceRegistration getRemoteServiceRegistration() {

-			return (exportEndpoint == null) ? null : exportEndpoint

-					.getRemoteServiceRegistration();

+		IRemoteServiceRegistration getRemoteServiceRegistration() {

+			return exportReference.getRemoteServiceRegistration();

 		}

 

-		synchronized EndpointDescription getEndpointDescription() {

-			return (exportEndpoint == null) ? null : exportEndpoint

-					.getEndpointDescription();

+		EndpointDescription getEndpointDescription() {

+			return exportReference.getEndpointDescription();

 		}

 

 		public void close() {

 			boolean publish = false;

-			Throwable t = null;

+			ID containerID = null;

+			Throwable exception = null;

 			EndpointDescription endpointDescription = null;

 			synchronized (this) {

 				// Only do this once

-				if (exportEndpoint != null) {

-					t = exportEndpoint.getException();

-					endpointDescription = exportEndpoint

-							.getEndpointDescription();

-					publish = exportEndpoint.close(this);

-					exportEndpoint = null;

-					exportReference.close();

-					removeExportRegistration(this);

+				if (!closed) {

+					containerID = getContainerID();

+					exception = getException();

+					endpointDescription = getEndpointDescription();

+					publish = exportReference.close(this);

+					closed = true;

 				}

 			}

+			removeExportRegistration(this);

 			Bundle rsaBundle = getRSABundle();

 			// Only publish events

 			if (publish && rsaBundle != null)

-				publishEvent(

-						new RemoteServiceAdminEvent(

-								endpointDescription.getContainerID(),

-								RemoteServiceAdminEvent.EXPORT_UNREGISTRATION,

-								rsaBundle, exportReference, t),

+				publishEvent(new RemoteServiceAdminEvent(containerID,

+						RemoteServiceAdminEvent.EXPORT_UNREGISTRATION,

+						rsaBundle, exportReference, exception),

 						endpointDescription);

 		}

 

-		public synchronized Throwable getException() {

-			return (exportEndpoint == null) ? null : exportEndpoint

-					.getException();

-		}

-

-		public synchronized String toString() {

-			return "ExportRegistration[exportEndpoint=" + exportEndpoint + "]"; //$NON-NLS-1$ //$NON-NLS-2$

+		public Throwable getException() {

+			return exportReference.getException();

 		}

 

 	}

@@ -632,31 +654,63 @@
 	class ExportReference implements

 			org.osgi.service.remoteserviceadmin.ExportReference {

 

-		private ServiceReference serviceReference;

-		private EndpointDescription endpointDescription;

+		private ExportEndpoint exportEndpoint;

 

-		ExportReference(ServiceReference serviceReference,

-				EndpointDescription endpointDescription) {

-			this.serviceReference = serviceReference;

-			this.endpointDescription = endpointDescription;

+		private Throwable exception;

+		private EndpointDescription errorEndpointDescription;

+

+		ExportReference(ExportEndpoint exportEndpoint) {

+			Assert.isNotNull(exportEndpoint);

+			this.exportEndpoint = exportEndpoint;

+		}

+

+		ExportReference(Throwable exception,

+				EndpointDescription errorEndpointDescription) {

+			Assert.isNotNull(exception);

+			this.exception = exception;

+			Assert.isNotNull(exception);

+			this.errorEndpointDescription = errorEndpointDescription;

+		}

+

+		synchronized Throwable getException() {

+			return exception;

+		}

+

+		synchronized boolean close(ExportRegistration exportRegistration) {

+			if (exportEndpoint == null)

+				return false;

+			boolean result = exportEndpoint.close(exportRegistration);

+			exportEndpoint = null;

+			return result;

+		}

+

+		synchronized ExportEndpoint getExportEndpoint() {

+			return exportEndpoint;

+		}

+

+		synchronized IRemoteServiceRegistration getRemoteServiceRegistration() {

+			return (exportEndpoint == null) ? null : exportEndpoint

+					.getRemoteServiceRegistration();

+		}

+

+		synchronized ID getContainerID() {

+			return (exportEndpoint == null) ? null : exportEndpoint

+					.getContainerID();

 		}

 

 		public synchronized ServiceReference getExportedService() {

-			return serviceReference;

+			return (exportEndpoint == null) ? null : exportEndpoint

+					.getServiceReference();

 		}

 

 		public synchronized org.osgi.service.remoteserviceadmin.EndpointDescription getExportedEndpoint() {

-			return endpointDescription;

+			return (exportEndpoint == null) ? null : exportEndpoint

+					.getEndpointDescription();

 		}

 

-		synchronized void close() {

-			this.serviceReference = null;

-			this.endpointDescription = null;

-		}

-

-		public synchronized String toString() {

-			return "ExportReference[serviceReference=" + serviceReference //$NON-NLS-1$

-					+ ", endpointDescription=" + endpointDescription + "]"; //$NON-NLS-1$ //$NON-NLS-2$

+		synchronized EndpointDescription getEndpointDescription() {

+			return (exportEndpoint == null) ? errorEndpointDescription

+					: exportEndpoint.getEndpointDescription();

 		}

 

 	}

@@ -668,9 +722,7 @@
 		private IRemoteServiceListener rsListener;

 		private IRemoteServiceReference rsReference;

 		private ServiceRegistration proxyRegistration;

-		private Set<ImportRegistration> importRegistrations = new HashSet<ImportRegistration>();

-

-		private Throwable exception;

+		private Set<ImportRegistration> activeImportRegistrations = new HashSet<ImportRegistration>();

 

 		ImportEndpoint(IRemoteServiceContainerAdapter rsContainerAdapter,

 				IRemoteServiceReference rsReference,

@@ -690,13 +742,6 @@
 			this.rsContainerAdapter.addRemoteServiceListener(this.rsListener);

 		}

 

-		ImportEndpoint(IRemoteServiceContainerAdapter rsContainerAdapter,

-				EndpointDescription endpointDescription, Throwable t) {

-			this.rsContainerAdapter = rsContainerAdapter;

-			this.endpointDescription = endpointDescription;

-			this.exception = t;

-		}

-

 		synchronized EndpointDescription getEndpointDescription() {

 			return endpointDescription;

 		}

@@ -705,22 +750,19 @@
 			return proxyRegistration;

 		}

 

-		synchronized Throwable getException() {

-			return exception;

-		}

-

 		synchronized ID getContainerID() {

 			return (rsReference == null) ? null : rsReference.getContainerID();

 		}

 

-		synchronized boolean add(ImportRegistration importRegistration) {

-			return this.importRegistrations.add(importRegistration);

+		synchronized boolean addImportRegistration(

+				ImportRegistration importRegistration) {

+			return this.activeImportRegistrations.add(importRegistration);

 		}

 

 		synchronized boolean close(ImportRegistration importRegistration) {

-			boolean removed = this.importRegistrations

+			boolean removed = this.activeImportRegistrations

 					.remove(importRegistration);

-			if (removed && importRegistrations.size() == 0) {

+			if (removed && activeImportRegistrations.size() == 0) {

 				if (proxyRegistration != null) {

 					proxyRegistration.unregister();

 					proxyRegistration = null;

@@ -749,13 +791,8 @@
 			return rsReference.getID().equals(remoteServiceID);

 		}

 

-		public synchronized String toString() {

-			return "ImportEndpoint[rsReference=" + rsReference //$NON-NLS-1$

-					+ ", proxyRegistration=" + proxyRegistration + "]"; //$NON-NLS-1$ //$NON-NLS-2$

-		}

-

 		synchronized boolean match(EndpointDescription ed) {

-			if (importRegistrations.size() == 0)

+			if (activeImportRegistrations.size() == 0)

 				return false;

 			return this.endpointDescription.isSameService(ed);

 		}

@@ -765,43 +802,39 @@
 	class ImportRegistration implements

 			org.osgi.service.remoteserviceadmin.ImportRegistration {

 

-		private ImportEndpoint importEndpoint;

 		private ImportReference importReference;

 

+		private boolean closed = false;

+

 		ImportRegistration(ImportEndpoint importEndpoint) {

-			this.importEndpoint = importEndpoint;

-			this.importEndpoint.add(this);

-			ServiceRegistration sr = this.importEndpoint.getProxyRegistration();

-			EndpointDescription ed = this.importEndpoint

-					.getEndpointDescription();

-			this.importReference = new ImportReference(sr.getReference(), ed);

+			Assert.isNotNull(importEndpoint);

+			importEndpoint.addImportRegistration(this);

+			this.importReference = new ImportReference(importEndpoint);

 		}

 

-		synchronized ID getContainerID() {

-			return importEndpoint == null ? null : importEndpoint

-					.getContainerID();

+		ImportRegistration(EndpointDescription errorEndpointDescription,

+				Throwable exception) {

+			this.importReference = new ImportReference(

+					errorEndpointDescription, exception);

 		}

 

-		synchronized EndpointDescription getEndpointDescription() {

-			return (importEndpoint == null) ? null : importEndpoint

-					.getEndpointDescription();

+		ID getContainerID() {

+			return importReference.getContainerID();

 		}

 

-		synchronized boolean match(IRemoteServiceID remoteServiceID) {

-			if (importEndpoint == null)

-				return false;

-			return importEndpoint.match(remoteServiceID);

+		EndpointDescription getEndpointDescription() {

+			return importReference.getEndpointDescription();

 		}

 

-		synchronized ImportEndpoint getImportEndpoint(EndpointDescription ed) {

-			if (importEndpoint == null)

-				return null;

-			if (importEndpoint.match(ed))

-				return importEndpoint;

-			return null;

+		boolean match(IRemoteServiceID remoteServiceID) {

+			return importReference.match(remoteServiceID);

 		}

 

-		public synchronized org.osgi.service.remoteserviceadmin.ImportReference getImportReference() {

+		ImportEndpoint getImportEndpoint(EndpointDescription ed) {

+			return importReference.match(ed);

+		}

+

+		public org.osgi.service.remoteserviceadmin.ImportReference getImportReference() {

 			Throwable t = getException();

 			if (t != null)

 				throw new IllegalStateException(

@@ -811,38 +844,34 @@
 		}

 

 		public void close() {

+			boolean publish = false;

+			ID containerID = null;

 			Throwable exception = null;

 			EndpointDescription endpointDescription = null;

-			boolean publish = false;

 			synchronized (this) {

-				if (importEndpoint != null) {

-					exception = importEndpoint.getException();

-					endpointDescription = importEndpoint

-							.getEndpointDescription();

-					publish = importEndpoint.close(this);

-					importEndpoint = null;

-					importReference.close();

-					removeImportRegistration(this);

+				// only do this once

+				if (!closed) {

+					containerID = getContainerID();

+					exception = getException();

+					endpointDescription = getEndpointDescription();

+					publish = importReference.close(this);

+					closed = true;

 				}

 			}

+			removeImportRegistration(this);

 			Bundle rsaBundle = getRSABundle();

 			if (publish && rsaBundle != null)

 				publishEvent(

 						new RemoteServiceAdminEvent(

-								endpointDescription.getContainerID(),

+								containerID,

 								RemoteServiceAdminEvent.IMPORT_UNREGISTRATION,

 								rsaBundle, importReference, exception),

 						endpointDescription);

 

 		}

 

-		public synchronized Throwable getException() {

-			return (importEndpoint == null) ? null : importEndpoint

-					.getException();

-		}

-

-		public synchronized String toString() {

-			return "ImportRegistration[importEndpoint=" + importEndpoint + "]"; //$NON-NLS-1$ //$NON-NLS-2$

+		public Throwable getException() {

+			return importReference.getException();

 		}

 

 	}

@@ -850,32 +879,65 @@
 	class ImportReference implements

 			org.osgi.service.remoteserviceadmin.ImportReference {

 

-		private ServiceReference importedServiceReference;

-		private EndpointDescription endpointDescription;

+		private ImportEndpoint importEndpoint;

 

-		ImportReference(ServiceReference serviceReference,

-				EndpointDescription endpointDescription) {

-			this.importedServiceReference = serviceReference;

-			this.endpointDescription = endpointDescription;

+		private Throwable exception;

+		private EndpointDescription errorEndpointDescription;

+

+		ImportReference(ImportEndpoint importEndpoint) {

+			Assert.isNotNull(importEndpoint);

+			this.importEndpoint = importEndpoint;

+		}

+

+		ImportReference(EndpointDescription endpointDescription,

+				Throwable exception) {

+			Assert.isNotNull(exception);

+			this.exception = exception;

+			Assert.isNotNull(endpointDescription);

+			this.errorEndpointDescription = endpointDescription;

+		}

+

+		synchronized Throwable getException() {

+			return exception;

+		}

+

+		synchronized boolean match(IRemoteServiceID remoteServiceID) {

+			return (importEndpoint == null) ? null : importEndpoint

+					.match(remoteServiceID);

+		}

+

+		synchronized ImportEndpoint match(EndpointDescription ed) {

+			if (importEndpoint != null && importEndpoint.match(ed))

+				return importEndpoint;

+			return null;

+		}

+

+		synchronized EndpointDescription getEndpointDescription() {

+			return (importEndpoint == null) ? errorEndpointDescription

+					: importEndpoint.getEndpointDescription();

+		}

+

+		synchronized ID getContainerID() {

+			return (importEndpoint == null) ? null : importEndpoint

+					.getContainerID();

 		}

 

 		public synchronized ServiceReference getImportedService() {

-			return importedServiceReference;

+			return (importEndpoint == null) ? null : importEndpoint

+					.getProxyRegistration().getReference();

 		}

 

 		public synchronized org.osgi.service.remoteserviceadmin.EndpointDescription getImportedEndpoint() {

-			return endpointDescription;

+			return (importEndpoint == null) ? null : importEndpoint

+					.getEndpointDescription();

 		}

 

-		synchronized void close() {

-			this.importedServiceReference = null;

-			this.endpointDescription = null;

-		}

-

-		public synchronized String toString() {

-			return "ImportReference[importedServiceReference=" //$NON-NLS-1$

-					+ importedServiceReference + ", endpointDescription=" //$NON-NLS-1$

-					+ endpointDescription + "]"; //$NON-NLS-1$

+		synchronized boolean close(ImportRegistration importRegistration) {

+			if (importEndpoint == null)

+				return false;

+			boolean result = importEndpoint.close(importRegistration);

+			importEndpoint = null;

+			return result;

 		}

 

 	}

@@ -1279,7 +1341,7 @@
 		// for the exporting ECF container

 		endpointDescriptionProperties

 				.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,

-						RemoteConstants.ENDPOINT_SERVICE_IMPORTED_CONFIGS_VALUE);

+						remoteConfigsSupported);

 

 		// SERVICE_INTENTS

 		Object intents = PropertiesUtil

@@ -1336,8 +1398,9 @@
 			endpointDescriptionProperties.put(

 					RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER, rsFilter);

 

-		return endpointDescriptionProperties;

-

+		// Finally, copy all non-reserved properties

+		return PropertiesUtil.copyNonReservedProperties(overridingProperties,

+				endpointDescriptionProperties);

 	}

 

 	private Map<String, Object> copyNonReservedProperties(

@@ -1825,14 +1888,10 @@
 		return resultProperties;

 	}

 

-	private ExportEndpoint exportService(ServiceReference serviceReference,

+	private ExportRegistration exportService(ServiceReference serviceReference,

 			Map<String, Object> overridingProperties,

-			String[] exportedInterfaces, String[] serviceIntents,

-			IRemoteServiceContainer rsContainer) {

-

-		Map endpointDescriptionProperties = createExportEndpointDescriptionProperties(

-				serviceReference, overridingProperties, exportedInterfaces,

-				serviceIntents, rsContainer);

+			String[] exportedInterfaces, IRemoteServiceContainer rsContainer,

+			Map<String, Object> endpointDescriptionProperties) throws Exception {

 

 		// Create remote service properties

 		Map remoteServiceProperties = copyNonReservedProperties(

@@ -1845,46 +1904,29 @@
 		// Register remote service via ECF container adapter to create

 		// remote service registration

 		IRemoteServiceRegistration remoteRegistration = null;

-		Throwable exception = null;

-		try {

-			// Check security access for export

-			checkEndpointPermission(new EndpointDescription(serviceReference,

-					endpointDescriptionProperties), EndpointPermission.EXPORT);

-

-			if (containerAdapter instanceof IOSGiRemoteServiceContainerAdapter) {

-				IOSGiRemoteServiceContainerAdapter osgiContainerAdapter = (IOSGiRemoteServiceContainerAdapter) containerAdapter;

-				remoteRegistration = osgiContainerAdapter

-						.registerRemoteService(

-								exportedInterfaces,

-								serviceReference,

-								PropertiesUtil

-										.createDictionaryFromMap(remoteServiceProperties));

-			} else

-				remoteRegistration = containerAdapter

-						.registerRemoteService(

-								exportedInterfaces,

-								getClientBundleContext().getService(

-										serviceReference),

-								PropertiesUtil

-										.createDictionaryFromMap(remoteServiceProperties));

-			endpointDescriptionProperties

-					.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID,

-							remoteRegistration

-									.getProperty(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID));

-		} catch (Exception e) {

-			exception = e;

-			if (remoteRegistration != null)

-				remoteRegistration.unregister();

-		}

+		if (containerAdapter instanceof IOSGiRemoteServiceContainerAdapter) {

+			IOSGiRemoteServiceContainerAdapter osgiContainerAdapter = (IOSGiRemoteServiceContainerAdapter) containerAdapter;

+			remoteRegistration = osgiContainerAdapter.registerRemoteService(

+					exportedInterfaces, serviceReference, PropertiesUtil

+							.createDictionaryFromMap(remoteServiceProperties));

+		} else

+			remoteRegistration = containerAdapter.registerRemoteService(

+					exportedInterfaces,

+					getClientBundleContext().getService(serviceReference),

+					PropertiesUtil

+							.createDictionaryFromMap(remoteServiceProperties));

+		endpointDescriptionProperties

+				.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID,

+						remoteRegistration

+								.getProperty(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID));

 		EndpointDescription endpointDescription = new EndpointDescription(

 				serviceReference, endpointDescriptionProperties);

 		// Create ExportEndpoint/ExportRegistration

-		return (exception == null) ? new ExportEndpoint(serviceReference,

-				endpointDescription, remoteRegistration) : new ExportEndpoint(

-				serviceReference, endpointDescription, exception);

+		return new ExportRegistration(new ExportEndpoint(serviceReference,

+				endpointDescription, remoteRegistration));

 	}

 

-	private ImportEndpoint importService(

+	private ImportRegistration importService(

 			EndpointDescription endpointDescription,

 			IRemoteServiceContainer rsContainer) {

 		trace("doImportService", "endpointDescription=" + endpointDescription //$NON-NLS-1$ //$NON-NLS-2$

@@ -1942,8 +1984,8 @@
 				throw new RemoteReferenceNotFoundException(targetID, idFilter,

 						interfaces, rsFilter);

 

-			return createAndRegisterProxy(endpointDescription, rsContainer,

-					selectedRsReference);

+			return new ImportRegistration(createAndRegisterProxy(

+					endpointDescription, rsContainer, selectedRsReference));

 		} catch (Exception e) {

 			logError(

 					"importService", "selectRemoteServiceReference returned null for rsRefs=" //$NON-NLS-1$

@@ -1951,7 +1993,7 @@
 							+ ",idFilter=" + idFilter + ",interfaces=" //$NON-NLS-1$ //$NON-NLS-2$

 							+ interfaces + ",rsFilter=" + rsFilter //$NON-NLS-1$

 							+ ",rsContainerID=" + rsContainerID, e);

-			return new ImportEndpoint(containerAdapter, endpointDescription, e);

+			return new ImportRegistration(endpointDescription, e);

 		}

 	}

 

diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/SelectContainerException.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/SelectContainerException.java
new file mode 100644
index 0000000..2af93fd
--- /dev/null
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/SelectContainerException.java
@@ -0,0 +1,20 @@
+package org.eclipse.ecf.osgi.services.remoteserviceadmin;

+

+import org.eclipse.ecf.core.ContainerTypeDescription;

+

+public class SelectContainerException extends Exception {

+

+	private static final long serialVersionUID = -5507248105370677422L;

+

+	private ContainerTypeDescription containerTypeDescription;

+

+	public SelectContainerException(String message, Throwable cause,

+			ContainerTypeDescription containerTypeDescription) {

+		super(message, cause);

+		this.containerTypeDescription = containerTypeDescription;

+	}

+

+	public ContainerTypeDescription getContainerTypeDescription() {

+		return containerTypeDescription;

+	}

+}