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

📄 nodeclient.java

📁 精通Jboss——Ejb和Web Services开发精解的随书源代码
💻 JAVA
字号:
/*
 * Created on 2003-7-21
 */
package com.liuyang.ejb.cmp.node.client;

import java.util.Hashtable;
import java.util.Iterator;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import com.liuyang.ejb.cmp.node.Node;
import com.liuyang.ejb.cmp.node.NodeHome;


/**
 * @author
 * <a href="mailto:jdcyang@yahoo.com.cn">刘洋</a>
 */
public class NodeClient {

	public static void main(String[] args) {
		NodeClient client = new NodeClient();
		client.setup();
		String title = "hello1";
		try {
			//if(client.home.findAll().isEmpty()){
				//client.home.create(title,"today is 0723");
			//} else {
				//Node node = client.home.findByPrimaryKey(title);
				for(Iterator it = client.home.findAll().iterator();it.hasNext();){
					Node node =(Node) it.next();
					System.out.println(node.getText());
			//	}
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	NodeHome home;
	public void setup(){
		Context ctx = null;	
		try {
			Hashtable env = new Hashtable();
			env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
			env.put(Context.PROVIDER_URL,"localhost");
			ctx = new InitialContext(env);	
			//ctx = new InitialContext();				
		} catch (NamingException e) {
			e.printStackTrace();
		}
			Object objRef;
		try {
			objRef = ctx.lookup("cmp/node");
			home = (NodeHome)PortableRemoteObject.narrow(objRef, NodeHome.class);
			
		} catch (NamingException e1) {
			e1.printStackTrace();
		}		
	}
}

⌨️ 快捷键说明

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