Java EE - 谁来实现规范? [英] Java EE - who implement the specification?

查看:28
本文介绍了Java EE - 谁来实现规范?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在核心 Java 和 Java EE 方面有一些经验.我阅读了关于 SO 的各种问题以了解 Java EE 到底是什么?SO 中的几个答案是: what-exactly-is-java-ee , what-is-java-ee

I have some experience in core Java and Java EE. I read the various question on SO to understand what exactly Java EE is? And few answers in SO are: what-exactly-is-java-ee , what-is-java-ee

1) 如果 Java EE 只是一个规范,那么谁来实现它们?应用服务器(如 JBOSS、GlassFish)是否实现了这些规范?

1) If Java EE is just a specification, who does implement them? Do Application Servers (like JBOSS, GlassFish) implement these specifications?

2) 如果我是对的,EJB 规范是由 EJB 容器实现的,我相信 EJB 容器是应用服务器的一部分.现在,当我们作为开发人员编写 EJB 代码时,我们实际上在做什么?我的疑问是,EJB 容器实现了 EJB 规范,那么我们是否覆盖了 EJB 的某些规范部分"?为什么 EJB 的某些部分是由 EJB 容器实现的,而某些东西是开发人员正在编写的?还是 EJB 的某些部分必须由 EJB 容器提供,而某些部分必须由开发人员开发?我很难理解这一点.

2) If I am correct the EJB specification is implemented by EJB container, and I believe EJB Container is part of Application Server. Now, when we as developers write an EJB code, what are we actually doing? The doubt I have is, EJB container implements the EJB specification, so are we overriding some "specification part" of the EJB? How come, some part of EJB is implemented by the EJB container and some thing which developers are writing? OR is it that some part of the EJB have to be provided by EJB container and some part to be developed by developers? I am having difficulty in undestanding this.

请问有人可以帮助理解这一点吗?

Please can anyone help in understanding this?

推荐答案

任何人都可以实现 java ee 规范 (JSR342),或任何 jsr 这是其中的一部分.当他们这样做时,他们可以(在购买并通过 兼容性测试后Suite) 声称与规范兼容.有许多供应商的应用程序服务器与 兼容使用 java ee,但没有供应商实现完整的 java ee 规范.例如,glassfish(java ee 参考实现)使​​用 Red Hat 的 CDI 实现.有时,供应商不实现 java ee 规范的任何部分,他们获取 glassfish,添加供应商特定的库,并以他们的名义发布.要声明兼容性,他们仍然需要通过认证过程并运行 CTS.

Anybody can implement the java ee specification (JSR342), or any jsr that's part of it. When they do, they can (after buying and passing Compatibility Test Suite) claim to be compatible with the specification. There is a number of vendors with their application servers which are compatible with java ee, but no vendor implement full java ee specification. For instance, glassfish (the java ee reference implementation) uses Red Hat's CDI implementation. Sometimes, the vendor does not implement any part of the java ee specification, they grab glassfish, add their vendor specific libraries, and release it under their name. To claim compatibility, they still need to go through the certification process and run CTS.

要找出所有实施该规范的供应商并非易事,因为并非所有供应商都经过认证过程.例如,Apache CXF 本身没有经过认证,而是作为红帽的 JBoss.

To find out all the vendors who implement the specification is not so easy, since not all of them go through the certification process. For instance, Apache CXF is not certified on its own, rather it gets certified as part of Red Hat's JBoss.

每个规范都有一个 API 和一个书面的 pdf,两者都定义了每个实现的强制性行为.这就是您在编写 EJB 代码时使用的内容.例如,当您创建一个 ejb 时:

Each specification has an API and a written pdf, both of which define the mandatory behaviour of each implementation. That is what you use when write EJB code. For instance, when you create an ejb:

import javax.ejb.Singleton;
@Singleton
public class MySingleton{
   ... 
}

@Singleton 注释是规范的一部分,但 MySingleton 类是您的 EJB 代码,它不是规范的一部分.EJB 容器然后知道如何处理该类.

@Singleton annotation is part of the specification, but MySingleton class is your EJB code, it's not part of the specification. The EJB container then knows what to do with the class.

这篇关于Java EE - 谁来实现规范?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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