Date birthdate = new Date();
Double annualSalary = new Double(0.0);
Double loanAmount = new Double(0.0);
int startPK = 0;
StatefulLoanManagerRemote loanmanager = null;
Random generator = new Random();
try{
Context jndiContext = new InitialContext();
Object ref = jndiContext.lookup("StatefulLoanManagerHomeRemote");
StatefulLoanManagerHomeRemote home = (StatefulLoanManagerHomeRemote)
PortableRemoteObject.narrow(ref, StatefulLoanManagerHomeRemote.class);
loanmanager = home.create();
} catch(CreateException ce){
ce.printStackTrace();
} catch(RemoteException re){
re.printStackTrace();
} catch(NamingException ne){
ne.printStackTrace();
}
//System.out.println("Please enter loan details:");
try{
startPK = loanmanager.getMaxPK();
} catch (RemoteException re){
re.printStackTrace();
}
for(int i=startPK + 1;i<startPK + generator.nextInt(14) + 1;i++){
id = new Integer(i);
name = "Customer" + i;
address = "Address" + i;
sssNo = "SSS:" + i;
birthdate = new Date();
annualSalary = new Double(generator.nextDouble() * 150000.0 + 20000.0);
loanAmount = new Double(generator.nextDouble() * 1000000.0 + 50000.0);
try{
loanmanager.submitLoanApplication(id, name, address, birthdate, sssNo, annualSalary, loanAmount);
System.out.println("Submitting new loan application...");
System.out.println("-> submit count is now = " + loanmanager.getSubmitCount());
}catch (RemoteException re){
re.printStackTrace();
}
}
try{
System.out.println(loanmanager.getSubmitCount() + " loan applications were submitted.");
}catch(RemoteException re){
re.printStackTrace();
}
}