<dependencies>
<dependency>
<groupId>org.jboss.remoting</groupId>
<artifactId>jboss-remoting</artifactId>
<version>3.0.0.Final</version>
</dependency>
</dependencies>
import org.jboss.remoting.ServerInvocationHandler;
import org.jboss.remoting.ServerInvoker;
public class MyServerImpl implements ServerInvocationHandler {
public String greet(String name) {
return "Hello, " + name + "!";
}
public static void main(String[] args) {
MyServerImpl server = new MyServerImpl();
ServerInvoker invoker = new ServerInvoker(server);
invoker.setServerEndpoint("localhost", 8080);
invoker.addInvocationHandler("myService", server);
invoker.start();
}
}
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.callback.Callback;
public class MyClient {
public static void main(String[] args) throws Exception {
InvokerLocator locator = new InvokerLocator("remoting://localhost:8080");
Client client = new Client(locator);
client.connect();
String result = (String) client.invoke("myService", "greet", new Object[]{"John"}, new Class[]{String.class});
System.out.println(result);
client.disconnect();
}
}