前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >UML2.51边译边学-组件

UML2.51边译边学-组件

作者头像
面向对象思考
发布2021-10-14 16:16:28
4550
发布2021-10-14 16:16:28
举报

本文是UML规范2.5.1中组件相关部分中文翻译。原文可从https://www.omg.org/spec/UML/2.5.1下载。

11.6.1 Summary(总结)

This sub clause specifies a set of constructs that can be used to define software systems of arbitrary size and complexity.In particular, it specifies a Component as a modular unit with well-defined Interfaces that is replaceable within its environment. The Component concept addresses the area of component-based development and component-based system structuring, where a Component is modeled throughout the development life cycle and successively refined into deployment and run-time.

本节规定了一组结构,可用于定义任意大小和复杂性的软件系统。特别是,它将组件规定为具有可在其环境中替换的明确定义的接口的模块化单元。组件概念涉及基于组件的开发和基于组件的系统结构领域,其中组件在整个开发生命周期中被建模,并连续细化到部署和运行时。

An important aspect of component-based development is the reuse of previously constructed Components. A Component can always be considered an autonomous unit within a system or subsystem. It has one or more provided and/or required Interfaces (potentially exposed via Ports), and its internals are hidden and inaccessible other than as provided by its Interfaces. Although it may be dependent on other elements in terms of Interfaces that are required, a Component is encapsulated and its Dependencies are designed such that it can be treated as independently as possible. As a result, Components and subsystems can be flexibly reused and replaced by connecting (“wiring”) them together.

基于组件的开发的一个重要方面是重用先前构建的组件。组件始终可以被视为系统或子系统中的自治单元。它有一个或多个提供的和/或必需的接口(可能通过端口暴露),并且它的内部是隐藏的,除了由其接口提供的之外,无法访问。尽管就所需的接口而言,它可能依赖于其他元素,但组件是封装的,并且其依赖项被设计为可以尽可能独立地对待它。因此,组件和子系统可以通过将它们连接(“接线”)在一起来灵活地重用和替换。

The aspects of autonomy and reuse also extend to Components at deployment time. The artifacts that implement Component are intended to be capable of being deployed and re-deployed independently, for instance to update an existing system.

自治和重用的想法也在部署时扩展到组件。实现组件的制品旨在能够独立部署和重新部署,例如更新现有系统。

The Components package supports the specification of both logical Components (e.g., business components, process components) and physical Components (e.g., EJB components, CORBA components, COM+ and .NET components, WSDL components, etc.), along with the artifacts that implement them and the nodes on which they are deployed and executed. It is anticipated that profiles based around Components will be developed for specific component technologies and associated hardware and software environments.

组件包支持定义逻辑组件(例如,业务组件、流程组件)和物理组件(例如,EJB 组件、CORBA 组件、COM+ 和 .NET 组件、WSDL 组件等),以及实现、部署和执行它们的节点。预计将会针对特定的组件技术和相应的硬件和软件环境开发基于组件的配置文件。

11.6.3 Semantics(语义)

11.6.3.1 Components(组件)

A Component represents a modular part of a system that encapsulates its contents and whose manifestation is replaceable within its environment.

组件代表系统的模块化部分,它封装了其内容并且表现形式在其环境中是可替换的。

A Component is a self-contained unit that encapsulates the state and behavior of a number of Classifiers. A Component specifies a formal contract of the services that it provides to its clients and those that it requires from other Components or services in the system in terms of its provided and required Interfaces.

组件是一个独立的单元,它封装了许多类目的状态和行为。组件根据其提供的和所需的接口指定了它向其客户提供的服务以及它从系统中的其他组件或服务要求的服务的正式约定。

A Component is a substitutable unit that can be replaced at design time or run-time by a Component that offers equivalent functionality based on compatibility of its Interfaces. As long as the environment is fully compatible with the provided and required Interfaces of a Component, it will be able to interact with this environment. Similarly, a system can be extended by adding new Component types that add new functionality. Larger pieces of a system’s functionality may be assembled by reusing Components as parts in an encompassing Component or assembly of Components, and wiring them together.

