IBM®
跳转到主要内容
    中国 [选择]    使用条款
 
 
Select a scope: Search for:    
    首页    产品    服务与解决方案     支持与下载    个性化服务    
跳转到主要内容

developerWorks 中国  >  Open source | Java technology  >

创建 Geronimo 客户机应用程序

利用 Geronimo 的客户机应用程序容器或者自己创建客户机应用程序

developerWorks

返回文章


CatClientStandalone.java 中的 getCats() 方法
				
	private Vector getCats() {
		Vector cats = new Vector();
		Collection coll = null;
		CategoryRemote cr = null;
	
		Properties props = new Properties();
		props.put("java.naming.factory.initial",
				"org.openejb.client.RemoteInitialContextFactory");
		props.put("java.naming.provider.url", "127.0.0.1:4201");
		props.put("java.naming.security.principal", "testuser");
		props.put("java.naming.security.credentials", "testpassword");

		try {
       
			Context ic = new InitialContext(props);
			Object o = ic.lookup("CategoryBean");

			CategoryHome home = (CategoryHome) PortableRemoteObject.narrow(o,
				CategoryHome.class);
			coll = home.findAll();
			Iterator it = coll.iterator();
			while (it.hasNext()) {
				cr = (CategoryRemote) it.next();
				cats.add("Cat id= " + cr.getId() + ";  Name= " + cr.getName());
			} // of while
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return cats;
	}

返回文章

    关于 IBM 隐私条约 联系 IBM 使用条款