Services provide fundamental functionality without which the application server would fail to function. 服务是在应用服务器没有失去作用的时候提供的基础的功能性。

They correspond to "Tools" in CMF (Zope 2) from which some of the semantics were also inspired.

他们相当于CMF(Zope 2)中符合"工具",并从中得到些许的灵感。

Services do not depend on other components at all. 服务根本不依赖于其他组件。

You only interact with other components by passing them as arguments to the constructor or the methods of the service. 你只需要向其他组件的构造函数或者服务方法传递参数来与它们交互。

Any given application should have only a few services that cover the most fundamental functionality. 任何的给予应用应该只有少许包括最基本的功能性的服务。

When dealing with locality, services should always delegate requests upward — up to the global version of the service — if a request can not be answered locally.

当处理本地请求时,如果本地不能响应,那么服务应该总是向上派发请求,—直到该服务的全局版本。

The most fundamental services are the registries of the components themselves.

最基本的服务是组件注册他们自己。

Whenever you register a class as a utility using ZCML, for example, then the class is registered in the "Utility Service" and can be retrieved later using the service. 举例来说,每当你使用ZCML将类注册为一个实用工具的时候,这个类就注册到在“Utility Service”里,并且可以随后通过使用该服务来检索到它。

And yes, we also have a "Service Service" that manages all registered services.

是的,我们还有一个 "服务的服务(Service Service)"来管理所有的注册服务。

Another service is the Error Reporting service, which records all errors that occurred during the publication process of a page. 另外的一个服务是错误报告(Error Reporting)服务, 用来记录所有的在页面发布过程中产生的错误。

It allows a developer to review the details of the error and the state of the system/request at the time the error occurred.

当错误发生的时候,它允许开发者检讨错误的细节和检讨系统/请求的状态。

Figure 7.1: UML diagram of the Error Reporting Service.

图 7.1: 错误报告服务的 UML 图表。

A convention for service interfaces is that they only contain accessor methods. 服务接口的一个习惯性用法是他们只包含“访问者(accessor)”方法。

Mutator methods are usually implementation-specific and are provided by additional interfaces. 变异者(Mutator)”方法通常是特别实现的并且是由附加的接口提供的。

A consequence of this pattern is that services are usually not modified once the system is running. 这样设计的结果是一旦系统在运行中,那么服务通常不能被修改。

Please note though that we strongly discourage developers from writing services for applications. 请注意我们强烈地劝诫开发者放弃为应用编写服务。

Please use utilities instead.

请改为使用实用工具。

Services make use of acquisition by delegating a query if it cannot be answered locally. 如果请求在本地不能得到回答,那么服务就藉由派发请求的方式来获得

For example, if I want to find a utility named "hello 1" providing the interface IHello and it cannot be found at my local site, then the Utility Service will delegate the request to the parent site. 举例来说,如果我想找一个名叫 "hello 1" 的实用工具,它提供了IHello接口并且在本地站点没有找到,那么实用工具服务(Utility Service)就将该请求派发到父站点里。

This goes all the way up to the global Utility Service. 这就是到达全局实用工具服务(Utility Service)所有的途径。

Only if the global service cannot provide a result, an error is returned. 如果全局服务也不能提供结果时,那么一个错误将被返回。

For more details about local and global components see "Global versus Local" below.

更多关于本地和全局组件的内容请参考下面的“全局vs本地”章节。