📄 client3.java~14~
字号:
package client;
import javax.rmi.PortableRemoteObject;
import prj32_1.CustomerBmpRemoteHome;
import prj32_1.CustomerBmpRemote;
/*
准备状态下,不存在两个Bean的主键一样,
池状态下,主键没有太大意义,只是作为到达池状态一刹那间的一个标识
*/
public class Client3 {
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
remote1.getAccount();//到达了准备状态
//查询2
CustomerBmpRemote remote2 = home.findByPrimaryKey("0008");//0009载入这个Bean,覆盖掉0008,但是0008是被保存在context中,可以通过ejbActivate来得到
remote2.getAccount();//此时不是用的22行生成的那个Bean,而是20行到达准备状态下的那个Bean
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -