@Service
public class HelloServiceImpl implements HelloService {
@Override
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
org.osgi.service.remoteserviceadmin.RemoteServiceAdmin rsa = ...;
rsa.exportService(HelloService.class, new HelloServiceImpl(), new Hashtable<>());
RemoteServiceContext context = RemoteServiceContext.create();
context.setEndpointUrl("http://remote-host:8080/remote-service");
context.setInterfaceName(HelloService.class.getName());
HelloService helloService = context.createProxy();
String result = helloService.sayHello("Amdatu");
System.out.println(result);