⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 helloclient.java

📁 该HttpProxy用于从Applet或Swing界面中访问Ejb和服务端的JavaBean。
💻 JAVA
字号:
/*
 * Created on 2005-6-29
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package com.nari.pmos.ejb.hello;

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;

/**
 * @author hujun
 * 
 * To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Generation - Code and Comments
 */
public class helloClient {
	/*
	 * main 函数
	 */
	public static void main(String[] args) {
		Properties p = new Properties();
		p.put(Context.INITIAL_CONTEXT_FACTORY,
				"org.jnp.interfaces.NamingContextFactory");
		p.put(Context.PROVIDER_URL, "jnp://10.144.98.202:1099");
		// p.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
		// p.put(Context.PROVIDER_URL,"iiop://10.144.94.187:2809");
		try {
			Context ctx = new InitialContext(p);
			Object obj = ctx.lookup("pmos/ejb/hello");

			helloHome home = (helloHome) javax.rmi.PortableRemoteObject.narrow(
					obj, helloHome.class);
			hello Hello = home.create();
			System.out.println(Hello.echo());
			System.out.println(Hello.echo_1(1, 2, 3));
			// Hello.remove();

			// Object objt = Hello.getLocal();

			// Hello.getLocal();

			// helloLocal HelloLocal = (helloLocal)Hello.getLocal();
			/*
			 * System.out.println(HelloLocal.toString());
			 */
			hello Hello_1 = (hello) Hello.getRemote();
			System.out.println(Hello_1.echo());

			// Context ctx1 = new InitialContext(p);
			// Object obj1 = ctx.lookup("pmos/ejb/helloLocal");

			// helloLocalHome home1 =
			// (helloLocalHome)obj;//(helloHome)javax.rmi.PortableRemoteObject.narrow(obj,
			// helloHome.class );
			// helloLocal Hello1 = home1.create();

		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Exception:");
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -