1. Open the EJB Module and Create CMP 2.0 Entity Bean
2..Right Click The CMP ---- Select Lanuch DTO/Façade Wizard
The Wizard will Auto Create some .java Include
For Example: My module name is ContractSample
DTO
ContractSampleDto.java
ContractSampleDtoAssemble.java
EJB
Entity
ContractSample.java
ContractSampleBean.java
ContractSampleHome.java
Session
ContractSampleFacade.java
ContractSampleFacadeBean.java
ContractSampleFacadeHome.java
ContractSampleFacadeLocal.java
ContractSampleFacadeLocalHome.java
IMPL
ContractSampleDelegate.java
DTO
ContractSampleDto.java
ContractSampleDtoAssemble.java
Explain:
Using Value Object Pattern
Efficiently transfer remote , fine-grained data by sending a coarse-grained view of the data
EJB
Entity
ContractSample.java
ContractSampleBean.java
ContractSampleHome.java
Session
ContractSampleFacade.java
ContractSampleFacadeBean.java
ContractSampleFacadeHome.java
ContractSampleFacadeLocal.java
ContractSampleFacadeLocalHome.java
Explain
Provide a unified , workflow-oriented interface to a set of enterprise beans
ContractSampleFacadeBean.java
Write the business logic code in ContractSampleFacadeBean.java
ContractSampleFacadeBean implement Remote and Local Interface method
ContractSampleFacade.java
Provide remote interface
ContractSampleFacadeLocal.java
Provide Local Interface
ContractSampleFacade.java
Remote create() Mehtod
ContractSampleFacadeLocal.java
Local create() method
IMPL
ContractSampleDelegate.java
The Business Logic Mothod Interface
The Client used ContractSampleDelegate’s Object transfer business logic method()
In Common Use Method of EJB
1、New(Form add)
----------------------------Action--------------------------------
OrderDirectFacadeUtil.getLocalHome().create().create(data);
//OrderDirectFacadeLocalHome home = OrderDirectFacadeUtil.getLocalHome();
//OrderDirectFacadeLocal order = home.create();
//OrderDirectData orderdata = order.create(data);
-------------------------OrderDirectFacadeEJB-----------------------
public OrderDirectData create(OrderDirectData cd)
throws javax.ejb.CreateException, javax.naming.NamingException {
return getLocalHome().create(cd).getData();
}
Delete
----------------------------Action--------------------------------
Boolean isDel = OrderRecordFacadeUtil.getLocalHome().create().deleteOrderRecord(data);
-------------------------OrderDirectFacadeEJB-----------------------
public boolean deleteOrderRecord(OrderRecordData data) throws Exception {
//OrderRecordUtil.getLocalHome().findByPrimaryKey(data.getPrimaryKey()).remove();
this.getLocalHome().findByPrimaryKey(data.getPrimaryKey()).remove();
}
Modify
----------------------------Action--------------------------------
Fill the form’s data to DAO
OrderRecordFacadeUtil.getLocalHome().create().updateOrderRecord(data);
-------------------------OrderDirectFacadeEJB-----------------------
本文地址:http://com.8s8s.com/it/it14712.htm