From f24c051ee57a41060970ab5e1f5f799ec8abf4dd Mon Sep 17 00:00:00 2001 From: slewis Date: Mon, 17 Jan 2011 10:40:04 -0800 Subject: RSA additions --- .../remoteserviceadmin/RemoteConstants.java | 7 ++- .../remoteserviceadmin/RemoteServiceAdmin.java | 67 +++++++++++++++------- 2 files changed, 52 insertions(+), 22 deletions(-) (limited to 'incubation') diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java index 22fd970b5..5e9ad3563 100644 --- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java +++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java @@ -11,6 +11,10 @@ package org.eclipse.ecf.osgi.services.remoteserviceadmin; public class RemoteConstants { + private RemoteConstants() { + // not instantiable + } + public static final String SERVICE_TYPE = "osgirsvc"; public static final String DISCOVERY_SCOPE = "ecf.endpoint.discovery.scope"; @@ -30,7 +34,7 @@ public class RemoteConstants { // Value of // org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS - // For ECF providers this is a constant, and receivers of + // For ECF providers this is a constant public static final String ENDPOINT_SERVICE_IMPORTED_CONFIGS_VALUE = "org.eclipse.ecf.config"; // Value of type String,ID,or Object[] @@ -40,4 +44,5 @@ public class RemoteConstants { // Value of type ID public static final String SERVICE_EXPORTED_CONTAINER_ID = "ecf.exported.containerid"; + public static final String SERVICE_IMPORTED_VALUETYPE = "ecf.imported.valuetype"; } diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java index cafe636a0..f7de6eb31 100644 --- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java +++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java @@ -916,8 +916,10 @@ public class RemoteServiceAdmin implements Collection results = new ArrayList(); synchronized (exportedRegistrations) { for (ExportRegistration reg : exportedRegistrations) { - org.osgi.service.remoteserviceadmin.ExportReference eRef = reg.getExportReference(); - if (eRef != null) results.add(eRef); + org.osgi.service.remoteserviceadmin.ExportReference eRef = reg + .getExportReference(); + if (eRef != null) + results.add(eRef); } } return results; @@ -927,8 +929,10 @@ public class RemoteServiceAdmin implements Collection results = new ArrayList(); synchronized (importedRegistrations) { for (ImportRegistration reg : importedRegistrations) { - org.osgi.service.remoteserviceadmin.ImportReference iRef = reg.getImportReference(); - if (iRef != null) results.add(iRef); + org.osgi.service.remoteserviceadmin.ImportReference iRef = reg + .getImportReference(); + if (iRef != null) + results.add(iRef); } } return results; @@ -1102,18 +1106,24 @@ public class RemoteServiceAdmin implements .getService(); } - private Version getPackageVersion(ServiceReference serviceReference, String serviceInterface, String packageName) { + private Version getPackageVersion(ServiceReference serviceReference, + String serviceInterface, String packageName) { Object service = getContext().getService(serviceReference); - if (service == null) return null; + if (service == null) + return null; Class[] interfaceClasses = service.getClass().getInterfaces(); - if (interfaceClasses == null) return null; + if (interfaceClasses == null) + return null; Class interfaceClass = null; - for(int i=0; i < interfaceClasses.length; i++) { - if (interfaceClasses[i].getName().equals(serviceInterface)) interfaceClass = interfaceClasses[i]; + for (int i = 0; i < interfaceClasses.length; i++) { + if (interfaceClasses[i].getName().equals(serviceInterface)) + interfaceClass = interfaceClasses[i]; } - if (interfaceClass == null) return null; - ExportedPackage exportedPackage = getExportedPackageForClass(getPackageAdmin(), interfaceClass); - return (exportedPackage == null)?null:exportedPackage.getVersion(); + if (interfaceClass == null) + return null; + ExportedPackage exportedPackage = getExportedPackageForClass( + getPackageAdmin(), interfaceClass); + return (exportedPackage == null) ? null : exportedPackage.getVersion(); } protected Map createExportEndpointDescriptionProperties( @@ -1142,7 +1152,8 @@ public class RemoteServiceAdmin implements String packageVersion = (String) PropertiesUtil.getPropertyValue( serviceReference, overridingProperties, packageVersionKey); if (packageVersion == null) { - Version version = getPackageVersion(serviceReference, exportedInterfaces[i], packageName); + Version version = getPackageVersion(serviceReference, + exportedInterfaces[i], packageName); if (version != null && !version.equals(Version.emptyVersion)) packageVersion = version.toString(); else @@ -1636,10 +1647,21 @@ public class RemoteServiceAdmin implements resultProperties .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS, intentsValue); - // Set service.imported to IRemoteService - resultProperties - .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED, - remoteService); + + // Set service.imported to IRemoteService unless SERVICE_IMPORTED_VALUETYPE is + // set + String serviceImportedType = (String) endpointDescription + .getProperties() + .get(org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_VALUETYPE); + if (serviceImportedType == null + || serviceImportedType.equals(IRemoteService.class.getName())) + resultProperties + .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED, + remoteService); + else + resultProperties + .put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED, + new Boolean(true)); String[] exporterSupportedConfigs = (String[]) endpointDescription .getProperties() @@ -1794,20 +1816,23 @@ public class RemoteServiceAdmin implements toClose = new ArrayList(exportedRegistrations); exportedRegistrations.clear(); } - for(ExportRegistration reg: toClose) reg.close(); + for (ExportRegistration reg : toClose) + reg.close(); } - + private void closeImportRegistrations() { List toClose = null; synchronized (importedRegistrations) { toClose = new ArrayList(importedRegistrations); importedRegistrations.clear(); } - for(ImportRegistration reg: toClose) reg.close(); + for (ImportRegistration reg : toClose) + reg.close(); } public void close() { - trace("close","closing importedRegistrations="+importedRegistrations+" exportedRegistrations="+exportedRegistrations); + trace("close", "closing importedRegistrations=" + importedRegistrations + + " exportedRegistrations=" + exportedRegistrations); closeRemoteServiceAdminListenerTracker(); closeEventAdminTracker(); closePackageAdminTracker(); -- cgit v1.2.3