一个组件是一个可替代的单元,可以在设计时或运行时被一个组件替换,该组件提供基于其接口兼容性的等效功能。只要环境与组件提供的和所需的接口完全兼容,它就能够与该环境进行交互。类似地,可以通过添加新的组件类型来扩展系统,从而增加新的功能。系统功能的较大部分可以通过将组件重新用作包含组件或组件组件中的部件,并将它们连接在一起来组装。

A Component is modeled throughout the development life cycle and successively refined into deployment and run-time. A Component may be manifested by one or more Artifacts, and in turn, that Artifact may be deployed to its execution environment. A DeploymentSpecification may define values that parameterize the Component’s execution. (See

Deployments – Clause 19).

组件在整个开发生命周期中都被建模,并连续细化为部署和运行时。一个组件可以由一个或多个制品表现出来,反过来,制品可以部署到它的执行环境中。 部署定义可以定义参数化组件执行的值。(参见部署 – 第 19 节)。

The required and provided Interfaces of a Component allow for the specification of StructuralFeatures such as attributes and Association ends, as well as BehavioralFeatures such as Operations and Receptions. A Component may implement a provided Interface directly, or its realizing Classifiers may do so, or they may be inherited. The required and provided Interfaces may optionally be organized through Ports; these enable the definition of named sets of provided and required Interfaces that are typically (but not always) addressed at run-time.

组件所需和提供的接口允许定义结构特征,例如属性和关联端,以及行为特征,例如操作和接收。一个组件可以直接实现一个提供的接口,或者由它的实现类目提供,或者它们可以被继承。可以选择通过端口组织所需和提供的接口;这些可以定义提供和所需接口的命名集,这些接口通常(但不总是)在运行时定位。

A Component has an external view (or “black-box” view) by means of its publicly visible Properties and Operations. Optionally, a Behavior such as a ProtocolStateMachine may be attached to an Interface, Port, and to the Component itself, to define the external view more precisely by making dynamic constraints in the sequence of Operation calls explicit.

组件通过其公开可见的属性和操作提供外部视图(或“黑盒”视图)。可选地,可以将诸如协议状态机之类的行为附加到接口、端口和组件本身,以定义通过明确操作调用序列中的动态约束来更精确地获取外部视图。

The wiring between Components in a system or other context can be structurally defined by using Dependencies between compatible simple Ports, or between Usages and matching InterfaceRealizations that are represented by sockets and lollipops (see 10.4.4) on Components on Component diagrams. Creating a wiring Dependency between a Usage and a matching InterfaceRealization, or between compatible simple Ports, means that there may be some additional information, such as performance requirements, transport bindings, or other policies that determine that the Interface is realized in a way that is suitable for consumption by the depending Component. Such additional information could be captured in a profile by means of stereotypes.

系统或其他上下文中的组件之间的接线可以通过使用兼容的简单端口之间的依赖关系来结构化定义,或者在使用和匹配的接口实现之间进行定义,这些接口由组件图中组件上的插座和棒棒糖(参见 10.4.4)表示。在使用和匹配的接口实现之间或在兼容的简单端口之间创建接线依赖意味着可能有一些附加信息,例如性能要求、传输绑定或其他确定接口以某种方式实现的策略适合由依赖组件消耗。此类附加信息可以通过衍型在配置文件中捕获。

A Component also has an internal view (or “white-box” view) by means of its private Properties and realizing Classifiers. This view shows how the external Behavior is realized internally. Dependencies on the external view provide a convenient overview of what may happen in the internal view; they do not prescribe what must happen. More detailed behavior specifications such as Interactions and Activities may be used to detail the mapping from external to internal behavior.

组件还通过其私有属性和实现类目具有内部视图(或“白盒”视图)。该视图显示了外部行为是如何在内部实现的。对外部视图的依赖为内部视图中可能发生的事情提供了方便的概览;它们没有规定必须发生什么。可以使用更详细的行为定义(例如交互和活动)来详细说明从外部行为到内部行为的映射。

The execution time semantics for an assembly Connector in a Component are that requests (signals and operation invocations) travel along an instance of a Connector. The execution semantics for multiple Connectors directed to and from different roles, or n-ary Connectors where n> 2, indicates that the instance that will originate or handle the request will be determined at execution time.

