Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/osgi
diff options
context:
space:
mode:
authorslewis2018-03-13 14:03:21 -0400
committerslewis2018-03-13 14:03:21 -0400
commiteb1a4ff73d8860fb04ff5051ffb178cb6bc5d926 (patch)
treee588c702a95d6f8bc4031b28666d0c1173d9eb8a /osgi
parent2e67e4c37bea37d8f1fdb27455a3ceeac097d3ba (diff)
downloadorg.eclipse.ecf-eb1a4ff73d8860fb04ff5051ffb178cb6bc5d926.tar.gz
org.eclipse.ecf-eb1a4ff73d8860fb04ff5051ffb178cb6bc5d926.tar.xz
org.eclipse.ecf-eb1a4ff73d8860fb04ff5051ffb178cb6bc5d926.zip
Dependency fixes for bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=532205 Adds support for osgi.private in ecf generic, ecf ssl, and rosgi providers, as well as a framework in ecf core and rsa impl for any other distribution providers. Change-Id: I5cacab08ba5b6fe63b8550fdb70eb8d6d1357977
Diffstat (limited to 'osgi')
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF1
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractContainerSelector.java81
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java75
3 files changed, 139 insertions, 18 deletions
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
index 81b83701c..efd5a7ddd 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/META-INF/MANIFEST.MF
@@ -17,6 +17,7 @@ Import-Package: javax.xml.parsers,
org.eclipse.ecf.core.events;version="[3.1.0,4.0.0)",
org.eclipse.ecf.core.identity;version="[3.2.0,4.0.0)",
org.eclipse.ecf.core.jobs;version="[1.1.0,2.0.0)",
+ org.eclipse.ecf.core.provider;version="[3.2.0,4.0.0)",
org.eclipse.ecf.core.security;version="[3.1.0,4.0.0)",
org.eclipse.ecf.core.util;version="[3.2.0,4.0.0)",
org.eclipse.ecf.discovery;version="[4.1.0,5.0.0)",
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 59916440b..e6b5622b4 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
@@ -12,6 +12,7 @@ package org.eclipse.ecf.osgi.services.remoteserviceadmin;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -23,6 +24,7 @@ import org.eclipse.ecf.core.IContainerFactory;
import org.eclipse.ecf.core.IContainerManager;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.provider.ContainerIntentException;
import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator;
import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
@@ -32,6 +34,7 @@ import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
import org.eclipse.ecf.remoteservice.RemoteServiceContainer;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
/**
@@ -129,11 +132,28 @@ public abstract class AbstractContainerSelector {
Map<String, Object> properties,
ContainerTypeDescription containerTypeDescription)
throws SelectContainerException {
+
+ return createContainer(serviceReference, properties, containerTypeDescription, null);
+ }
+
+ /**
+ * @param serviceReference serviceReference
+ * @param properties overriding properties
+ * @param containerTypeDescription containerTypeDescription
+ * @param intents intents
+ * @return IContainer created container. May be null if instance cannot be created (e.g. because of intent requirements)
+ * @throws SelectContainerException thrown if some create or configure failure
+ * @since 4.6
+ */
+ protected IContainer createContainer(ServiceReference serviceReference,
+ Map<String, Object> properties,
+ ContainerTypeDescription containerTypeDescription, String[] intents)
+ throws SelectContainerException {
IContainerFactory containerFactory = getContainerFactory();
final Object containerFactoryArguments = getContainerFactoryArguments(
- serviceReference, properties, containerTypeDescription);
+ serviceReference, properties, containerTypeDescription, intents);
try {
if (containerFactoryArguments instanceof String) {
@@ -155,12 +175,17 @@ public abstract class AbstractContainerSelector {
}
return containerFactory.createContainer(containerTypeDescription);
} catch (ContainerCreateException e) {
- throw new SelectContainerException(
+ if (e instanceof ContainerIntentException) {
+ LogUtility.logWarning("createContainer", DebugOptions.CONTAINER_SELECTOR, this.getClass(), "Container does not satisfy required intent="+((ContainerIntentException) e).getIntentName(),e); //$NON-NLS-1$ //$NON-NLS-2$
+ return null;
+ } else
+ throw new SelectContainerException(
"Exception creating or configuring container", e, //$NON-NLS-1$
containerTypeDescription);
}
}
+
/**
* @param serviceReference serviceReference
* @param properties overriding properties
@@ -171,19 +196,67 @@ public abstract class AbstractContainerSelector {
protected Object getContainerFactoryArguments(
ServiceReference serviceReference, Map<String, Object> properties,
ContainerTypeDescription containerTypeDescription) {
+ return getContainerFactoryArguments(serviceReference, properties, containerTypeDescription, null);
+ }
+
+ /**
+ * @param serviceReference serviceReference
+ * @param properties overriding properties
+ * @param containerTypeDescription containerTypeDescription
+ * @param intents intents
+ * @return Object container factory arguments to use
+ * @since 4.6
+ */
+ protected Object getContainerFactoryArguments(
+ ServiceReference serviceReference, Map<String, Object> properties,
+ ContainerTypeDescription containerTypeDescription, String[] intents) {
// 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 != null)
return containerFactoryArguments;
-
+ // Else we return Map as is required for RSA container creation
+ Map<String, Object> results = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
+ // Put the service intents (e.g. osgi.private) into the results map
+ if (intents != null)
+ results.put(Constants.SERVICE_INTENTS, intents);
+ // This iterates through the service Reference properties...if the property starts with
+ // any of the service intent names (e.g. osgi.basic.timeout) then the property is
+ // added to the results map
+ if (intents != null)
+ for (String propName : serviceReference.getPropertyKeys()) {
+ Object value = null;
+ for (String intent : intents) {
+ if (propName.startsWith(intent + ".")) //$NON-NLS-1$
+ value = serviceReference.getProperty(propName);
+ }
+ if (value != null)
+ results.put(propName, value);
+ }
+ // This iterates through the properties map...if the property starts with
+ // any of the service intent names (e.g. osgi.basic.timeout) then the property is
+ // added to the results map
+ if (intents != null)
+ for (String propName : properties.keySet()) {
+ Object value = null;
+ for (String intent : intents) {
+ if (propName.startsWith(intent + ".")) //$NON-NLS-1$
+ value = properties.get(propName);
+ }
+ if (value != null)
+ results.put(propName, value);
+ }
+ // Add any config properties
String exportedConfig = containerTypeDescription.getName();
// If not, then we look through the properties that start with
// <containerTypeDescription.name>.
- Map<String, Object> results = PropertiesUtil.getConfigProperties(exportedConfig, properties);
+ Map<String, Object> configProperties = PropertiesUtil.getConfigProperties(exportedConfig, properties);
+ results = PropertiesUtil.mergeProperties(results, configProperties);
+
if (results.size() == 0)
return null;
+
return results;
}
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 a27301d3c..19a352c79 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
@@ -23,6 +23,8 @@ import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.provider.ContainerInstantiatorUtils;
+import org.eclipse.ecf.core.provider.ContainerIntentException;
import org.eclipse.ecf.core.security.IConnectContext;
import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.IDUtil;
import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
@@ -168,7 +170,7 @@ public abstract class AbstractHostContainerSelector extends
return matchHostSupportedConfigTypes(requiredConfigTypes, description)
&& matchHostSupportedIntents(requiredServiceIntents,
- description)
+ description, container)
&& matchHostContainerID(serviceReference, properties, container)
&& matchHostContainerToConnectTarget(serviceReference,
properties, container);
@@ -260,7 +262,7 @@ public abstract class AbstractHostContainerSelector extends
protected Collection createAndConfigureHostContainers(
ServiceReference serviceReference, Map<String, Object> properties,
String[] serviceExportedInterfaces, String[] requiredConfigs,
- String[] requiredIntents) throws SelectContainerException {
+ String[] serviceIntents) throws SelectContainerException {
List results = new ArrayList();
ContainerTypeDescription[] descriptions = getContainerTypeDescriptions();
@@ -269,7 +271,7 @@ public abstract class AbstractHostContainerSelector extends
// If there are no required configs specified, then create any defaults
if (requiredConfigs == null || requiredConfigs.length == 0) {
createAndAddDefaultContainers(serviceReference, properties,
- serviceExportedInterfaces, requiredIntents, descriptions,
+ serviceExportedInterfaces, serviceIntents, descriptions,
results);
} else {
// See if we have a match
@@ -277,7 +279,7 @@ public abstract class AbstractHostContainerSelector extends
IRemoteServiceContainer matchingContainer = createMatchingContainer(
descriptions[i], serviceReference, properties,
serviceExportedInterfaces, requiredConfigs,
- requiredIntents);
+ serviceIntents);
if (matchingContainer != null)
results.add(matchingContainer);
}
@@ -350,14 +352,14 @@ public abstract class AbstractHostContainerSelector extends
ContainerTypeDescription containerTypeDescription,
ServiceReference serviceReference, Map<String, Object> properties,
String[] serviceExportedInterfaces, String[] requiredConfigs,
- String[] requiredIntents) throws SelectContainerException {
+ String[] serviceIntents) throws SelectContainerException {
if (matchHostSupportedConfigTypes(requiredConfigs,
containerTypeDescription)
- && matchHostSupportedIntents(requiredIntents,
+ && matchHostSupportedIntents(serviceIntents,
containerTypeDescription)) {
return createRSContainer(serviceReference, properties,
- containerTypeDescription);
+ containerTypeDescription, serviceIntents);
}
return null;
}
@@ -374,8 +376,25 @@ public abstract class AbstractHostContainerSelector extends
ServiceReference serviceReference, Map<String, Object> properties,
ContainerTypeDescription containerTypeDescription)
throws SelectContainerException {
+ return createRSContainer(serviceReference, properties, containerTypeDescription, null);
+ }
+
+ /**
+ * @param serviceReference serviceReference
+ * @param properties properties
+ * @param containerTypeDescription container type description
+ * @return IRemoteServiceContainer created remote service container
+ * @throws SelectContainerException if could not be created
+ * @since 4.6
+ */
+ protected IRemoteServiceContainer createRSContainer(
+ ServiceReference serviceReference, Map<String, Object> properties,
+ ContainerTypeDescription containerTypeDescription, String[] intents)
+ throws SelectContainerException {
IContainer container = createContainer(serviceReference, properties,
- containerTypeDescription);
+ containerTypeDescription, intents);
+ if (container == null)
+ return null;
IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container
.getAdapter(IRemoteServiceContainerAdapter.class);
if (adapter == null)
@@ -384,6 +403,7 @@ public abstract class AbstractHostContainerSelector extends
return new RemoteServiceContainer(container, adapter);
}
+
/**
* @param serviceReference service reference
* @param properties properties
@@ -414,6 +434,15 @@ public abstract class AbstractHostContainerSelector extends
protected boolean matchHostSupportedIntents(
String[] serviceRequiredIntents,
ContainerTypeDescription containerTypeDescription) {
+ return matchHostSupportedIntents(serviceRequiredIntents, containerTypeDescription, null);
+ }
+
+ /**
+ * @since 4.6
+ */
+ protected boolean matchHostSupportedIntents(
+ String[] serviceRequiredIntents,
+ ContainerTypeDescription containerTypeDescription, IContainer container) {
// If there are no required intents then we have a match
if (serviceRequiredIntents == null)
return true;
@@ -422,14 +451,32 @@ public abstract class AbstractHostContainerSelector extends
if (supportedIntents == null)
return false;
-
- List supportedIntentsList = Arrays.asList(supportedIntents);
-
+ // checks to see that containerTypeDescription supports requiredIntents
boolean result = true;
- for (int i = 0; i < serviceRequiredIntents.length; i++)
- result = result
- && supportedIntentsList.contains(serviceRequiredIntents[i]);
+ for (int i = 0; i < serviceRequiredIntents.length; i++) {
+ boolean found = false;
+ for(String supportedIntent: supportedIntents)
+ if (serviceRequiredIntents[i].equals(supportedIntent) || serviceRequiredIntents[i].startsWith(supportedIntent+".")) {//$NON-NLS-1$
+ found = true;
+ break;
+ }
+ result &= found;
+ }
+ if (!result)
+ return false;
+
+ // If container is non-null,
+ // check to see that it's ID is private. If it's not private, return null
+ if (container != null) {
+ try {
+ if (ContainerInstantiatorUtils.containsPrivateIntent(serviceRequiredIntents))
+ ContainerInstantiatorUtils.checkPrivate(container.getID());
+ } catch (ContainerIntentException e) {
+ return false;
+ }
+ }
+
return result;
}

Back to the top