EJB - 何时使用远程和/或本地接口? [英] EJB's - when to use Remote and/or local interfaces?

查看:12
本文介绍了EJB - 何时使用远程和/或本地接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Java EE 非常陌生,我正在尝试理解本地接口和远程接口的概念.有人告诉我,Java EE 的一大优势是易于扩展(我相信这意味着您可以在不同的服务器上部署不同的组件).那是远程和本地接口的用武之地吗?如果您希望您的应用程序在不同的服务器上具有不同的组件,您是否应该使用远程接口?如果您的应用程序只驻留在一台服务器上,请使用本地接口?

I'm very new to Java EE and I'm trying to understand the concept of Local interfaces and Remote interfaces. I've been told that one of the big advantages of Java EE is that it is easy to scale (which I believe means you can deploy different components on different servers). Is that where Remote and Local interfaces come in? Are you supposed to use Remote interfaces if you expect your application to have different components on different servers? And use Local interfaces if your application is only going to reside on one server?

如果我的上述假设是正确的,在不确定流量是多少的新应用程序中,您将如何选择是使用本地接口还是远程接口?从使用本地接口开始,然后逐渐升级到适用的远程接口?

If my assumptions above are correct, how would you go about choosing whether to use Local or Remote interfaces for a new application, where your unsure of what the volume of traffic would be? Start off by using Local interfaces, and gradually upgrade to Remote interfaces where applicable?

感谢您的任何澄清和建议.

Thanks for any clarification and suggestions.

推荐答案

我对 Java EE 非常陌生,我正在尝试理解本地接口和远程接口的概念.

I'm very new to Java EE and I'm trying to understand the concept of Local interfaces and Remote interfaces.

在 EJB 规范的初始版本中,EJB 被假定"为远程组件,调用它们的唯一方法是进行远程调用,使用 RMI 语义和它暗示的所有开销(网络调用和对象每个方法调用的序列化).即使 EJB 客户端与 EJB 容器并置在同一虚拟机中,EJB 客户端也必须为此付出代价.

In the initial versions of the EJB specification, EJBs were "assumed" to be remote components and the only way to invoke them was to make a remote call, using RMI semantics and all the overhead it implies (a network call and object serialization for every method call). EJB clients had to pay this performance penalty even when collocated in the same virtual machine with the EJB container.

后来,Sun 意识到大多数业务应用程序实际上并没有在不同的层上分发 EJB,并且他们通过引入本地接口的概念来修复规范(在 EJB 2.0 中),以便与 EJB 容器并置在同一虚拟机中的客户端可以使用直接方法调用来调用 EJB,完全绕过 RMI 语义(以及相关的开销).

Later, Sun realized most business applications were actually not distributing EJBs on a different tier and they fixed the spec (in EJB 2.0) by introducing the concept of Local interfaces so that clients collocated in the same virtual machine with the EJB container can call EJBs using direct method invocation, totally bypassing RMI semantics (and the associated overhead).

有人告诉我,Java EE 的一大优势是易于扩展(我相信这意味着您可以在不同的服务器上部署不同的组件)

I've been told that one of the big advantages of Java EE is that it is easy to scale (which I believe means you can deploy different components on different servers)

Java EE 可以扩展,但这并不一定意味着分发组件.您可以在集群上运行 Web+EJB 应用程序,而无需分离 Web 层和 EJB 层.

Java EE can scale, but this doesn't necessarily means distributing components. You can run a Web+EJB application on a cluster without separating the Web tier and the EJB tier.

如果您希望您的应用程序在不同的服务器上具有不同的组件,您是否应该使用远程接口?如果您的应用程序只驻留在一台服务器上,请使用本地接口?

Are you supposed to use Remote interfaces if you expect your application to have different components on different servers? And use Local interfaces if your application is only going to reside on one server?

我会这样表述:如果客户端不在同一个 JVM 中,则使用远程接口(这并不意味着只使用一个服务器/JVM).

I would phrase it like this: use remote interfaces if the client are not in the same JVM (this doesn't mean using only one server/JVM).

(...) 从使用本地接口开始,然后逐渐升级到适用的远程接口?

(...) Start off by using Local interfaces, and gradually upgrade to Remote interfaces where applicable?

我可能会从使用本地接口开始.并且正如已经暗示的那样,切换到远程接口并不总是强制性的(您可以对 并置 结构进行集群).

I would probably start by using Local interfaces. And as already hinted, switching to remote interfaces is not always mandatory (you can cluster a collocated structure).

我建议检查下面提到的资源(前 2 个已经很旧但仍然相关,另外 2 个是最近的).

I suggest to check the resources mentioned below (the 2 first ones are quite old but still relevant, the 2 others are more recent).

  • Under the Hood of J2EE Clustering by Wang Yu
  • Scaling Your Java EE Applications by Wang Yu
  • Scaling Your Java EE Applications -- Part 2 by Wang Yu

这篇关于EJB - 何时使用远程和/或本地接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