package ejb; import javax.ejb.*; /** * This is the bean class for the CustomerFacadeBean enterprise bean. * Created 06-Dec-2005 18:10:46 * @author :-) */ public class CustomerFacadeBean implements SessionBean, CustomerFacadeRemoteBusiness { private SessionContext context; private ejb.CustomerLocalHome custHome; // // TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services) // TODO Add business methods or web service operations /** * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext) */ public void setSessionContext(SessionContext aContext) { context = aContext; } /** * @see javax.ejb.SessionBean#ejbActivate() */ public void ejbActivate() { } /** * @see javax.ejb.SessionBean#ejbPassivate() */ public void ejbPassivate() { } /** * @see javax.ejb.SessionBean#ejbRemove() */ public void ejbRemove() { } // /** * See section 7.10.3 of the EJB 2.0 specification * See section 7.11.3 of the EJB 2.1 specification */ public void ejbCreate() { custHome = lookupCustomerBean(); } // Add business logic below. (Right-click in editor and choose // "EJB Methods > Add Business Method" or "Web Service > Add Operation") private ejb.CustomerLocalHome lookupCustomerBean() { try { javax.naming.Context c = new javax.naming.InitialContext(); ejb.CustomerLocalHome rv = (ejb.CustomerLocalHome) c.lookup("java:comp/env/ejb/CustomerBean"); return rv; } catch(javax.naming.NamingException ne) { java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE,"exception caught" ,ne); throw new RuntimeException(ne); } } public String getCustomerInfo(int custId) throws javax.ejb.FinderException { ejb.CustomerLocal customer = custHome.findByPrimaryKey(new Integer(custId)); return "Name: " + customer.getName() + ", E-mail: " +customer.getEmail(); } }