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

📄 helloclient.java

📁 EJB_原代码多例-好好东西啊
💻 JAVA
字号:
package com.wiley.compBooks.roman.session.helloworld;

import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import java.util.Properties;

/**
 * This class is an example of client code which invokes
 * methods on a simple stateless session bean.
 */
public class HelloClient {

	public static void main(String[] args) {

		try {
			/*
			 * Get System properties for JNDI initialization
			 */
			Properties props = System.getProperties();

			/*
			 * Get a reference to the HelloHome Object - the
			 * factory for Hello EJB Objects
			 */
			Context ctx = new InitialContext(props);
			HelloHome home = (HelloHome) ctx.lookup("HelloHome");

			/*
			 * Use the factory to create the Hello EJB Object
			 */
			Hello hello = home.create();

			/*
			 * Call the hello() method, and print it
			 */
			System.out.println(hello.hello());

			/*
			 * Done with EJB Object, so remove it
			 */
			hello.remove();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

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