try {
Properties p = new Properties();
// p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
// p.put(Context.PROVIDER_URL, "t3://localhost:7001");
javax.naming.Context jndiContext = new InitialContext();
Object obj =
jndiContext.lookup("java:comp/env/ejb/CabinHome");
CabinHomeRemote home = (CabinHomeRemote)
javax.rmi.PortableRemoteObject.narrow(obj,CabinHomeRemote.class);
Vector vect = new Vector();
for (int i = 1; ; i++) {
Integer pk = new Integer(i);
CabinRemote cabin = null;
try {
cabin = home.findByPrimaryKey(pk);
} catch(javax.ejb.FinderException fe) {
System.out.println("Caught exception: "+fe.getMessage()+" for pk="+i);
break;
}
// Check to see if the bed count and ship ID match.
if (cabin != null &&
cabin.getShipId() == shipID &&
cabin.getBedCount() == bedCount) {
String details =
i+","+cabin.getName()+","+cabin.getDeckLevel();
vect.addElement(details);
}
}
String [] list = new String[vect.size()];
vect.copyInto(list);
return list;
} catch(Exception e) {throw new EJBException(e);}