Methods Summary |
---|
public Ticket | bookPassage(CreditCard card, double price)
if(customer == null || cruise == null || cabin == null){
throw new IncompleteConversationalState();
}
try{
ReservationHome resHome =
(ReservationHome) getHome("ReservationHome",ReservationHome.class);
Reservation reservation =
resHome.create(customer, cruise, cabin,price);
ProcessPaymentHome ppHome =
(ProcessPaymentHome) getHome("ProcessPaymentHome",ProcessPaymentHome.class);
ProcessPayment process = ppHome.create();
process.byCredit(customer, card, price);
Ticket ticket = new Ticket(customer,cruise,cabin,price);
return ticket;
}catch(Exception e){
throw new RemoteException("",e);
}
|
public void | ejbActivate()
|
public void | ejbCreate(Customer cust)
customer = cust;
|
public void | ejbPassivate()
try{
jndiContext.close();
}catch(NamingException ne){}
jndiContext = null;
|
public void | ejbRemove()
|
public int | getCabinID()
if(cabin==null)
throw new IncompleteConversationalState();
return ((CabinPK)cabin.getPrimaryKey()).id;
|
private java.sql.Connection | getConnection()
return DriverManager.getConnection(
ejbContext.getEnvironment().getProperty("jdbcURL"));
|
public int | getCruiseID()
if(cruise == null)
throw new IncompleteConversationalState();
return ((CruisePK)cruise.getPrimaryKey()).id;
|
public int | getCustomerID()
if(customer == null)
throw new IncompleteConversationalState();
return ((CustomerPK)customer.getPrimaryKey()).id;
|
protected java.lang.Object | getHome(java.lang.String name, java.lang.Class type)
try{
String jndiName =
ejbContext.getEnvironment().getProperty(name);
return getJndiContext().lookup(jndiName);
}catch(NamingException ne){
throw new RemoteException("Could not lookup ("+name+")",ne);
}
|
protected javax.naming.Context | getJndiContext()
if (jndiContext != null)
return jndiContext;
//java.util.Properties p = new java.util.Properties();
//jndiContext = new javax.naming.InitialContext(p);
jndiContext = new javax.naming.InitialContext();
return jndiContext;
|
public java.lang.String[] | listAvailableCabins(int bedCount)
if(cruise == null) throw new IncompleteConversationalState();
Connection con = null;
PreparedStatement ps = null;;
ResultSet result = null;
try {
int cruiseID = ((CruisePK)cruise.getPrimaryKey()).id;
int shipID = cruise.getShipID();
con = getConnection();
ps = con.prepareStatement(
"select ID, NAME, DECK_LEVEL from CABIN "+
"where SHIP_ID = ? and ID NOT IN "+
"(SELECT CABIN_ID FROM RESERVATION WHERE CRUISE_ID = ?)");
ps.setInt(1,shipID);
ps.setInt(2,cruiseID);
result = ps.executeQuery();
Vector vect = new Vector();
while(result.next()){
StringBuffer buf = new StringBuffer();
buf.append(result.getString(1));
buf.append(',");
buf.append(result.getString(2));
buf.append(',");
buf.append(result.getString(3));
vect.addElement(buf.toString());
}
String [] returnArray = new String[vect.size()];
vect.copyInto(returnArray);
return returnArray;
}
catch (Exception e) {
throw new RemoteException("",e);
}
finally {
try {
if (result != null) result.close();
if (ps != null) ps.close();
if (con!= null) con.close();
}catch(SQLException se){se.printStackTrace();}
}
|
public void | setCabinID(int cabinID)
CabinHome home = (CabinHome)getHome("CabinHome",CabinHome.class);
CabinPK pk = new CabinPK();
pk.id=cabinID;
cabin = home.findByPrimaryKey(pk);
|
public void | setCruiseID(int cruiseID)
CruiseHome home = (CruiseHome)getHome("CruiseHome", CruiseHome.class);
cruise = home.findByPrimaryKey(new CruisePK(cruiseID));
|
public void | setSessionContext(javax.ejb.SessionContext cntx)
ejbContext = cntx;
try{
jndiContext = new javax.naming.InitialContext();
}catch(NamingException ne){
throw new RemoteException("",ne);
}
|