Skip to main content
Jump to: navigation, search

MDT/OCL/4.X Architecture

< MDT‎ | OCL
Revision as of 12:47, 12 June 2010 by (Talk | contribs) (Pivot Structural Model)

The planned Architecture for MDT/OCL 4.X is based around a Pivot Model as shown in


Pivot Model

Pivot Structural Model

The Pivot Model isolates OCL from the details of any particular UML or Ecore (or EMOF or CMOF or ...) meta-model representation. OCL expressions can therefore be defined, analyzed and evaluated for a heterogeneous mix of meta-models for which an external representation to pivot model mapping has been defined. (Initially this mapping may be realised as a one shot transformation. In the longer term, the mapping must be a live adaptation in order for the pivot model to update automatically to external changes in the meta-model.)

The Pivot Model is arguably a major omission from the OMG OCL specification, which provides no clues as to how the OCL AST can reference a non-meta-model operation defined by an OperationContextDecl, or how an OperationCallExp can reference a standard library operation since there is no defined URI for the OCL Standard Library.

A custom pivot model may need to be created for each usage since each usage may customise OclAny in distinct ways. However most usages will not customise OclAny, so a lightweight approach is needed for simple usage whose costs are proportionate to complexity.

The Pivot Model is a merged meta-model with a class for each user-defined classifier and for each OCL Standard Library class. A "conformsTo" relationship is established from the "superType" relationships of the user meta-models. The merge imposes the additional OCL "conformsTo" relationships so that each root classifier in the user meta-models "conformsTo" OclType which "conformsTo" OclAny. Similarly OclVoid "conformsTo" each leaf classifier in the user meta-models. Additional model elements introduced by CompleteOCL are incorporated in the pivot model so that there is no observable difference between between a user-defined feature, a CompleteOCL feature or an OCL Standard LIbrary feature.

The Pivot Model needs to accommodate all the class-related concepts of UML, such as AssociationClasses, subset properties and profiles. However there is no need for other facilities such as Use Cases or Deployments. The meta-model of the Pivot Model is therefore perhaps a distinct merge of UML packages analoguous to the Essential MOF merge.

With full class-related facilities in the pivot model, problems such as how to navigate non-navigable opposites in EMOF are isolated as a problem for EMOF and the EMOF to pivot model mapping. Ongoing discussions standardising Tags should allow these problems to be resolved.

The Pivot Model need never be persisted, however its construction is predictable and so the pivot model can be the provider of consistent URIs for use by the OCL AST.

With a uniform merged representation in the pivot model, it is fairly easy in principle to provide substantial reflective facilities in the pivot model. In practice, provision of reflection could undermine OCL's current support for full static type analysis. This hazard need not arise if the reflection fully generic and so avoids the problems that Java and Ecore had in maintaining compatibility when generics were introduced once reflection was already established.

Pivot AST Model

The primary AST will be based on the Pivot model and be converted between Ecore and UML representations when necessary.

(It is unclear whether the Pivot Model will just be a third binding of the generic binding, or whether an evolution back to non-genetic bindings is merited thereby giving 100% compliance with an OMG endorsed Pivot model.)

Pivot Standard Library Model

Using the Pivot Model to represent the OCL standard library allows the OCL Library to be fully model driven, allowing variant OCL standard libraries to realise alternative interpreations of the OCL specifications and extended libraries to support other languages.

The standard library model provides the declarations used by the parser, analyzer and validator and associates a Java class with each feature. Extension or modification therefore requires alternate or additional declarations and/or Java classes.

Pivot Generics

The Pivot Model has explicit generic parameters, just like Java or Ecore or UML, rather than the implicit generics that lurk behind a coherent interpretation of Set(T), Collection::product(T2), Tuple etc.

Xtext editors

Four Xtext editors support different aspects of OCL usage. The highly model-driven nature of Xtext ensures that many behaviours that can be sensibly derived from the maet-model are so derived. The editors therefore acquire many useful functions with very little development effort, and will hopefully acquire many more as Xtext matures.

CompleteOCL Editor

This editor supports development of an OCL Document in accordance with Section 12 of the OMG OCL specification. A Complete OCL Document complements an independent meta-model.

OCLinEcore Editor

This editor supports combined development of an Ecore meta-model and OCL constraints upon that meta-model. Editing may be performed directly on a *.ecore XMI file for compatibility with existing working practices, or on a *.oclinecore text file so that detailed whitespace and commenting is preserved.

'OCLinEcore' may prove to be a bit of a misnomer since the Concrete Syntax has nothing to do with Ecore; although there is a syntax for every Ecore concept (including EReference.keys and EAnnotation.contents). This syntax can be extended to Associations and State Machines and subset feature derivation thereby supporting a useful 'OCLinUML'.

Perhaps this editor should be 'UnifiedOCL' borrowing the U from UML.

EssentialOCL Editor

This editor supports editing a single OCL Expression. It is not anticipated that this editor will be used in isolation, rather it is intended for use in pop-ups within other tools that exploit OCL. It should form the basis of expression entry in the Interactive OCL Console.

OCLstdlib Editor

This editor facilitates development of the OCL 'Standard' Library definition. It is primarily intended for use by language developers. However OCL-based languages that encourage user-defined library extension may want to make the OCLstdlib editor available to users.

Xtext integration

Xtext uses an ANTLr parser which is very different to the LPG parser used in MDT/OCL pre 4.X.

The LPG parser is probably faster and has a significant API obligation, so discarding the LPG parser is not an option so a way for the two parsers to coexist is required.

The ANTLr LL grammar is less powerful and so less precise than the LPG LALR grammar. However the Xtext semantic resolution performed by the "linking and scope services" mean that the Xtext CST is considerably more accurate than the LPG CST.

In the LPG CST, "MyClass" is a text string in a valid syntactic context. The Analyzer is responsible for performing the name to EObject resolution while building the AST.

In the Xtext CST, "MyClass" is a text string that the "linking and scope services" has resolved to a semantically consistent EObject whose name is "MyClass". The Xtext CST therefore needs only a simple mapping to align with an OMG compliant AST.

The "linking and scope services" are realised by a ScopeAdapters on each CST object with functionality closely resembling "Inherited Attributes" and "Synthesized Attributes" from the OMG specification. It therefore seems that the LPG compatibility problem may be resolved by using slightly different ScopeAdapters on the LPG CST so that the functionality currently distributed in diversely named methods in the Analyzer class migrate to polymorphic methods in ScopeAdapter classes.

MDT/OCL 3.X status

Much of the proposed MDT/OCL 4.X architecture evolved during MDT/OCL 3.X.

The Standard Library model-driven evaluator may be found in a ReflectiveLibrary branch in CVS, however the work to fully integrate it with the LPG analyzer was too ambitious to complete for 3.0.0M6 so the evaluator remains difficult to extend and with a few (hopefully very obscure) errors in 3.0.0.

The Xtext editors are present in MDT/OCL 3.0.0 as Examples with a plausible though almost certainly incomplete realisation of the "linking and scope services". The "map and merge" supports only referencing external meta-models, so there is no ability for the Xtext editors to produce ASTs, and there is no validation of well-formedness rules.

Back to the top