Association (Java EE 5)

Java EE API


javax.xml.registry.infomodel Interface Association

All Superinterfaces:
ExtensibleObject, RegistryObject

public interface Association
extends RegistryObject

Implements: RegistryObject

RegistryObject 实例可以与 0 个或多个 RegistryObject 实例关联。信息模型定义一个 Association 接口,可以使用该接口的实例将任意两个 RegistryObject 实例关联。

Association 的示例

这种关联的一个示例如下:在两个 ClassificationScheme 实例之间,其中一个 ClassificationScheme 替代了另一个 ClassificationScheme,如图 1 所示。在提交一个 ClassificationScheme 新版本时可能出现这种情况。在图 1 中,可以看到新版 NAICS ClassificationScheme 与旧版 NAICS ClassificationScheme 之间的 Association 是如何定义的。

RegistryObject Association 的示例
图 1. RegistryObject Association 的示例

源对象和目标对象

Association 实例表示源 RegistryObject 与目标 RegistryObject 之间的关联。它们分别称为 Association 实例的 sourceObject 和 targetObject。在确定 Association 的方向语义时,了解哪个对象是 sourceObject 以及哪个对象是 targetObject 非常重要。在图 1 的示例中,重点在于用较新版本的 NAICS ClassificationScheme 作为 sourceObject,用较旧版本的 NAICS ClassificationScheme 作为 targetObject,因为 associationType 意味着使用 sourceObject 替代 targetObject(而非相反)。

Association 类型

每个 Association 都必须有一个标识关联类型的 associationType 属性。associationType 属性是枚举 Concept 的引用,枚举 Concept 由 JAXR 规范中的预定义 associationType ClassificationScheme 定义。我们的示例使用了名为 Supersedes 的预定义 associationType Concept。

内部 Association

Association 接口最常见的用法是:User "u" 创建了两个 RegistryObject "o1" 和 "o2" 之间的 Association "a",其中 Association "a" 以及 RegistryObject "o1" 和 "o2" 都是由同一 User "u" 创建的对象。这是最简单的一种用法,其中的关联在定义 Association 的用户所拥有的两个对象之间。这种关联称为内部关联 (intramural association)。图 2 扩展了上面图 1 中的示例,作为内部关联的例子。

内部 Association 的示例
图 2. 内部 Association 的示例

外部 Association

信息模型还支持更复杂的用法:User "u1" 创建了两个 RegistryObject "o1" 和 "o2" 之间的 Association "a",其中 Association "a" 归 User "u1" 所有,但 RegistryObject "o1" 和 "o2" 则分别归 User "u2" 和 User "u3" 所有。这种用法中的 Association 如下:拥有所关联的一个或两个对象的 User 与定义 Association 的 User 不同。这种关联称为外部关联 (extramural association)。Association 接口提供了一个称为 isExtramural 的便捷方法,如果 Association 实例是外部 Association,则该方法返回 true。图 3 扩展了上面图 1 中的示例,作为外部关联的例子。注意,外部关联可能有两个不同的 User,而不是图 3 中所示的三个。在这种情况下,其中一个用户拥有所涉及的三个对象(Association、sourceObject 和 targetObject)中的两个。

外部 Association 的示例
图 3. 外部 Association 的示例

Association 的确认

关联可能需要由 Association 所涉及对象的拥有方进行确认。这一节描述所涉及的各方进行关联确认的语义。

内部 Association 的确认

内部关联可以被视为事实声明,不需要明确的步骤来确认 Association 的真实性。换句话说,内部关联隐式地认为已经经过了确认。

外部 Association 的确认

外部关联可以被视为单方面断言,直到其他(外部)方(示例中的 User "u2" 和 "u3")确认之后才认为它是真实的。拥有 sourceObject 或 targetObject 的外部方可能会调用 BusinessLifeCycleManager 接口的 confirmAssociation 方法。

未经确认的 Association 的可见性

外部关联要求,若要外部 Association 对该 Association 中未涉及的第三方可见,它所做的断言必须经过每个外部方的确认。这样可以确保未经确认的 Association 对于第三方注册客户端是不可见的。

