FileDocCategorySizeDatePackage
TravelAgentBean.javaAPI DocExample2083Mon Dec 13 22:39:54 GMT 1999com.titan.travelagent

TravelAgentBean

public class TravelAgentBean extends Object implements javax.ejb.SessionBean

Fields Summary
Constructors Summary
Methods Summary
public voidejbActivate()

public voidejbCreate()

   // Do nothing.
   
public voidejbPassivate()

public voidejbRemove()

private javax.naming.ContextgetInitialContext()

      Properties p = new Properties();
      // ... Specify the JNDI properties specific to the vendor.
      return new javax.naming.InitialContext(p);
   
public java.lang.String[]listCabins(int shipID, int bedCount)

        try {
            Context jndiContext = getInitialContext();
            CabinHome home = 
              (CabinHome)jndiContext.lookup("CabinHome");
    
            Vector vect = new Vector();
            CabinPK pk = new CabinPK();
            Cabin cabin;
            for(int i = 1; ; i++){
               pk.id = i;
               try {
                  cabin = home.findByPrimaryKey(pk);
                } catch(javax.ejb.FinderException fe){
                    break;
                }
                // Check to see if the bed count and ship ID match.
                if (cabin.getShip() == 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(javax.naming.NamingException ne){
            throw new RemoteException("Unable to locate CabinHome",ne);
       }    
   
public voidsetSessionContext(javax.ejb.SessionContext cntx)