FileDocCategorySizeDatePackage
TravelAgentBean.javaAPI DocExample2297Mon Sep 10 23:49:26 BST 2001com.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 javax.naming.ContextgetInitialContext()


		java.util.Properties properties = new java.util.Properties();
		properties.put(javax.naming.Context.PROVIDER_URL, "iiop:///");
		properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, 
			"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
		InitialContext initialContext = new InitialContext(properties);
		return initialContext;
    
public java.lang.String[]listCabins(int shipID, int bedCount)


	CabinRemote cabin = null;

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

            CabinHomeRemote home = (CabinHomeRemote)
            javax.rmi.PortableRemoteObject.narrow(obj,CabinHomeRemote.class);
    
            Vector vect = new Vector();
            for (int i = 1; ; i++) {
              Integer pk = new Integer(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.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 javax.ejb.EJBException(e);}    
   
public voidsetSessionContext(javax.ejb.SessionContext cntx)