可能的确认状态

假定大多数情况下,一个外部 Association 有三个不同的 User 实例,如图 3 所示。若要获得完全确认,需要所有其他(外部)方(示例中的 User "u2" 和 "u3")都确认该外部 Association。Association 接口中的方法 isConfirmedBySourceOwner 和 isConfiremedByTargetOwner 可以访问 sourceObject 和 targetObject 的确认状态。名为 isConfirmed 的第三个便捷方法提供了确定 Association 是否得到完全确认的方式。因此,外部 Association 的确认状态存在以下四种可能:
  • Association 既没有经过 sourceObject 所有者的确认,也没有经过 targetObject 所有者的确认。
  • Association 经过了 sourceObject 所有者的确认,但没有经过 targetObject 所有者的确认。
  • Association 没有经过 sourceObject 所有者的确认,但经过了 targetObject 所有者的确认。
  • Association 经过了 sourceObject 所有者的确认,也经过了 targetObject 所有者的确认。这是 Association 经过了完全确认的唯一状态。
英文文档:

A RegistryObject instance may be associated with zero or more RegistryObject instances. The information model defines an Association interface, an instance of which may be used to associate any two RegistryObject instances.

Example of an Association

One example of such an association is between two ClassificationScheme instances, where one ClassificationScheme supersedes the other ClassificationScheme as shown in Figure 1. This may be the case when a new version of a ClassificationScheme is submitted. In Figure 1, we see how an Association is defined between a new version of the NAICS ClassificationScheme and an older version of the NAICS ClassificationScheme.

Example of RegistryObject Association
Figure 1. Example of RegistryObject Association

Source and Target Objects

An Association instance represents an association between a source RegistryObject and a target RegistryObject. These are referred to as sourceObject and targetObject for the Association instance. It is important which object is the sourceObject and which is the targetObject as it determines the directional semantics of an Association. In the example in Figure 1, it is important to make the newer version of NAICS ClassificationScheme be the sourceObject and the older version of NAICS be the targetObject because the associationType implies that the sourceObject supersedes the targetObject (and not the other way around).

Association Types

Each Association must have an associationType attribute that identifies the type of that association. The associationType attribute is a reference to an enumeration Concept as defined by the predefined associationType ClassificationScheme in the JAXR specification. Our example uses the pre-defined associationType Concept named Supersedes.

Intramural Associations

A common use case for the Association interface is when a User "u" creates an Association "a" between two RegistryObjects "o1" and "o2" where association "a" and RegistryObjects "o1" and "o2" are objects that were created by the same User "u". This is the simplest use case where the association is between two objects that are owned by same User that is defining the Association. Such associations are referred to as intramural associations. Figure 2 extends the previous example in Figure 1 for the intramural association case.

Example of Intramural Association
Figure 2. Example of Intramural Association

Extramural Association

The information model also allows a more sophisticated use case where a User "u1" creates an Association "a" between two RegistryObjects "o1" and "o2" where association "a" is owned by User "u1", but RegistryObjects "o1" and "o2" are owned by User "u2" and User "u3" respectively. In this use case the Association is being defined where either or both objects that are being associated are owned by a User different from the User defining the Association. Such associations are referred to as extramural associations. The Association interface provides a convenience method called isExtramural that returns true if the Association instance is an extramural Association. Figure 3 extends the previous example in Figure 1 for the extramural association case. Note that it is possible for an extramural association to have two distinct Users rather than three distinct Users as shown in Figure 3. In such case, one of the two users owns two of the three objects involved (Association, sourceObject and targetObject).

Example of Extramural Association
Figure 3. Example of Extramural Association

Confirmation of an Association

An association may need to be confirmed by the parties whose objects are involved in that Association. This section describes the semantics of confirmation of an association by the parties involved.

Confirmation of Intramural Associations

Intramural associations may be viewed as declarations of truth and do not require any explicit steps to confirm that Association as being true. In other words, intramural associations are implicitly considered be confirmed.

Confirmation of Extramural Associations

