当前位置: 技术问答>java相关
ejb中session bean 如何本地调用entity bean(一定给分)
来源: 互联网 发布时间:2015-08-03
本文导语: ejb中session bean 如何本地调用entity bean(一定给分) | HelloTest test8012.HelloTestHome test8012.HelloTestRemote t...
ejb中session bean 如何本地调用entity bean(一定给分)
|
HelloTest
test8012.HelloTestHome
test8012.HelloTestRemote
test8012.HelloTest
Stateless
Container
ejb/gy_device
Entity
test8012.GyDeviceHome
test8012.GyDevice
GyDevice
ejb/gy_province
Entity
test8012.GyProvinceHome
test8012.GyProvince
GyProvince
//本地调用
private GyDeviceHome getGyDeviceHome()
{
Context ctx = null;
try
{
System.out.println("查找 gy_device entity bean!");
ctx = new InitialContext();
Object ref = ctx.lookup("java:comp/env/ejb/gy_device");
System.out.println("查找结束");
return (GyDeviceHome)ref;
}
catch (Exception E)
{
throw new EJBException(E.getMessage());
}
finally
{
try
{
if (ctx != null)
{
ctx.close();
}
}
catch (Exception ex)
{
throw new EJBException(ex.getMessage());
}
}
}