正在加载图片...
ooAD大报告之 Petstore中EB的设计模式分析 2148概述 在 PetStore中就使用了这种模式,不过大家一般在开发中都可能使用这种模式,只是自己不知道罢 了 2.1.4.9 Shoppingclient FacadelocalEJB public class ShoppingClientFacadelocalEJB implements SessionBean i k asume that the customer userid has been set //它封装了调用客户的 EntityBean public CustomerLocal getCustomer o throws FinderException look up name of customer: userid is not set") InitialContext ic new InitialContexto Object o=ic lookup( java: comp/env/ejb/local/Customer) CustomerLocalHome home =(CustomerL ocalHome)o customer home. findBy PrimaryKey (userId) catch(javax. naming. NamingException nx)i throw new GeneralFailureException ("ShoppingClient Facade failed to look aught return customer;}//它封装了产生客户方法 public CustomerLocal createCustomer(String userId) InitialContext ic new InitialContext o Object o=ic lookup(java: comp/env/ejb/local/Customer CustomerLocalHome home =(CustomerLocalHome)o customer= home. create (userId 作者:张玉平,吴小静,范簧梦,张麒,罗晟,张翅18OOAD 大报告之 PetStore 中 EJB 的设计模式分析 作者: 张 玉 平 , 吴 小 静 , 范 赟 梦 , 张麒,罗晟, 张 翅 18 2.1.4.8 概述 在PetStore 中就使用了这种模式,丌过大家一般在开发中都可能使用这种模式,叧是自己丌知道罢 了。 2.1.4.9 ShoppingClientFacadeLocalEJB public class ShoppingClientFacadeLocalEJB implements SessionBean { /* * Asume that the customer userId has been set */ //它封装了调用客户的EntityBean public CustomerLocal getCustomer() throws FinderException { if (userId == null) { throw new GeneralFailureException("ShoppingClientFacade: failed to look up name of customer: userId is not set" ); } try { InitialContext ic = new InitialContext(); Object o = ic.lookup("java:comp/env/ejb/local/Customer"); CustomerLocalHome home =(CustomerLocalHome)o; customer = home.findByPrimaryKey(userId); } catch (javax.naming.NamingException nx) { throw new GeneralFailureException("ShoppingClientFacade: failed to look up name of customer: caught " + nx); } return customer; } //它封装了产生客户方法 public CustomerLocal createCustomer(String userId) { try { InitialContext ic = new InitialContext(); Object o = ic.lookup("java:comp/env/ejb/local/Customer"); CustomerLocalHome home =(CustomerLocalHome)o; customer = home.create(userId);
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有