EE.2.2 Profiles
第 EE.2.2 节 配置
The Java EE 6 specification introduces the notion of “profiles” (see Chapter EE.9, “Profiles”).
Java EE规范第六版引入了“配置”的概念(参考第EE.9章节,“配置”)
A profile is a configuration of the Java EE platform targeted at a specific class of applications.
一个配置是指针对特定类型的Java EE平台的应用程序的配置。
Profiles are not a new concept, nor are they unique to the Java EE platform. The Java Community Process Document (version 2.6) gives the following definition of a profile: “A Specification that references one of the Platform Edition Specifications and zero or more other JCP Specifications (that are not already a part of a Platform Edition Specification). APIs from the referenced Platform Edition must be included according to the referencing rules set out in that Platform Edition Specification. Other referenced specifications must be referenced in their entirety.”
配置不是一个新的概念,也不专属于Java EE平台。Java进程组织文档(第2.6版)这样定义配置:“一个引用平台规范和其他零个或多个其他JCP规范(目前还不是平台规范的部分)的规范”。平台版本的API必须依照平台版本规范的规则引入。其他规范的引用必须引用规范全文。
All Java EE profiles share a set of common features, such as naming and resource injection, packaging rules, security requirements, etc. This guarantees a degree of uniformity across all products, and indirectly applications, that fall under the “Java EE platform” umbrella. This also ensures that developers who are familiar with a certain profile, or with the full platform, can move easily to other profiles, avoiding excessive compartmentalization of skills and experience.
所有的Java EE的配置文件共享一组通用的特性,比如命名和资源的注入、打包规则、安全性需求等。这些平等的对待所有归属于Java EE平台的产品和间接地应用程序。这也确保使用这些配置的开发者可以轻松的移植到其他配置,避免技能和经验的过度区域化。
Beyond the basic functionality outlined above, profiles are free to include any set of technologies that are part of the platform, provided that all rules in the present specification that pertain to the included technologies,either alone or in combination with others, are followed.
除了上述的基本功能,配置可以自由的包含于单独的一个或者与其他共同的技术(当前规范中的所有规则以及技术)都是被允许的。
This last point is worth stressing. If profiles only included pointwise technologies, they would be little more than bundles of APIs with few or no tie-ins. Instead, the definition of profiles adopted here guarantees that, whenever this specification defines requirements on combinations of technologies, these requirements will be honored in all products based on Java EE profiles.
最后一点是最值得强调的。如果配置仅仅被包含在逐点技术,那么他们可能会多一些、少一些或没有捆绑销售的API。作为替代,本处采用的配置的定义保证:无论是否本规范定义的需求基于一组技术,他们都将在所有的基于Java EE配置的所有产品的尊重。
As a concrete example, let’s consider the use of transactions in a servlet container. In isolation, neither the Servlet specification nor the Java Transaction API specification define a complete programming model for portable applications. This specification then fills that gap by introducting its own set of requirements that pertain conjunctly to Servlets and JTA. These requirements must be satisfied by any Java EE profile-based product that includes those two technologies, thus offering application developers a more complete programming model shared across all relevant Java EE profiles.
作为一个具体的例子,让我们研究一下在Servlet容器中的事物的用法。单独的,Servlet规范和Java事物API规范都没有定义一个完整的可移植应用程序的编程模型。本规范通过引入一组结合Servlets和JTA的要求来填补这一缺陷。这些要求必须符合任何包含这两项技术的基于配置的Java EE产品,以此来提供给应用程序开发者一个更完整的跨所有相关的Java EE配置的编程模型。
A separate specification, the Java EE 6 Web Profile Specification, defines the Java EE Web Profile, the first new profile of the Java EE 6 platform.
一个单独的规范,Java EE 6 Web配置规范,定义了Java EE的Web配置,是Java EE 6平台的第一个配置。
Additional profiles may be defined in accordance with the rules of the Java Community Process and those contained in the present specification. In particular, profiles are initiated by submitting a Java Specification Request and are released at completion on their own schedule, independently of any concurrent revision of the platform itself or of other profiles. This ensures maximum flexibility in defining and releasing a new profile or an updated version of an existing one.
当前规范包含的其他的配置也根据JCP的规则进行了定义。特别的,配置发起于提交给Java规范请求,之后按照他们的计划发布完成,独立于任何当前平台或者配置的修订版本。以确保定义和发布新配置或者更新已有版本的最大灵活性。
In accordance with the definition of profiles given above, a profile may end up being either a proper subset of the platform, or a proper superset of it, or it may overlap with it to a certain extent. This flexibility guarantees that future profiles will be able to cover uses well beyond those originally envisioned by the platform specification.
依照上面给出的配置的定义,一个配置最终会是平台的子集、或者平台的超集、亦或是与平台有一部分重合。这样的灵活性保证了将来的配置可以比平台规范的原始定义使用的更好。
As the previous paragraphs made clear, creating a new profile is a significant undertaking. The decision to create a profile should take into account its potential drawbacks, especially in terms of fragmentation and developer confusion. In general, a profile should be created only when there is a natural developer constituency and a well-understood class of applications that can benefit from it. It is also recommended that a profile cast a comprehensive net on its area of interest, to minimize the occurrence of overlapping or competing profiles. Java EE 6 platform features such as optional components, extensibility and pruning can be used by profiles to achieve a better fit to their intended target.
如之前章节所明确的,创建一个新的配置是一个重要的责任。做出创建一个新的配置的决定,需要考虑它的潜在的缺点,特别是碎片化和开发者的困惑。通常来说,只有在一个原始开发者社区和一个熟知的应用程序的类可以从中受益时,才可以创建一个配置。它也建议,一个配置映射了一个它所感兴趣的范围的大范围网络,以减少覆盖或者竞争的发生。Java EE 6 平台的特性,如可选组件、伸缩性,可以被用于配置,以更适合实现其预定目标。