当前位置: 技术问答>java相关
关于Local接口和Remote接口!(请看过SUN的PetStore例子的朋友进来看看)!!!
来源: 互联网 发布时间:2015-05-10
本文导语: 在1.3版本的PETSTORE中,它用的全是Local接口 而以前的1.2.2版本的例子,用的全是Remote 这是为什么? Local接口和Remote接口分别在什么样的场合使用呢? | local 是同一个容器调用的,remote可以跨容...
在1.3版本的PETSTORE中,它用的全是Local接口
而以前的1.2.2版本的例子,用的全是Remote
这是为什么?
Local接口和Remote接口分别在什么样的场合使用呢?
而以前的1.2.2版本的例子,用的全是Remote
这是为什么?
Local接口和Remote接口分别在什么样的场合使用呢?
|
local 是同一个容器调用的,remote可以跨容器调用
|
举个最简单的例子:
如果一个SESSION BEAN要调用一个ENTITY BEAN,在1.3以前要使用REMOTE接口这样的话,就和客户请求一样使用RMI处理,这样的话效率比较低,所以从1.3开始出现了LOCAL接口,这一接口说的简单点就是通过本地调用对EJB进行访问,使的效率大大提高.但也有限制,就是调用方一定要在同一容器内.详细情况可看SUN的技术文档!
如果一个SESSION BEAN要调用一个ENTITY BEAN,在1.3以前要使用REMOTE接口这样的话,就和客户请求一样使用RMI处理,这样的话效率比较低,所以从1.3开始出现了LOCAL接口,这一接口说的简单点就是通过本地调用对EJB进行访问,使的效率大大提高.但也有限制,就是调用方一定要在同一容器内.详细情况可看SUN的技术文档!
|
Remote and local access
An EJB 2.0 component can be accessed remotely or locally. Clients thataccess a remote bean use the bean’s remote and remote home interfaces. Aremote home is often referred to as the home interface. A client with remote access to a bean can run on a different machine and use a different Java Virtual Machine (JVM) than the bean itself. In method calls to a remote bean, parameters are passed by value, which helps maintain loose coupling between the client and the bean.
A client with local access to a bean must run in the same JVM as the bean it accesses. A local client won’t be an external client application, but rather another enterprise bean or web component. In method calls to a local bean, parameters are passed by reference, resulting in a tighter coupling between the calling bean or web component and the called bean.
Like the remote interface, the local interface provides access to the bean’s business methods, while its local home interface provides access to the methods that control the life cycle of the bean as well as its finder methods. Often entity beans that have a container-managed relationship with other entity beans have local access to them.
Because beans with local interfaces must run in the same JVM, there is no need for remote calls. Therefore, the overhead of serializing and transporting objects is reduced. Usually this means greater performance.
An EJB 2.0 component can be accessed remotely or locally. Clients thataccess a remote bean use the bean’s remote and remote home interfaces. Aremote home is often referred to as the home interface. A client with remote access to a bean can run on a different machine and use a different Java Virtual Machine (JVM) than the bean itself. In method calls to a remote bean, parameters are passed by value, which helps maintain loose coupling between the client and the bean.
A client with local access to a bean must run in the same JVM as the bean it accesses. A local client won’t be an external client application, but rather another enterprise bean or web component. In method calls to a local bean, parameters are passed by reference, resulting in a tighter coupling between the calling bean or web component and the called bean.
Like the remote interface, the local interface provides access to the bean’s business methods, while its local home interface provides access to the methods that control the life cycle of the bean as well as its finder methods. Often entity beans that have a container-managed relationship with other entity beans have local access to them.
Because beans with local interfaces must run in the same JVM, there is no need for remote calls. Therefore, the overhead of serializing and transporting objects is reduced. Usually this means greater performance.
|
理论上应该是可以得
根据规范上说的, 只要是同一个机器上的同一个java 虚拟机就行
根据规范上说的, 只要是同一个机器上的同一个java 虚拟机就行