private Map<String, Object> createExportEndpointDescriptionProperties(
ServiceReference serviceReference,
Map<String, Object> overridingProperties,
String[] exportedInterfaces, String[] serviceIntents,
IRemoteServiceContainer rsContainer) {
IContainer container = rsContainer.getContainer();
ID containerID = container.getID();
Map<String, Object> endpointDescriptionProperties = new TreeMap<String, Object>(
String.CASE_INSENSITIVE_ORDER);
// OSGi properties
// OBJECTCLASS set to exportedInterfaces
endpointDescriptionProperties.put(
org.osgi.framework.Constants.OBJECTCLASS, exportedInterfaces);
// Service interface versions
for (int i = 0; i < exportedInterfaces.length; i++) {
String packageName = getPackageName(exportedInterfaces[i]);
String packageVersionKey = org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_
+ packageName;
// If it's pre-set...by registration or by overridingProperties,
// then use that value
String packageVersion = (String) PropertiesUtil.getPropertyValue(
serviceReference, overridingProperties, packageVersionKey);
if (packageVersion == null) {
Version version = getPackageVersion(serviceReference,
exportedInterfaces[i], packageName);
if (version != null && !version.equals(Version.emptyVersion))
packageVersion = version.toString();
}
// Only set the package version if we have a non-null value
if (packageVersion != null)
endpointDescriptionProperties.put(packageVersionKey,
packageVersion);
}
// ENDPOINT_ID
String endpointId = (String) PropertiesUtil
.getPropertyValue(
serviceReference,
overridingProperties,
org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID);
if (endpointId == null)
endpointId = UUID.randomUUID().toString();
endpointDescriptionProperties
.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID,
endpointId);
// ECF ENDPOINT ID
String ecfEndpointId = (String) PropertiesUtil.getPropertyValue(
serviceReference, overridingProperties,
RemoteConstants.ENDPOINT_ID);
if (ecfEndpointId == null)
ecfEndpointId = containerID.getName();
endpointDescriptionProperties.put(RemoteConstants.ENDPOINT_ID,
ecfEndpointId);
// ENDPOINT_SERVICE_ID
// This is always set to the value from serviceReference as per 122.5.1
Long serviceId = (Long) serviceReference
.getProperty(org.osgi.framework.Constants.SERVICE_ID);
endpointDescriptionProperties.put(
org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID, serviceId);
// ENDPOINT_FRAMEWORK_ID
String frameworkId = (String) PropertiesUtil
.getPropertyValue(
serviceReference,
overridingProperties,
org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID);
if (frameworkId == null)
frameworkId = Activator.getDefault().getFrameworkUUID();
endpointDescriptionProperties
.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID,
frameworkId);
// REMOTE_CONFIGS_SUPPORTED
String[] remoteConfigsSupported = getSupportedConfigs(container.getID());
if (remoteConfigsSupported != null)
endpointDescriptionProperties
.put(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED,
remoteConfigsSupported);
// SERVICE_IMPORTED_CONFIGS...set to constant value for all ECF
// providers
// supported (which is computed
// for the exporting ECF container
endpointDescriptionProperties
.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,
remoteConfigsSupported);
// SERVICE_INTENTS
Object intents = PropertiesUtil
.getPropertyValue(
null,
overridingProperties,
org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS);
if (intents == null)
intents = serviceIntents;
if (intents != null)
endpointDescriptionProperties
.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS,
intents);
// REMOTE_INTENTS_SUPPORTED
String[] remoteIntentsSupported = getSupportedIntents(container.getID());
if (remoteIntentsSupported != null)
endpointDescriptionProperties
.put(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED,
remoteIntentsSupported);
// ECF properties
// ID namespace
String idNamespace = containerID.getNamespace().getName();
endpointDescriptionProperties.put(
RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE, idNamespace);
// timestamp
endpointDescriptionProperties.put(RemoteConstants.ENDPOINT_TIMESTAMP, System.currentTimeMillis());
// ENDPOINT_CONNECTTARGET_ID
String connectTarget = (String) PropertiesUtil.getPropertyValue(
serviceReference, overridingProperties,
RemoteConstants.ENDPOINT_CONNECTTARGET_ID);
if (connectTarget == null && isClient(container)) {
ID connectedID = container.getConnectedID();
if (connectedID != null && !connectedID.equals(containerID))
connectTarget = connectedID.getName();
}
if (connectTarget != null)
endpointDescriptionProperties.put(