ejb的定义配置及其使用

1、ejb定义
a、定义一个ejb接口:继承EJBObject类,定义方法名;
b、定义ejb类:实现SessionBean接口,并实现ejb接口中的方法;
c、定义home类:继承EJBHome类,创建ejb接口对象。
例如:
public interface VentureHome extends EJBHome {
Venture create() throws CreateException, EJBException,RemoteException;}

2、ejb的配置
a、在ejb-jar.xml中配置session和method
例如:
session的配置:
<session id="Venture">
<ejb-name>Venture</ejb-name>
<home>com.iss.itreasury.bill.venture.bizlogic.VentureHome</home>
<remote>com.iss.itreasury.bill.venture.bizlogic.Venture</remote>
<ejb-class>com.iss.itreasury.bill.venture.bizlogic.VentureEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref id="ResourceRef_1293009859115">
<description>DataSource Resource</description>
<res-ref-name>jdbc/cpf/type4</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</session>

method的配置:
<method>
<ejb-name>Venture</ejb-name>
<method-name>*</method-name>
</method>
b、web.xml的配置
<ejb-ref id="EjbRef_1293021770030">
<description>
</description>
<ejb-ref-name>TransferLoanContractDepositHome</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.iss.itreasury.settlement.transferloancontract.bizlogic.TransferLoanContractDepositHome</home>
<remote>com.iss.itreasury.settlement.transferloancontract.bizlogic.TransferLoanContractDeposit</remote>
<ejb-link>itreasuryEJB.jar#TransferLoanContractDeposit</ejb-link>
</ejb-ref>
3、ejb的使用方法:
使用ejb类时不能直接new,调用方法是可能不报错,但是执行代码时会跳过此方法。
正确的方式是:先定义一个TransCurrentDepositHome对象,用EJBHomeFactory类生成,同时定义一个ejb接口的对象,有TransCurrentDepositHome类的create()方法创建。
例如:
TransCurrentDeposit transCurrentDepositFacade;
TransCurrentDepositHome home =(TransCurrentDepositHome) EJBHomeFactory.getFactory().lookUpHome(TransCurrentDepositHome.class);
transCurrentDepositFacade = (TransCurrentDeposit) home.create();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值