Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2011-05-08 12:51:59 -0400
committerslewis2011-05-08 12:51:59 -0400
commitb1d116f37d46e22bc8a2374ac1bbaff108f5e740 (patch)
tree27639d53d2dc72286780103fe192d04a43ec2e06
parent90ba77baf40e3902ca144c2faccfd408b161cd35 (diff)
downloadorg.eclipse.ecf-b1d116f37d46e22bc8a2374ac1bbaff108f5e740.tar.gz
org.eclipse.ecf-b1d116f37d46e22bc8a2374ac1bbaff108f5e740.tar.xz
org.eclipse.ecf-b1d116f37d46e22bc8a2374ac1bbaff108f5e740.zip
Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=345075
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java18
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java48
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java34
3 files changed, 54 insertions, 46 deletions
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 6208de4c6..04ca0b60f 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
@@ -120,19 +120,19 @@ public class PropertiesUtil {
ServiceReference serviceReference, Object propValue) {
if (propValue == null)
return null;
+ String[] objectClass = (String[]) serviceReference
+ .getProperty(org.osgi.framework.Constants.OBJECTCLASS);
boolean wildcard = propValue.equals("*"); //$NON-NLS-1$
if (wildcard)
- return (String[]) serviceReference
- .getProperty(org.osgi.framework.Constants.OBJECTCLASS);
+ return objectClass;
else {
- final String[] stringValue = getStringArrayFromPropertyValue(propValue);
- if (stringValue != null && stringValue.length == 1
- && stringValue[0].equals("*")) { //$NON-NLS-1$
+ final String[] stringArrayValue = getStringArrayFromPropertyValue(propValue);
+ if (stringArrayValue == null) return null;
+ else if (stringArrayValue.length == 1
+ && stringArrayValue[0].equals("*")) { //$NON-NLS-1$
// this will support the idiom: new String[] { "*" }
- return (String[]) serviceReference
- .getProperty(org.osgi.framework.Constants.OBJECTCLASS);
- }
- return stringValue;
+ return objectClass;
+ } else return stringArrayValue;
}
}
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 be580b35f..17cceeb9f 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
@@ -12,6 +12,7 @@ package org.eclipse.ecf.osgi.services.remoteserviceadmin;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -233,50 +234,35 @@ public abstract class AbstractHostContainerSelector extends
List results = new ArrayList();
ContainerTypeDescription[] descriptions = getContainerTypeDescriptions();
if (descriptions == null)
- return results;
+ return Collections.EMPTY_LIST;
// If there are no required configs specified, then create any defaults
if (requiredConfigs == null || requiredConfigs.length == 0) {
- ContainerTypeDescription[] ctds = getContainerTypeDescriptionsForDefaultConfigTypes(descriptions);
- if (ctds != null) {
- for (int i = 0; i < ctds.length; i++) {
- IRemoteServiceContainer rsContainer = createRSContainer(
- serviceReference, properties, ctds[i]);
- if (rsContainer != null)
- results.add(rsContainer);
- }
- }
+ createAndAddDefaultContainers(serviceReference, properties, serviceExportedInterfaces, requiredIntents, descriptions, results);
} else {
// See if we have a match
for (int i = 0; i < descriptions.length; i++) {
- IRemoteServiceContainer rsContainer = createMatchingContainer(
+ IRemoteServiceContainer matchingContainer = createMatchingContainer(
descriptions[i], serviceReference, properties,
serviceExportedInterfaces, requiredConfigs,
requiredIntents);
- if (rsContainer != null)
- results.add(rsContainer);
- }
- }
- // we still haven't created one then we check for no default and if
- // not present then we
- // create default ones
- if (results.size() == 0 && requiredConfigs != null
- && requiredConfigs.length > 0) {
- List requiredConfigsList = Arrays.asList(requiredConfigs);
- if (!requiredConfigsList.contains(NODEFAULT)) {
- ContainerTypeDescription[] ctds = getContainerTypeDescriptionsForDefaultConfigTypes(descriptions);
- if (ctds != null) {
- for (int i = 0; i < ctds.length; i++) {
- IRemoteServiceContainer rsContainer = createRSContainer(
- serviceReference, properties, ctds[i]);
- if (rsContainer != null)
- results.add(rsContainer);
- }
- }
+ if (matchingContainer != null)
+ results.add(matchingContainer);
}
}
return results;
}
+ private void createAndAddDefaultContainers(ServiceReference serviceReference, Map<String, Object> properties, String[] serviceExportedInterfaces, String[] requiredIntents, ContainerTypeDescription[] descriptions, Collection results) {
+ 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);
+ if (matchingContainer != null)
+ results.add(matchingContainer);
+ }
+ }
+ }
+
protected ContainerTypeDescription[] getContainerTypeDescriptionsForDefaultConfigTypes(
ContainerTypeDescription[] descriptions) {
String[] defaultConfigTypes = getDefaultConfigTypes();
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 71bc6ce98..0c033925a 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
@@ -10,6 +10,7 @@
package org.eclipse.ecf.osgi.services.remoteserviceadmin;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -159,6 +160,13 @@ public class RemoteServiceAdmin implements
}
}
+ 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,
@@ -178,7 +186,10 @@ public class RemoteServiceAdmin implements
throw new IllegalArgumentException(
org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES
+ " not set"); //$NON-NLS-1$
-
+ // verifyExportedInterfaces
+ if (!validExportedInterfaces(serviceReference, exportedInterfaces)) return Collections.EMPTY_LIST;
+
+
// Get optional exported configs
String[] exportedConfigs = PropertiesUtil
.getStringArrayFromPropertyValue(overridingProperties
@@ -235,11 +246,11 @@ public class RemoteServiceAdmin implements
exportService(serviceReference,
overridingProperties, exportedInterfaces,
serviceIntents, rsContainers[i]));
- // If no exception, we add it to our known set of exported
- // registrations
- if (exportRegistration.getException() == null)
- addExportRegistration(exportRegistration);
}
+ // If no exception, we add it to our known set of exported
+ // registrations
+ if (exportRegistration.getException() == null)
+ addExportRegistration(exportRegistration);
// We add it to the results in either case
exportRegistrations.add(exportRegistration);
}
@@ -896,30 +907,39 @@ public class RemoteServiceAdmin implements
}
int eventType = event.getType();
String eventTypeName = null;
+ String registrationTypeName = null;
switch (eventType) {
case (RemoteServiceAdminEvent.EXPORT_REGISTRATION):
eventTypeName = "EXPORT_REGISTRATION"; //$NON-NLS-1$
+ registrationTypeName = "export.registration";//$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.EXPORT_ERROR):
eventTypeName = "EXPORT_ERROR"; //$NON-NLS-1$
+ registrationTypeName = "export.registration";//$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.EXPORT_UNREGISTRATION):
eventTypeName = "EXPORT_UNREGISTRATION"; //$NON-NLS-1$
+ registrationTypeName = "export.registration";//$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.EXPORT_WARNING):
eventTypeName = "EXPORT_WARNING"; //$NON-NLS-1$
+ registrationTypeName = "export.registration";//$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.IMPORT_REGISTRATION):
eventTypeName = "IMPORT_REGISTRATION"; //$NON-NLS-1$
+ registrationTypeName = "import.registration";//$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.IMPORT_ERROR):
eventTypeName = "IMPORT_ERROR"; //$NON-NLS-1$
+ registrationTypeName = "import.registration";//$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.IMPORT_UNREGISTRATION):
eventTypeName = "IMPORT_UNREGISTRATION"; //$NON-NLS-1$
+ registrationTypeName = "import.registration";//$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.IMPORT_WARNING):
eventTypeName = "IMPORT_WARNING"; //$NON-NLS-1$
+ registrationTypeName = "import.registration";//$NON-NLS-1$
break;
}
if (eventTypeName == null) {
@@ -975,7 +995,9 @@ public class RemoteServiceAdmin implements
.size()]));
eventProperties.put("timestamp", new Long(new Date().getTime())); //$NON-NLS-1$
eventProperties.put("event", event); //$NON-NLS-1$
- eventProperties.put("import.registration", endpointDescription);
+ if (registrationTypeName != null) {
+ eventProperties.put(registrationTypeName, endpointDescription);
+ }
postRemoteServiceAdminEvent(topic, eventProperties);
}

Back to the top