Topic: 这段什么意思,前后矛盾啊

  Print this page

1.这段什么意思,前后矛盾啊 Copy to clipboard
Posted by: liang
Posted on: 2005-08-29 23:29

To indicate a system-level problem, such as the inability to connect to a database, a business method should throw the javax.ejb.EJBException. When a business method throws an EJBException, the container wraps it in a RemoteException, which is caught by the client. The container will not wrap application exceptions such as BookException. Because EJBException is a subclass of RuntimeException, you do not need to include it in the throws clause of the business method.

这第一句跟最后一句矛盾不?晕了

2.Re:这段什么意思,前后矛盾啊 [Re: liang] Copy to clipboard
Posted by: ww1ww1
Posted on: 2005-08-29 23:46

我的翻译:
为了描述一个系统级的问题,例如不能连接数据库,一个业务方法应该抛出javax.ejb.EJBException。
当一个业务方法抛出一个EJBException,容器将其包装成为一个RemoteException,这个RemoteException将被客户端捕抓到。
容器不会将其包装成为应用类型的异常,例如BookException(这个是自定义的Exception)。
因为 EJBException 是RemoteException的子类,你不需要将其定义(包含)在业务方法的抛出异常中。

理解:EJBException是RemoteException的子类,在EJB中,business method 抛出这个子类EJBException的父类RemoteException。

3.Re:这段什么意思,前后矛盾啊 [Re: liang] Copy to clipboard
Posted by: liang
Posted on: 2005-08-30 00:00

因为 EJBException 是RuntimeException的子类,你不需要将其定义(包含)在业务方法的抛出异常语句中。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923