import javax.rmi.PortableRemoteObject;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;
import hello.HelloHome;
import hello.Hello;


public class HelloClient{
	public static void main(String[] args) throws Exception{
		//# 1. ¿ø°Ý È¨ °´Ã¼ÀÇ ref ¾ò±â 
		//		a. ¿ø°Ý J2EE ServerÀÇ Naming Service ÀÇ Ref ¾ò±â

		Properties prop = new Properties();
		prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
		prop.put(Context.PROVIDER_URL,"t3://211.183.3.212:7001");

		Context context = new InitialContext(prop);

		//		b. JNDI NAME À¸·Î Lookup ÇØ¼­  È¨ °´Ã¼ÀÇ ref¾ò±â
		//			¿ø°ÝÈ¨°´Ã¼ÀÇ ref ´Â CORBA °´Ã¼ Å¸ÀÔÀÌ´Ù.
		Object homeObject = context.lookup("MyBean");

		// CORBA °´Ã¼ ¸¦ ÀÚ¹Ù°´Ã¼·Î Narrowing ÇØÁØ´Ù.
		HelloHome home = (HelloHome)PortableRemoteObject.narrow(homeObject,HelloHome.class);


		//#2. home.create() ¸Þ½îµå È£Ãâ
		// ¿ø°Ý °´Ã¼ ref ¾ò±â
		Hello hello = home.create();

		String result = hello.greet("¾Æ³ªÄÜ´Ù");
		System.out.println("result :" + result);
	}
}