组件中装配连接器的执行时间语义是请求(信号和操作调用)沿着连接器的实例传输。多个连接器的执行语义指向和来自不同角色的,或n( n> 2 )元连接器,表明将在执行时确定将发起或处理请求的实例。

A number of UML standard stereotypes exist that apply to Component. For example, «Subsystem» to model large-scale Components, and «Specification» and «Realization» to model Components with distinct specification and realization definitions, where one specification may have multiple realizations (see the Standard Profiles).

存在许多适用于组件的 UML 标准构造型。例如,“子系统”对大规模组件建模,“定义”和“实现”对具有不同定义和实现的组件建模,其中一个定义可能有多个实现(参见标准配置文件)。

A Component may be realized (or implemented) by a number of Classifiers. In that case, a Component owns a set of ComponentRealizations to these Classifiers.

组件可以由多个类目实现(或实装)。在这种情况下,组件拥有一组针对这些分类器的组建实现。

A component acts like a Package for all model elements that are involved in or related to its definition, which should be either owned or imported explicitly. Typically the Classifiers that realize a Component are owned by it.

对于所有涉及或与其定义相关的模型元素,一个组件就像一个包,应该明确拥有或导入。通常,实现组件的类目归它所有。

11.6.4 Notation(记法)

A Component is shown as a Classifier rectangle with the keyword «component». Optionally, in the right hand corner a Component icon can be displayed. This is a Classifier rectangle with two smaller rectangles protruding from its left hand side. If the icon symbol is shown, the keyword «component» may be hidden.

组件显示为带有关键字 «component» 的类目矩形。或者,可以在右上角显示一个组件图标。这是一个类目矩形,其左侧有两个较小的矩形突出。如果显示图标符号,则可能隐藏关键字 «component»。

The attributes, operations and internal structure compartments all have their normal meaning. The internal structure uses the notation defined in StructuredClassifiers (11.2).

属性、操作和内部结构分区都有其正常含义。内部结构使用在 StructuredClassifiers (11.2) 中定义的符号。

The provided and required Interfaces of a Component may be shown by means of ball (lollipop) and socket notation (see 10.4.4), where the lollipops and sockets stick out of the Component rectangle.

组件的提供和需要的接口可以通过球(棒棒糖)和插座符号(见 10.4.4)来表示,其中棒棒糖和插座伸出组件矩形。

For displaying the full signature of a provided or required Interface of a Component, the Interfaces can also be displayed as normal expandable Classifier rectangles. For this option, the Interface rectangles are connected to the Component rectangle by appropriate dependency arrows, as specified in 7.7.4 and 10.4.4.

为了显示组件提供或需要的接口的完整签名,接口也可以显示为正常的可扩展类目矩形。对于此选项,接口矩形通过适当的依赖箭头连接到组件矩形,如 7.7.4 和 10.4.4 中所述。

A conforming tool may optionally support compartments named “provided interfaces” and “required interfaces” listing the provided and required Interfaces by name. This may be a useful option in scenarios in which a Component has a large number of provided or required Interfaces.

符合标准的工具可以选择支持名为“提供的接口”和“所需的接口”的隔间,按名称列出提供的和所需的接口。在组件具有大量提供或需要的接口的情况下,这可能是一个有用的选项。

Additional optional compartments “realizations” and “artifacts” may be used to list the realizing Classifiers (Classifiers reached by following the realization property) and manifesting Artifacts (Artifacts that manifest this component – see 19.3).

额外的可选隔间“实现”和“制品”可用于列出实现类目(通过遵循实现属性到达的类目)和显示制品(显示该组件的制品 - 参见 19.3)。

A ComponentRealization is notated in the same way as a Realization dependency (i.e., as a general dashed line with a hollow triangle as an arrowhead).

组件实现以与实现依赖项相同的方式表示(即,作为带有空心三角形作为箭头的一般虚线)。

The packagedElements of a Component may be displayed in an optional compartment named “packaged elements,” according to the specification for optional compartments for ownedMembers set out in 9.2.4.