Extramural associations may be viewed as a unilateral assertion that may not be viewed as truth until it has been confirmed by the other (extramural) parties (Users "u2" and "u3" in example). The confirmAssociation method on the BusinessLifeCycleManager interface may be called by the extramural parties that own the sourceObject or targetObject.

Visibility of Unconfirmed Associations

Extramural associations require each extramural party to confirm the assertion being made by the extramural Association before the Association is visible to 3rd parties that are not involved in the Association. This ensures that unconfirmed Associations are not visible to 3rd party registry clients.

Possible Confirmation States

Assume the most general case where there are three distinct User instances as shown in Figure 23 for an extramural Association. The extramural Association needs to be confirmed by both the other (extramural) parties (Users "u2" and "u3" in example) in order to be fully confirmed. The methods isConfirmedBySourceOwner and isConfiremedByTargetOwner in the Association interface provide access to confirmation state for both the sourceObject and targetObject. A third convenience method called isConfirmed provides a way to determine whether the Association is fully confirmed or not. So there are the following four possibilities related to confirmation state of an extramural Association:
  • The Association is confirmed neither by the owner of the sourceObject nor is it confirmed by owner of targetObject.
  • The Association is confirmed by the owner of the sourceObject but it is not confirmed by owner of targetObject.
  • The Association is not confirmed by the owner of the sourceObject but it is confirmed by owner of targetObject.
  • The Association is confirmed by the owner of the sourceObject and it is confirmed by owner of targetObject. This is the only state where the Association is fully confirmed.

Author:
Farrukh S. Najmi
See Also:
RegistryObject

Method Summary
 Concept
 RegistryObject
 RegistryObject
 boolean
 boolean
 boolean
 boolean
 void
 void
 void
 
Methods inherited from interface javax.xml.registry.infomodel.RegistryObject
 
Methods inherited from interface javax.xml.registry.infomodel.ExtensibleObject
 

Method Detail

public RegistryObject getSourceObject() throws JAXRException
获取作为此 Association 的源的 Object。

功能级别:0
return 作为此 Association 的源对象的 RegistryObject
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

getSourceObject

RegistryObject getSourceObject()
                               throws JAXRException
Gets the Object that is the source of this Association.

Capability Level: 0

Returns:
The RegistryObject that is the source object of this Association
Throws:
JAXRException - If the JAXR provider encounters an internal error

public void setSourceObject(RegistryObject srcObject) throws JAXRException
设置作为此 Association 的源的 Object。

功能级别:0
srcObject 作为此 Association 的源对象的 RegistryObject
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

setSourceObject

void setSourceObject(RegistryObject srcObject)
                     throws JAXRException
Sets the Object that is the source of this Association.

Capability Level: 0

Parameters:
srcObject - the RegistryObject that is the source object of this Association
Throws:
JAXRException - If the JAXR provider encounters an internal error

public RegistryObject getTargetObject() throws JAXRException
获取作为此 Association 的目标的 Object。

功能级别:0
return 作为此 Association 的目标对象的 RegistryObject
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

getTargetObject

RegistryObject getTargetObject()
                               throws JAXRException
Gets the Object that is the target of this Association.

Capability Level: 0

Returns:
The RegistryObject that is the target object of this Association
Throws:
JAXRException - If the JAXR provider encounters an internal error

public void setTargetObject(RegistryObject targetObject) throws JAXRException
设置作为此 Association 的目标的 Object。

功能级别:0
targetObject 作为此 Association 的目标对象的 RegistryObject
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

setTargetObject

void setTargetObject(RegistryObject targetObject)
                     throws JAXRException
Sets the Object that is the target of this Association.

Capability Level: 0

Parameters:
targetObject - the RegistryObject that is the target object of this Association
Throws:
JAXRException - If the JAXR provider encounters an internal error

public Concept getAssociationType() throws JAXRException
获取此 Association 的关联类型。

功能级别:0
return 此 Association 的关联类型,它是 AssociationType ClassificationScheme 中的一个 Concept
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

getAssociationType

Concept getAssociationType()
                           throws JAXRException
Gets the association type for this Association.

Capability Level: 0

