FileDocCategorySizeDatePackage
TravelAgentBean.javaAPI DocExample1990Fri Mar 01 22:25:12 GMT 2002com.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()

public java.lang.String[]listCabins(int shipID, int bedCount)


      try 
      {
         javax.naming.Context jndiContext = new InitialContext();
         CabinHomeLocal home = (CabinHomeLocal)
            jndiContext.lookup("java:comp/env/ejb/CabinHomeLocal");

         Vector vect = new Vector();
         for (int i = 1; ; i++) 
         {
            Integer pk = new Integer(i);
            CabinLocal 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 (NamingException ne) 
      {
         throw new EJBException(ne);
      }    
   
public voidsetSessionContext(javax.ejb.SessionContext cntx)