?? client2.java~45~
字號:
package client;
import javax.rmi.PortableRemoteObject;
import prj32_1.CustomerBmpRemoteHome;
import prj32_1.CustomerBmpRemote;
/*
池里面的對象是可以被重用的(空殼,只含主鍵,并且主鍵會可能被覆蓋)
1:findByXXXX方法,系統(tǒng)為生成一個對象放在池里面,為了節(jié)省內(nèi)存考慮
2:調(diào)用get,set函數(shù),bean都會到達(dá)準(zhǔn)備狀態(tài)
3:如果調(diào)用get,set函數(shù)時,池里面有空殼Bean,系統(tǒng)就根據(jù)遠(yuǎn)程接口使用空殼bean,否則生成對象
*/
public class Client2 {
public static void main(String args[]) throws Exception{
Object obj = EjbFactory.getEjbHome("CustomerBmp");
CustomerBmpRemoteHome home = (CustomerBmpRemoteHome) PortableRemoteObject.
narrow(obj, CustomerBmpRemoteHome.class);
//查詢1
CustomerBmpRemote remote1 = home.findByPrimaryKey("0008");//0008載入這個Bean
//查詢2
CustomerBmpRemote remote2 = home.findByPrimaryKey("0009");//0009載入這個Bean,覆蓋掉0008,但是0008是被保存在context中,可以通過ejbActivate來得到
System.out.println(remote1.getAccount());
System.out.println(remote2.getAccount());//如果在get函數(shù)調(diào)用時,池中沒有相應(yīng)的Bean,系統(tǒng)就在context中尋找相應(yīng)的主鍵,來生成Bean
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -