KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > client > raccess > RemoteAccessClient


1 /*
2  * AceAppServerCom.java
3  *
4  * Created on May 29, 2003, 1:16 PM
5  */

6
7 package com.quikj.client.raccess;
8
9 import java.rmi.*;
10 import java.net.*;
11
12 /**
13  *
14  * @author amit
15  */

16 public class RemoteAccessClient
17 {
18     
19     /** Holds value of property httpsAccess. */
20     private AceRMIInterface remoteAccess = null;
21     
22     private String JavaDoc lookupName;
23     
24     /** Creates a new instance of AceAppServerCom */
25     public RemoteAccessClient(String JavaDoc registry_url,
26     String JavaDoc service_name,
27     String JavaDoc host)
28     {
29         if (registry_url.endsWith("/") == false)
30         {
31             registry_url += "/";
32         }
33         
34         if (service_name.endsWith("/") == false)
35         {
36             service_name += "/";
37         }
38         
39         lookupName = registry_url + service_name + host;
40     }
41     
42     public RemoteAccessClient(String JavaDoc host, String JavaDoc service_name)
43     {
44         this("rmi://localhost:1099", service_name, host);
45     }
46     
47     public AceRMIInterface getRemoteAccess()
48     throws NotBoundException, MalformedURLException, RemoteException
49     {
50         return (AceRMIInterface)Naming.lookup(lookupName);
51     }
52     
53     // args[0] = host name of the remote object
54
// args[1] = service name
55
// args[2] = name of the object
56
// args[3] = name of the param
57

58     public static void main(String JavaDoc[] args)
59     {
60         try
61         {
62             RemoteAccessClient com = new RemoteAccessClient(args[0], args[1]);
63             AceRMIInterface rmi = com.getRemoteAccess();
64             
65             System.out.println(args[3] + "="
66             + rmi.getParam(args[2],
67             args[3]));
68         }
69         catch (Exception JavaDoc ex)
70         {
71             System.err.println(ex.getClass().getName() + ": "
72             + ex.getMessage());;
73         }
74         
75         System.exit(0);
76     }
77 }
78
Popular Tags