根据 9.2.4 中规定的拥有成员的可选隔间的规范,组件的 packagedElements 可以显示在名为“packaged elements”的可选隔间中。

11.6.5 Examples(示例)

An overview diagram can show Components related by Dependencies, which signify some further unspecified kind of dependency between the components, and by implication a lack of dependency where there are no Dependency arrows.

概览图可以显示由依赖关系相关的组件,这意味着组件之间存在某种进一步未指定的依赖关系,并暗示在没有依赖关系箭头的情况下不存在依赖关系。

Figure 11.40 shows an external (“black-box”) view of a Component by means of interface lollipops and sockets sticking out of the Component rectangle.

图 11.40 显示了一个组件的外部(“黑盒”)视图,通过接口棒棒糖和从组件矩形伸出的插座。

Figure 11.41 shows provided and required interfaces listed in optional compartments.

图 11.41 显示了在可选隔间中列出的提供和需要的接口。

Figure 11.42 shows a “white box” view of a Component listing realizing Classifiers and manifesting Artifacts in additional optional compartments.

图 11.42 显示了一个组件列表的“白盒”视图,它实现了分类器并在额外的可选隔间中显示了工件。

Figure 11.43 shows explicit representation of the provided and required Interfaces using Dependency notations, allowing Interface details such as Operations to be displayed.

图 11.43 使用依赖符号显示了提供的和所需的接口的显式表示,允许显示诸如操作之类的接口详细信息。

Figure 11.44 shows a set of Classifiers that realize a Component with realization arrows representing the ComponentRealizations.

图 11.44 显示了一组实现组件的类目,实现箭头表示组建实现。

Figure 11.45 shows owned Classes that realize a Component nested within an optional “packaged elements” compartment of the Component shape.

图 11.45 显示了拥有的类,这些类实现了嵌套在组件形状的可选“打包元素”隔间中的组件。

Figure 11.46 shows various ways of wiring Components using Dependencies.

图 11.46 显示了使用依赖关系连接组件的各种方式。

The Dependency on the right of the figure is from the Usage of OrderableItem to the InterfaceRealization of OrderableItem. This also shows that “/OrderableItem” is an Interface that is implemented by a supertype of Product, following the notation specified in 10.4.4.

The Dependency between the AccountPayable Ports illustrates the notational option of showing the dependency arrow joining the socket to the lollipop, when a Dependency is wired between simple Ports.

图中右边的Dependency是从OrderableItem的使用到OrderableItem的接口实现。这也表明“/OrderableItem”是一个由 Product 的超类型实现的接口,遵循 10.4.4 中指定的符号。

When realizing Classifiers are shown in a packaged elements compartment, a Dependency may be shown from a simple Port to a realizing Classifier to indicate that the Interface provided or required by the Port is dependent in some way upon the Classifier. This is illustrated by the Dependency from AccountPayable to OrderHeader, which indicates that something about the fact that the Component requires AccountPayable is dependent upon OrderHeader.

当实现类目显示在封装元素隔间中时,可以从简单端口到实现类目显示依赖关系,以指示端口提供或所需的接口以某种方式依赖于类目。从 AccountPayable 到 OrderHeader 的依赖关系说明了这一点,这表明组件需要 AccountPayable 的事实依赖于 OrderHeader。

Figure 11.47 shows an internal or white-box view of the internal structure of a Component that contains other Components with simple Ports as parts of its internal assembly. The assembly Connectors use ball-and-socket notation. The delegation connectors use the notational option that the Connector line can end on the ball or socket, rather than the simple port itself.

图 11.47 显示了一个组件的内部结构的内部或白盒视图,该组件包含其他具有简单端口的组件作为其内部组件的一部分。装配连接器使用球窝符号。委托连接器使用符号选项,连接器线可以在球或插座上结束,而不是简单的端口本身。

Figure 11.48 shows delegation Connectors from delegating Ports to handling parts; in this example the parts in the internal structure compartment are typed by Classes shown in the optional packaged elements compartment.

图 11.48 显示了从委派端口到处理部件的委派连接器;在此示例中,内部结构隔间中的部件按可选包装元素隔间中显示的类键入。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-10-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 面向对象思考 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档