/* * * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. * * This software is the proprietary information of Sun Microsystems, Inc. * Use is subject to license terms. * */ import java.util.*; import javax.ejb.*; import javax.naming.*; import javax.rmi.PortableRemoteObject; public class ShipperEJB implements SessionBean { String site; public void ejbCreate(String site) { System.out.println("ShipperEJB: ejbCreate()"); this.site = site; } public void shipItem(String productId, int quantity) throws FinderException { System.out.println("ShipperEJB: shipItem()"); try { Context initial = new InitialContext(); Object objref = initial.lookup("java:comp/env/ejb/Stocker"); StockHome home = (StockHome)PortableRemoteObject.narrow(objref, StockHome.class); Stock stock = home.findByPrimaryKey(productId); stock.updateOnHand(quantity); if (stock.reorderNeeded()) { // Generate an order to replenish the stock . . . } } catch (Exception ex) { throw new EJBException(ex.getMessage()); } } public ShipperEJB() {} public void ejbRemove() {} public void ejbActivate() {} public void ejbPassivate() {} public void setSessionContext(SessionContext sc) {} }