 |
返回文章
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;
}
|
返回文章
|  |
|