// 1. Create R-OSGi Container
IContainerManager containerManager = getContainerManagerService();
container = containerManager.getContainerFactory().createContainer(
"ecf.r_osgi.peer");
// 2. Get remote service container adapter
IRemoteServiceContainerAdapter containerAdapter = (IRemoteServiceContainerAdapter) container
.getAdapter(IRemoteServiceContainerAdapter.class);
// 3. Lookup IRemoteServiceReference
IRemoteServiceReference[] helloReferences = containerAdapter
.getRemoteServiceReferences(IDFactory.getDefault().createID(
container.getConnectNamespace(), ROSGI_SERVICE_HOST),
IHello.class.getName(), null);
Assert.isNotNull(helloReferences);
Assert.isTrue(helloReferences.length > 0);
// 4. Get remote service for reference
IRemoteService remoteService = containerAdapter
.getRemoteService(helloReferences[0]);
// 5. Get the proxy
IHello proxy = (IHello) remoteService.getProxy();
// 6. Finally...call the proxy
proxy.hello("RemoteService Consumer");