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

TutorialforbuildingJ2EEApplicationsusingJBOSSandECLIPSE-5

http://www.rdxx.com 06年12月09日 04:26 互联网 我要投稿

标签: Tutorial , san , J2EE , Eclipse , JB , ATI , UI , ONS , IP
 

Chapter 5.

Creating a BMP Entity Bean

This chapter describes how to create a Bean Managed Persistence (BMP) EJB component. We will create two BMP beans, Customer and Manager, as shown below. The Customer bean will be responsible for storing the details of customers of MyStore. The Manager bean stores details of the manager of MyStore. Both beans communicate with their respective tables in the database using Data Access Objects (DAOs) named CustomerDAO and ManagerDAO respectively.






All customers have been assigned a unique customerID for housekeeping purposes in MyStore in addition to their username for accessing the services of MyStore. Similarly the Manager of MyStore has been assigned a unique ManagerID.



Note : It is the usual practice to access business methods of BMP beans via a session bean, which encapsulates business logic and acts as an interface to further EJB components. In this case Customer and Manager are accessible via by StoreAccess.

This approach comes from a pattern called a Session Facade, whereby enterprise beans encapsulate business logic and business data and expose their interfaces. The session bean acts as a facade to encapsulate the complexity of interactions with the lower-level beans. The session facade is responsible for managing business objects and provides a uniform business service abstraction to presentation layer clients, thereby hiding the business object implementation in the lower-level beans.

This tutorial uses that pattern for business tier implementation.

Tasks :

  1. Create a BMP bean named Customer under package au.com.tusc.bmp.

  2. Create a DAO class named CustomerDAOImpl under package au.com.tusc.dao.

  3. Add all attributes/properties to the CustomerBean, with getter and setter methods for each of the attributes.

  4. Add a finder method named ejbFindByPrimaryKey with the signature

    public CustomerPK ejbFindByPrimaryKey (CustomerPK pk) throws FinderException

  5. Add a finder method named ejbFindByUserID with the signature

    public CustomerPK ejbFindByUserID (String userID) throws FinderException

  6. Add a business method named getCustomerData with the signature

    public CustomerData getCustomerData()

  7. Implement required methods in the CustomerDAOImpl class.

  8. Deploy the Customer Bean.

  9. Add a create method to the StoreAccess Bean.

    public void ejbCreate() throws javax.ejb.CreateException

  10. Add a business method to the StoreAccess Bean.

    public CustomerData getCustomerData(String userID)

  11. Create a test client named SessionBMPClient under package au.com.tusc.client.

  12. Run your client and test the bean.


Create the Customer BMP Entity Bean :


Go To Package Explorer > Expand Mystore (project) node > select src, right click and a menu will pop up.

On the pop up menu > New > Lomboz EJB Creation Wizard.

Enter package name au.com.tusc.bmp, bean name Customer and select bean type as Bean Manged Entity > Finish.

This will create a package named au.com.tusc.bmp under src and CustomerBean under that package as shown below.

9 7 3 1 2 3 4 5 6 7 8 4 8 :


 
 
打印本文
 
 
  热点搜索
 
 
 



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