Search in sources :

Example 1 with IExtendedRemoteServiceRegistration

use of org.eclipse.ecf.remoteservice.IExtendedRemoteServiceRegistration in project ecf by eclipse.

the class RemoteServiceAdmin method exportService.

private ExportRegistration exportService(final ServiceReference serviceReference, Map<String, ?> overridingProperties, String[] exportedInterfaces, IRemoteServiceContainer rsContainer, Map<String, Object> endpointDescriptionProperties) throws Exception {
    // Create remote service properties
    Map<String, Object> remoteServiceProperties = copyNonReservedProperties(serviceReference, (Map<String, Object>) overridingProperties, new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER));
    // Added for R7 support. Copy intents and intent options to remote service
    // properties
    String[] intents = PropertiesUtil.getStringArrayWithDefault(endpointDescriptionProperties, org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED, new String[] {});
    remoteServiceProperties = PropertiesUtil.copyIntentProperties(endpointDescriptionProperties, intents, remoteServiceProperties);
    IRemoteServiceContainerAdapter containerAdapter = rsContainer.getContainerAdapter();
    // create serializable dictionary from remote service properties
    Dictionary rsp = PropertiesUtil.createSerializableDictionaryFromMap(remoteServiceProperties);
    // Register remote service via ECF container adapter to create
    // remote service registration
    IRemoteServiceRegistration remoteRegistration = null;
    if (containerAdapter instanceof IOSGiRemoteServiceContainerAdapter) {
        IOSGiRemoteServiceContainerAdapter osgiContainerAdapter = (IOSGiRemoteServiceContainerAdapter) containerAdapter;
        remoteRegistration = osgiContainerAdapter.registerRemoteService(exportedInterfaces, serviceReference, rsp);
    } else {
        Object service = AccessController.doPrivileged(new PrivilegedAction<Object>() {

            public Object run() {
                return getClientBundleContext().getService(serviceReference);
            }
        });
        remoteRegistration = containerAdapter.registerRemoteService(exportedInterfaces, service, rsp);
    }
    endpointDescriptionProperties.put(org.eclipse.ecf.remoteservice.Constants.SERVICE_ID, remoteRegistration.getID().getContainerRelativeID());
    if (remoteRegistration instanceof IExtendedRemoteServiceRegistration) {
        IExtendedRemoteServiceRegistration iersr = (IExtendedRemoteServiceRegistration) remoteRegistration;
        Map<String, Object> extraProperties = iersr.getExtraProperties();
        if (extraProperties != null)
            endpointDescriptionProperties = PropertiesUtil.mergeProperties(endpointDescriptionProperties, extraProperties);
    }
    // Copy only serializable properties
    endpointDescriptionProperties = PropertiesUtil.copySerializableProperties(endpointDescriptionProperties, new TreeMap<String, Object>());
    // Create ExportEndpoint/ExportRegistration
    return new ExportRegistration(new ExportEndpoint(serviceReference, new EndpointDescription(endpointDescriptionProperties), remoteRegistration, endpointDescriptionProperties));
}
Also used : Dictionary(java.util.Dictionary) IOSGiRemoteServiceContainerAdapter(org.eclipse.ecf.remoteservice.IOSGiRemoteServiceContainerAdapter) IRemoteServiceContainerAdapter(org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter) TreeMap(java.util.TreeMap) IExtendedRemoteServiceRegistration(org.eclipse.ecf.remoteservice.IExtendedRemoteServiceRegistration) IRemoteServiceRegistration(org.eclipse.ecf.remoteservice.IRemoteServiceRegistration)

Aggregations

Dictionary (java.util.Dictionary)1 TreeMap (java.util.TreeMap)1 IExtendedRemoteServiceRegistration (org.eclipse.ecf.remoteservice.IExtendedRemoteServiceRegistration)1 IOSGiRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IOSGiRemoteServiceContainerAdapter)1 IRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter)1 IRemoteServiceRegistration (org.eclipse.ecf.remoteservice.IRemoteServiceRegistration)1