in black and white
Main menu
Home About us Share a book
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics

Model driven architecture applying MDA to Enterprise computing - Frankel D.

Frankel D. Model driven architecture applying MDA to Enterprise computing - Wiley & sons , 2003. - 355 p.
ISBN: 0-471-31920-1
Download (direct link): modeldrivenarchitecture2003.pdf
Previous << 1 .. 56 57 58 59 60 61 < 62 > 63 64 65 66 67 68 .. 123 >> Next

Note that the declaration of the type of the tags as Boolean has no standard meaning in UML 1.4. All tags in UML are actually typed as strings.
/ \
«stereotype» «stereotype» «stereotype»
<<stereotype>> Uniqueld
<<stereotype>> DCControllerContract
isUserAssigned : Boolean

<<TaggedValues>> OperationTags isTx : Boolean isIdempotent : Boolean
Figure 6.4 Formal class model of the sample profile.
3 [JSR26]
152 Chapter 6
--DCEntityContract Invariants
--At least one attribute is stereotyped <<UniqueId>>.
context DCEntityContract inv:
self.feature->exists (isStereotyped ('Uniqueld'))
Figure 6.5 Invariant for the sample profile.
A rigorous model of a profile includes invariant rules in the class model. For example, our profile requires that all <<DCEntityContract>>-stereotyped classes have at least one <<UniqueId>>-stereotyped attribute. (More than one <<UniqueId>>-stereotyped attribute is permitted, in which case the attribute values are concatenated to constitute an identifier.) This rule can be written as a formal invariant as in Figure 6.5.
Note that the isStereotyped operation is not part of the OCL specification but is defined as part of the UML Profile for CORBA specification, using OCL's ability to specify convenience operations.4
Figure 6.6 is a fragment of the UML metamodel that highlights the fact that, when the above OCL expression references feature, it is traversing an association in the metamodel. This illustrates the point that the UML metamodel is the context for a profile's constraints. Therefore, an architect or engineer who defines a UML profile must have fairly strong knowledge of the UML metamodel, or at least of the part of the metamodel being extended.
Figure 6.6 The fragment of the UML metamodel extended by the sample profile.
4 [UML4CORBA] section
Extending and Creating Modeling Languages 153
--Uniqueld Invariants
--The owning class is stereotyped <<DCEntityContract>>.
context UniqueId inv:
self.owner.isStereotyped ('DCEntityContract')
Figure 6.7 Additional invariant for the sample profile.
Our simple profile has another important constraint: An attribute can only be stereotyped <<UniqueId>> if its owning class is stereotyped <<DCEntity Contract» (see Figure 6.7).
One other thing that a formal definition of a profile must do is to declare the subset of the UML metamodel that is its scope of concern. It does this by specifying the packages of the UML metamodel that the profile imports. For example, the scope of concern of our sample profile is the set of packages that supports class modeling.
Extending UML via MOF
Profiling is not the only way to extend UML. In this section we examine an alternate approach using MOF and consider the trade-offs between that approach and profiling.
Anatomy of a Heavyweight UML Metamodel Extension
The UML metamodel is defined via MOF, and so you can extend it via MOF. UML extensions that use the full power of MOF are sometimes called heavyweight extensions. As we have seen, MOF offers metamodelers most of the familiar UML class-modeling constructs.
Figure 6.8 takes the heavyweight approach to defining the UML extensions that we defined via profiling in our previous example.
■ It defines DCEntityContract and DCControllerContract as fullblown subclasses of the UML metamodel element Class instead of making them merely stereotypes of Class.
■ It defines UniqueId as a subclass of Attribute rather than as a stereotype of it.
■ It defines a subclass of Operation called EnterpriseOperation, which has isTx and isIdempotent as attributes.
154 Chapter 6
Figure 6.8 A heavyweight UML metamodel extension.
Our sample heavyweight extension, to be complete, needs to include invariants. The invariants are almost identical to the ones declared for the sample profile, so I don't repeat them here.
Profiles versus Heavyweight Extensions
When faced with a need to extend UML, an architect has to decide whether to do so via a profile or a heavyweight extension. Thus, it is important to understand the trade-offs between the two approaches.
The main advantage of the profile approach is that a modeler who wishes to use extensions defined by a profile can do so with generic UML tools. Consider the profile defined by Figures 6.4 and 6.5. Generic UML tools can be configured to support these extensions. A modeler who wishes to use the extensions does not have to depend on vendors to revise their tools, as would be the case with a heavyweight extension. In fact, Figures 6.1 and 6.2, which use the profile, were created with a generic UML tool. The quality of support for profiling varies widely among UML tools, but the major ones all support it. A good profiling tool can enforce the semantics of the profile so that, when a model declares that it is supposed to conform to a specific profile, the tool can detect when that conformance is violated.
Previous << 1 .. 56 57 58 59 60 61 < 62 > 63 64 65 66 67 68 .. 123 >> Next