Returns:
The association type for this Association which is a Concept in the AssociationType ClassificationScheme
Throws:
JAXRException - If the JAXR provider encounters an internal error

public void setAssociationType(Concept associationType) throws JAXRException
设置此 Association 的关联类型。

功能级别:0
associationType 此 Association 的关联类型,它是 AssociationType ClassificationScheme 中的一个 Concept
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

setAssociationType

void setAssociationType(Concept associationType)
                        throws JAXRException
Sets the association type for this Association.

Capability Level: 0

Parameters:
associationType - the association type for this Association which is a Concept in the AssociationType ClassificationScheme
Throws:
JAXRException - If the JAXR provider encounters an internal error

public boolean isExtramural() throws JAXRException
确定 Association 是否为外部 Association。

如果拥有源和/或目标对象的 User 与创建此外部 Association 的 User 不同,则该外部关联必须由拥有源和/或目标对象的 User 进行确认。若要外部 Association 对第三方可见,sourceObject 和 targetObject 所有者都必须确认它。

功能级别:0
return 如果拥有 sourceObject 和/或 targetObject 的 User 与创建 Association 的 User 不同,则返回 true;否则返回 false
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

isExtramural

boolean isExtramural()
                     throws JAXRException
Determines whether an Association is extramural or not.

An Extramural Association must be confirmed by the User(s) that own the source and/or targert object, if they are different from the User who creates this extramural association. Both the sourceObject and targetObject owners must confirm an extramural Association, in order for it to be visible to third parties.

Capability Level: 0

Returns:
true if the sourceObject and/or the targetObject are owned by a User that is different from the User that created the Association; false otherwise
Throws:
JAXRException - If the JAXR provider encounters an internal error

public boolean isConfirmedBySourceOwner() throws JAXRException
确定源对象的所有者是否已经确认了某个 Association。

功能级别:0
return 如果 sourceObject 的所有者已经确认了关联,则返回 true;否则返回 false。对于内部 Association 总是返回 true
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

isConfirmedBySourceOwner

boolean isConfirmedBySourceOwner()
                                 throws JAXRException
Determines whether an Association has been confirmed by the owner of the source object.

Capability Level: 0

Returns:
true if the association has been confirmed by the owner of the sourceObject; false otherwise. For intramural Associations always return true
Throws:
JAXRException - If the JAXR provider encounters an internal error

public boolean isConfirmedByTargetOwner() throws JAXRException
确定目标对象的所有者是否已经确认了某个 Association。

功能级别:0
return 如果 targetObject 的所有者已经确认了关联,则返回 true;否则返回 false。对于内部 Association 总是返回 true
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
英文文档:

isConfirmedByTargetOwner

boolean isConfirmedByTargetOwner()
                                 throws JAXRException
Determines whether an Association has been confirmed by the owner of the target object.

Capability Level: 0

Returns:
true if the association has been confirmed by the owner of the targetObject; false otherwise. For intramural Associations always return true
Throws:
JAXRException - If the JAXR provider encounters an internal error

public boolean isConfirmed() throws JAXRException
确定某个 Association 是否已经完全确认。

仅当 isConfirmed 返回 true 时关联才对第三方(Association 未涉及)可见。

功能级别:0
return 如果 isConfirmedBySourceOwner 和 isConfirmedByTargetOwner 方法都返回 true,则返回 true;否则返回 false。对于内部 Association 总是返回 true
ThrowsJAXRException: 如果 JAXR 提供者遇到内部错误
See also isConfirmedBySourceOwner(), isConfirmedByTargetOwner()
英文文档:

isConfirmed

boolean isConfirmed()
                    throws JAXRException
Determines whether an Association has been confirmed completely.

An association should only be visible to third parties (not involved with the Association) if isConfirmed returns true.

Capability Level: 0

Returns:
true if the isConfirmedBySourceOwner and isConfirmedByTargetOwner methods both return true; false otherwise. For intramural Associations always return true
Throws:
JAXRException - If the JAXR provider encounters an internal error
See Also:
isConfirmedBySourceOwner(), isConfirmedByTargetOwner()


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!