import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.ServerInvokerFactory; public class MyServer { public static void main(String[] args) throws Exception { ServerInvokerFactory invokerFactory = new ServerInvokerFactory(); ServerInvoker serverInvoker = invokerFactory.createTCPServerInvoker(1234); serverInvoker.addListener(new MyServerListener()); serverInvoker.start(); Thread.sleep(Long.MAX_VALUE); } } class MyServerListener implements Listener { public void handleInvocation(Request request, Response response) throws Throwable { } } import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; public class MyClient { public static void main(String[] args) throws Exception { InvokerLocator locator = new InvokerLocator("rmi://localhost:1234"); Client client = new Client(locator); client.connect(); Request request = new Request(); Response response = client.invoke(request); } }


上一篇:
下一篇:
切换中文