blob: c2368fd1caa8b6a67f905cdbe366dfbd1e4a463b [file] [log] [blame]
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>OCL Relationship to Metamodels</title>
<link href="book.css" rel="stylesheet" type="text/css">
<meta content="DocBook XSL Stylesheets V1.75.1" name="generator">
<link rel="home" href="index.html" title="OCL Documentation">
<link rel="up" href="PivotProgrammersGuide.html" title="Unified or Pivot Programmers Guide">
<link rel="prev" href="PivotParsingDocuments.html" title="Parsing OCL Documents">
<link rel="next" href="Pivot-Ids.html" title="Ids">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">OCL Relationship to Metamodels</h1>
<div class="section" title="OCL Relationship to Metamodels">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="PivotMetamodels"></a>OCL Relationship to Metamodels</h2>
</div>
</div>
</div>
<p>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
<a class="link" href="AdvancedMetamodelBindings.html" title="Creating Metamodel Bindings">extensibility API</a> 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.
</p>
<p>
The OCL API implements support for different target metamodels via the
<a class="ulink" href="http://download.eclipse.org/ocl/javadoc/6.3.0/org/eclipse/ocl/pivot/utilities/EnvironmentFactory.html" target="_new">
<code class="code">EnvironmentFactory</code>
</a> interface. An implementation of this interface binds the metamodel&rsquo;s metaclasses to the generic type parameters of the
<a class="ulink" href="http://download.eclipse.org/ocl/javadoc/6.3.0/org/eclipse/ocl/pivot/utilities/OCL.html" target="_new">
<code class="code">OCL</code>
</a> class. The metamodel-specific
<a class="ulink" href="http://download.eclipse.org/ocl/javadoc/6.3.0/org/eclipse/ocl/examples/pivot/Environment.html" target="_new">
<code class="code">Environment</code>
</a> 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.
</p>
<div class="section" title="The Pivot Metamodel Binding">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="ThePivotMetamodelBinding"></a>The Pivot Metamodel Binding</h3>
</div>
</div>
</div>
<p>The preliminary OCL binding for the Pivot metamodel has been provided since the Indigo release by the
<code class="code">org.eclipse.ocl.examples.pivot</code> plug-in. This has been promoted to
<code class="code">org.eclipse.ocl.pivot</code> in the Mars release.
</p>
<p>The Pivot metamodel prototypes resolutions of the following problems in the OCL 2.4 specification</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>UML-alignment</p>
</li>
<li class="listitem">
<p>OCL Standard Library model</p>
</li>
<li class="listitem">
<p>XMI interchange</p>
</li>
<li class="listitem">
<p>Complete OCL implementability</p>
</li>
</ul>
</div>
<p>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.) </p>
<p>The Pivot metamodel is auto-generated by a package merge of</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>selected parts of the UML metamodel</p>
</li>
<li class="listitem">
<p>additional OCL packages</p>
</li>
<li class="listitem">
<p>implementation-specific packages</p>
</li>
</ul>
</div>
<p>The implementation-specific packages provide</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>Visitors throughout the entire metamodel (OCL
<span class="bold"><strong>and</strong></span> MOF)
</p>
</li>
<li class="listitem">
<p>Ecore extensions</p>
</li>
</ul>
</div>
<p>It is anticipated that the performance advantages of a uniform compliant metamodel, without the complexities of the templates from the
<code class="code">org.eclipse.ocl</code> 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.
</p>
<p>The Pivot binding is provided by the
<a class="ulink" href="http://download.eclipse.org/ocl/javadoc/6.3.0/org/eclipse/ocl/pivot/internal/utilities/PivotEnvironmentFactory.html" target="_new">
<code class="code">PivotEnvironmentFactory</code>
</a> class. For compatibility, as a default, the Pivot environment uses the static
<code class="code">EPackage</code> registry to look up package names. This default is deprecated since the domain of
<code class="code">allInstances()</code> 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
<code class="code">ResourceSet</code>) for relevant metamodels. The static registry is then used as a backup for package lookups, but not for
<code class="code">allInstances()</code>. The Pivot environment factory maintains the Pivot models associated with
</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>Ecore metamodels in use</p>
</li>
<li class="listitem">
<p>UML metamodels in use</p>
</li>
<li class="listitem">
<p>Library models in use</p>
</li>
<li class="listitem">
<p>Concrete Syntax source models</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="circle">
<li class="listitem">
<p>OCLinEcore (rather than Ecore)</p>
</li>
<li class="listitem">
<p>Complete OCL</p>
</li>
<li class="listitem">
<p>OCL Standard Library</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>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.</p>
<p>For applications that work exclusively with the Pivot binding for OCL, the
<code class="code">org.eclipse.ocl.pivot</code> package defines an
<code class="code">OCL</code> class that provides similar facilities to the corresponding Ecore and UML binding equivalents.
</p>
<p>The Pivot metamodel is used by Eclipse OCL for:</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>all Xtext editors; editing, parsing, analysis and validation</p>
</li>
<li class="listitem">
<p>the Xtext OCL console; editor and evaluation</p>
</li>
<li class="listitem">
<p>EMF delegates using the http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot URI</p>
</li>
<li class="listitem">
<p>explicit use of the Pivot metamodel from Java</p>
</li>
</ul>
</div>
<p>The Pivot metamodel is not used by Eclipse OCL for:</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>OCL console editing and evaluation</p>
</li>
<li class="listitem">
<p>EMF delegates using the http://www.eclipse.org/emf/2002/Ecore/OCL/LPG URI</p>
</li>
<li class="listitem">
<p>
<a class="link" href="ImpactAnalyzer.html" title="Incrementally Re-Evaluating OCL Expressions Using the Impact Analyzer">Impact Analyzer</a>.
</p>
</li>
<li class="listitem">
<p>explicit use of the Ecore or UML bindings from Java</p>
</li>
</ul>
</div>
<p>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 &ldquo;Executor targeted by the default OCL delegate&rdquo; preference setting, which defaults to
http://www.eclipse.org/emf/2002/Ecore/OCL/LPG for compatibility.</p>
<p>Note that the Indigo and Juno OCLinEcore editor uses the http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot URI and so uses the
<a class="link" href="PivotEvaluator.html" title="The Pivot Evaluator">Pivot Evaluator</a>, 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.
</p>
<p>In Kepler, Luna ans Mars, the OCLinEcore editor preserves any existing delegate URI selection. The new &ldquo;Preferred executor requested for OCL constraints&rdquo; 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.</p>
</div>
</div>
</body>
</html>