1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| /* Generated by Together */
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
//import CommandHome;
//import Command;
import java.util.Properties;
import java.lang.reflect.Proxy;
import java.lang.reflect.Method;
public class ClientClass {
public static void main(String[] argv) {
try {
Properties props = System.getProperties();
props.put(Context.PROVIDER_URL, URL);
props.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
Context initial = new InitialContext(props);
Object objref = initial.lookup(JNDI);
if (Proxy.isProxyClass(objref.getClass())) {
System.out.println(objref.getClass().getName());
Class[] interfaces = objref.getClass().getInterfaces();
for (int i=0;i<interfaces.length;i++) {
System.out.println(">> " + interfaces[i].getName());
if (!"javax.".equals(interfaces[i].getName().substring(0,6))) {
Method[] ms = interfaces[i].getMethods();
for (int j=0;j<ms.length;j++) {
System.out.println(" -- " + ms[j]);
if ("create".equals(ms[j].getName())) {
Class o = ms[j].getReturnType();
Method mo[] = o.getMethods();
for (int k=0;k<mo.length;k++) {
System.out.println(" ** " + mo[k]);
}
}
}
}
}
}
//CommandHome home = (CommandHome)PortableRemoteObject.narrow(objref, CommandHome.class);
//Command aCommand = home.create();
// write your test code here
//aCommand.method1();
//aCommand.remove();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private final static String JNDI_FACTORY = "org.jnp.interfaces.NamingContextFactory";
private final static String JNDI = "CommandBean";
private final static String URL = "localhost:1099";
} |