01 package com.flat502.rox.demo;
02
03 import java.net.URL;
04 import java.util.Arrays;
05
06 import com.flat502.rox.client.XmlRpcClient;
07 import com.flat502.rox.utils.Utils;
08
09 /**
10 * A demo client illustrating the {@link com.flat502.rox.client.XmlRpcClient#proxyObject(String, Class)}
11 * method.
12 */
13 public class RMIClientDemo {
14 /**
15 * Call each of the exposed methods on the remote demo server.
16 * @param args
17 * A list of parameters. Only the first is used and if
18 * present must be the URL of the remote server. This
19 * defaults to <code>http://localhost:8080/</code> if
20 * not specified.
21 */
22 public static void main(String[] args) {
23 try {
24 String url = "http://localhost:8080/";
25
26 if (args != null && args.length > 0) {
27 url = args[0];
28 }
29 System.out.println("Connecting to "+url);
30
31 XmlRpcClient client = new XmlRpcClient(new URL(url));
32 RMIServerInterface server = (RMIServerInterface) client.proxyObject(
33 "example.", RMIServerInterface.class);
34
35 System.out.println("Date: " + server.getDate());
36 System.out.println("Version: " + server.getVersionInfo(true));
37 int[] list = new int[]{1,2,3,4,5,6};
38 System.out.println("Sum of " + Utils.toString(list) + ": " + server.sum(list));
39 } catch (Exception e) {
40 e.printStackTrace();
41 }
42 }
43 }
|