package daben.impl;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import daben.CustomerHome;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import daben.*;
import javax.ejb.*;
import javax.naming.*;
import java.util.*;


public class CustFacadeAppBean implements SessionBean //会话Bean:CustFacadeApp实现类
{
SessionContext sessionContext;
CustimerHome custimerHome;

  public void ejbCreate()
  {
  }

  public void ejbActivate()
  {
  }

  public void ejbPassivate()
  {
  }

  public void ejbRemove()
  {
  }

  public void setSessionContext(SessionContext ctx)
  {
  }
//*完成新建客户的方法：addCustomer()*//
  public void addCustomer(Long id,String khmc,String khlxr,String khdz,String dh,String dzyj,String yhzh,String jsfs,String jshb)
  {
    try
    {
     InitialContext context = new InitialContext();
      //lookup for the Customer entity bean using ejb-ref tag  in ejb-jar.xml
      Object Obj=context.lookup("Customer");
      customerHome = (CustomerHome)PortableRemoteObject.narrow(Obj, CustomerHome.class);
      Customer customer;
      khxx = khxxHome.create(id,khmc,khlxr,khdz,dh,dzyj,yhzh,jsfs,jshb);                    
    }catch (Exception e)
    {
    System.err.println("Caught exception " + e.toString());
    throw new javax.ejb.EJBException(e);
    }
    }
  
  private CustomerHome getCustomerHome() throws NamingException
  {
    final InitialContext context = new InitialContext();
    return (CustomerHome)PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/Customer"), CustomerHome.class);
  }
  }