Search in sources :

Example 16 with IRemoteServiceRegistration

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

the class RestRemoteServiceAdapterTest method testGetRemoteService.

public void testGetRemoteService() {
    IRemoteServiceRegistration registration = createRestRegistration("resourcePath");
    IRemoteServiceReference reference = registration.getReference();
    assertNotNull(reference);
    IRemoteService remoteService = getRemoteServiceClientContainerAdapter().getRemoteService(reference);
    assertNotNull(remoteService);
}
Also used : IRemoteServiceReference(org.eclipse.ecf.remoteservice.IRemoteServiceReference) IRemoteServiceRegistration(org.eclipse.ecf.remoteservice.IRemoteServiceRegistration) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 17 with IRemoteServiceRegistration

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

the class AbstractDistributionTest method registerRemoteService.

protected IRemoteServiceRegistration registerRemoteService(IRemoteServiceContainerAdapter adapter, String serviceInterface, Object service, Dictionary serviceProperties, int sleepTime) {
    final IRemoteServiceRegistration result = adapter.registerRemoteService(new String[] { serviceInterface }, service, serviceProperties);
    sleep(sleepTime);
    return result;
}
Also used : IRemoteServiceRegistration(org.eclipse.ecf.remoteservice.IRemoteServiceRegistration)

Example 18 with IRemoteServiceRegistration

use of org.eclipse.ecf.remoteservice.IRemoteServiceRegistration 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

IRemoteServiceRegistration (org.eclipse.ecf.remoteservice.IRemoteServiceRegistration)18 IRemoteServiceReference (org.eclipse.ecf.remoteservice.IRemoteServiceReference)8 IRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter)3 IRemoteServiceID (org.eclipse.ecf.remoteservice.IRemoteServiceID)3 Dictionary (java.util.Dictionary)2 IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)2 Hashtable (java.util.Hashtable)1 TreeMap (java.util.TreeMap)1 IContainer (org.eclipse.ecf.core.IContainer)1 IExtendedRemoteServiceRegistration (org.eclipse.ecf.remoteservice.IExtendedRemoteServiceRegistration)1 IOSGiRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IOSGiRemoteServiceContainerAdapter)1 IRemoteCallable (org.eclipse.ecf.remoteservice.client.IRemoteCallable)1 HttpGetRequestType (org.eclipse.ecf.remoteservice.rest.client.HttpGetRequestType)1