`
huangxx
  • 浏览: 316285 次
  • 来自: ...
社区版块
存档分类
最新评论

ejb home local remote

阅读更多
从JBUIDER6中翻译的关于接口的资料:
一个EJB至少为会话BEAN或实体BEAN提供两种接口。对于EJB 1.x,你至少要创建一个home interface和remote interface;对于EJB 2.0可以有一个Remote home,Remote interface,还可以有一个Local home,Local interface。Remote home,Remote interface为客户端提供了BEAN的远程视图,而Local home,Local  interface为客户端提供了BEAN的本地视图。remote and/or local home interface定义了客户端程序用来创建、定位、销毁BEAN实例的方法;remote/local interface实现了BEAN的商业方法客户端是通过remote/local interface来访问这些方法的。
BEAN的home interface,无论是remote还是local,控制了BEAN的生命周期。它包含了创建、查找、删除一个BEAN实例的方法。作为BEAN的提供商,你必须定义home 接口,但可以不实现它。EJB容器会产生一个home对象,并返回一个引用给BEAN。
一个EJB的客户端可以有BEAN的远程视图或本地视图,remote bean有一个home interface,它扩展了EJBHome  interface;local bean有一个home interface,它扩展了EJBLocalHome interface。每个remote /local interface都扩展了javax.ejb.EJBHome  interface。

一个实体BEAN是被设计用来为多个客户端服务的,一个客户端创建了实体BEAN,其他客户端也应该可以使用它。
remote or local interface描述了客户端程序可以调用的商业方法。当在remote or local interface中定义了这些方法后,你要在BEAN class中实现它,客户端不会直接访问BEAN,他们是通过remote or local interface来访问这些方法的。
remote or local interface中定义的方法必须遵守以下原则:
它必须是public的;
如果是定义在remote interface中的方法,它必须抛出java.rmi.RemoteException;如果不是,它不能抛出java.rmi.RemoteException。
所有客户端能访问的方法必须在remote or local interface中定义。


BEAN的interface的几种选择:
选择Remote意味着EJB Designer生成一个Bean class,Remote home和Remote interface。
选择Local意味着EJB Designer生成一个Bean class,Local home和Local interface。
如果选择Remote/Local,EJB Designer将生成Bean class,Remote home,Remote interface,Local home和Local interface。在JBUILDER中,会话BEAN默认是remote的,实体BEAN默认是local的。
如果你为一个会话BEAN (Component)选择了Remote/Local,将生成的文件如下:
ComponentHome - the remote home interface;
ComponentBean - the bean class;
Component - the remote interface ;
ComponentLocalHome - the local home interface ;
ComponentLocal - the local interface。

如果你为一个实体BEAN (Component)选择了Remote/Local,将生成的文件如下:
ComponentHome - the local home interface ;
ComponentBean - the bean class ;
Component - the local interface ;
ComponentRemoteHome - the remote home interface ;
ComponentRemote - the remote interface。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics