您的位置:首页 >> 编程开发 >> Java >> JavaBeans >> 正文
RSS
 

Petstore源码追踪记(3)-商业逻辑处理(五)

http://www.rdxx.com 01年11月18日 11:08 互联网 我要投稿

关键词: 商业 , 逻辑 , Stor

          Locale locale =
I18nUtil.getLocaleFromString(profile.getPreferredLanguage());
          session.setAttribute(PetstoreKeys.LOCALE, locale);
      }
   }
}
以下略...

     SignOnNotifier
会透过PetstoreComponentManager取得
ShoppingClientFacade
reference
ShoppingClientFacadePetstoreEJB tier的代理接口,Web tier

Request均需透过它来存取所需资料,这个Design Pattern的好处是可以降低EJB tierWeb tier间的藕合性,将商业逻辑集中控管在EJB tier

PetstoreComponentManager
,源码在
D:\petstore1.3.1\src\apps\petstore\src\com\sun\j2ee\blueprints\petstore\controller\web\
PetstoreComponentManager.java
,约110列:

public CustomerLocal  getCustomer(HttpSession session) {
   ShoppingControllerLocal scEjb = getShoppingController(session);
   try {
   //取得ShoppingClientFacade reference
      ShoppingClientFacadeLocal scf = scEjb.getShoppingClientFacade();
      //scf.setUserId(userId);
      //
取得
CustomerLocal reference
      return scf.getCustomer();
   } catch (FinderException e) {
      System.err.println("PetstoreComponentManager finder error: " + e);
   } catch (Exception e) {
      System.err.println("PetstoreComponentManager error: " + e);
   }
  
return null;
}

ShoppingClientFacadeLocalEJB
Session Bean,源码在

D:\petstore1.3.1\src\apps\petstore\src\com\sun\j2ee\blueprints\petstore\controller\ejb\
ShoppingClientFacadeLocalEJB.java
,约101列:

/*
 * Asume that the customer userId has been set
 */
public CustomerLocal getCustomer() throws FinderException {
   //
请加入侦察码
   System.out.println("ShoppingClientFacadeLocalEJB.getCustomer()");
   if (userId == null) {
      throw new GeneralFailureException("ShoppingClientFacade: failed to look
up name of customer: userId is not set" );
   }
   try {
       ServiceLocator sl = new ServiceLocator();
       CustomerLocalHome home =(CustomerLocalHome)
           sl.getLocalHome(JNDINames.CUSTOMER_EJBHOME);
       customer = home.findByPrimaryKey(userId);
    } catch (ServiceLocatorException slx) {
       throw new GeneralFailureException("ShoppingClientFacade: failed to look
up name of customer: caught " + slx);
    }
    return customer;
}

CustomerEJB
Entity Bean,它与AccountEJB有一对一关系,AccountEJB也与ContactInfoEJB有一对一关系,三者皆为Entity Bean,直接对应资料库资料表CustomerEJBTable, AccountEJBTable, ContactInfoEJBTable,源码在D:\petstore1.3.1\src\components\customer\src\com\sun\j2ee\blueprints\customer\
共7页  第1页 第2页 第3页 第4页 第5页 第6页 第7页

 
 
标签: 商业 , 逻辑 , Stor 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站