public interface MyService {
String sayHello(String name);
}
public class MyServiceImpl implements MyService {
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
public class Server {
public static void main(String[] args) throws Exception {
Endpoint endpoint = EndpointFactory.createServerEndpoint("http://localhost:8080");
endpoint.getInvocationHandler().registerInvokable(new MyServiceImpl());
endpoint.start();
System.out.println("Server started!");
}
}
public class Client {
public static void main(String[] args) throws Exception {
Endpoint endpoint = EndpointFactory.createClientEndpoint("http://localhost:8080");
MyService proxy = ProxyFactory.create(MyService.class, endpoint);
String result = proxy.sayHello("Alice");
System.out.println(result);
}
}