The Pivot-based OCL implementation provides indirect support for models defined using either the Ecore or the UML metamodel (as implemented by the Eclipse EMF and UML2 projects), and an extensibility API that allows additional EMF-based metamodels to be plugged in. The indirection through the UML-aligned Pivot metamodel makes OMG compliance much easier and decouples the implementationm from particular bindings. Support for an alternate concrete metamodel representation is therefore comparatively simple.
The OCL API implements support for different target metamodels via the
interface. An implementation of this interface binds the metamodel’s metaclasses to the generic type parameters of the
class. The metamodel-specific
implementation constructed by this factory implements the reflection capability required by OCL to discover the elements of the model being constrained and the relationships between them.
The preliminary OCL binding for the Pivot metamodel has been provided since the Indigo release by the
org.eclipse.ocl.examples.pivot plug-in. This has been promoted to
org.eclipse.ocl.pivot in the Mars release.
The Pivot metamodel prototypes resolutions of the following problems in the OCL 2.4 specification
OCL Standard Library model
Complete OCL implementability
The support for an OCL Standard Library model enables large parts of the OCL specification to be captured by models. This makes the behavior mutable and extensible through definition of alternate or extended library models. (The corresponding Ecore and UML bindings have an Ecore representation of the library but much of its functionality is directly implemented and so immutable.)
The Pivot metamodel is auto-generated by a package merge of
selected parts of the UML metamodel
additional OCL packages
The implementation-specific packages provide
Visitors throughout the entire metamodel (OCL and MOF)
It is anticipated that the performance advantages of a uniform compliant metamodel, without the complexities of the templates from the
org.eclipse.ocl plugin, will outweigh the initial overhead of converting an Ecore or UML metamodel to Pivot form. Once this has been demonstrated, the direct Ecore and UML metamodels will be deprecated.
The Pivot binding is provided by the
class. For compatibility, as a default, the Pivot environment uses the static
EPackage registry to look up package names. This default is deprecated since the domain of
allInstances() may be very large when many models are registered. It should therefore be supplied with an alternative package registry (for example, one local to a
ResourceSet) for relevant metamodels. The static registry is then used as a backup for package lookups, but not for
allInstances(). The Pivot environment factory maintains the Pivot models associated with
Ecore metamodels in use
UML metamodels in use
Library models in use
Concrete Syntax source models
OCLinEcore (rather than Ecore)
OCL Standard Library
The Pivot binding for OCL will provide the full capabilities of the UML binding, but at present only the Ecore facilities have been tested. The Pivot binding has the additional ability to support extensions to the library.
For applications that work exclusively with the Pivot binding for OCL, the
org.eclipse.ocl.pivot package defines an
OCL class that provides similar facilities to the corresponding Ecore and UML binding equivalents.
The Pivot metamodel is used by Eclipse OCL for:
all Xtext editors; editing, parsing, analysis and validation
the Xtext OCL console; editor and evaluation
EMF delegates using the http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot URI
explicit use of the Pivot metamodel from Java
The Pivot metamodel is not used by Eclipse OCL for:
OCL console editing and evaluation
EMF delegates using the http://www.eclipse.org/emf/2002/Ecore/OCL/LPG URI
explicit use of the Ecore or UML bindings from Java
EMF delegates using the http://www.eclipse.org/emf/2002/Ecore/OCL virtual URI are redirected to either http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot or http://www.eclipse.org/emf/2002/Ecore/OCL/LPG by the setting of the “Executor targeted by the default OCL delegate” preference setting, which defaults to http://www.eclipse.org/emf/2002/Ecore/OCL/LPG for compatibility.
Note that the Indigo and Juno OCLinEcore editor uses the http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot URI and so uses the Pivot Evaluator, whereas the Helios OCLinEcore editor used the http://www.eclipse.org/emf/2002/Ecore/OCL URI and so the Ecore evaluator. A file using the http://www.eclipse.org/emf/2002/Ecore/OCL URI will automatically be upgraded to the http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot URI when edited using the Indigo or Juno OCLinEcore editors.
In Kepler, Luna ans Mars, the OCLinEcore editor preserves any existing delegate URI selection. The new “Preferred executor requested for OCL constraints” preference determines the URI when no previous setting is available. This defaults to http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot for backwards compatibility.