import org.osgi.service.remoteserviceadmin.RemoteConstants;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
...
ExampleService service = new ExampleServiceImpl();
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(RemoteConstants.SERVICE_EXPORTED_INTERFACES, ExampleService.class.getName());
remoteServiceAdmin.exportService(service, properties);
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdmin;
...
EndpointDescription[] endpointDescriptions = remoteServiceAdmin.discoverEndpoints("example.service");
if (endpointDescriptions.length > 0) {
ExampleService proxy = remoteServiceAdmin.importService(endpointDescriptions[0]);
proxy.doSomething();
}