blob: 80e5b5b3a03c3118ee111112bf394899cb3a5070 [file] [log] [blame]
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Pivot Standalone Configuration</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="PivotEvaluator.html" title="The Pivot Evaluator">
<link rel="next" href="PivotThreadSafety.html" title="Pivot Thread Safety">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">Pivot Standalone Configuration</h1>
<div class="section" title="Pivot Standalone Configuration">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="PivotStandalone"></a>Pivot Standalone Configuration</h2>
</div>
</div>
</div>
<p>If you use Eclipse OCL within Eclipse you should find that the appropriate registrations are provided for you automatically by the plugin registration mechanisms.</p>
<p>However if you use Eclipse OCL outside Eclipse, for instance in JUnit tests, you must provide the corresponding registrations in your code.</p>
<div class="literallayout">
<p>
<code class="code">org.eclipse.ocl.pivot.OCL.initialize(resourceSet);<br>
org.eclipse.ocl.pivot.uml.UML2AS.initialize(resourceSet);<br>
org.eclipse.ocl.pivot.model.OCLstdlib.install();<br>
org.eclipse.ocl.pivot.delegate.OCLDelegateDomain.initialize(resourceSet);<br>
org.eclipse.ocl.xtext.completeocl.CompleteOCLStandaloneSetup.doSetup();<br>
org.eclipse.ocl.xtext.oclinecore.OCLinEcoreStandaloneSetup.doSetup();<br>
org.eclipse.ocl.xtext.oclstdlib.OCLstdlibStandaloneSetup.doSetup();<br>
org.eclipse.ocl.domain.utilities.StandaloneProjectMap.getAdapter(resourceSet);<br>
<br>
</code>
</p>
</div>
<p></p>
<p>These are elaborated on below.</p>
<div class="section" title="Models">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="Models2"></a>Models</h3>
</div>
</div>
</div>
<p>For the Pivot metamodel, the required registrations should be provided by invoking
<code class="code">org.eclipse.ocl.pivot.OCL.initialize(ResourceSet)</code>. This initialization ensures that *.ecore is understood.
</p>
<p>If *.uml support is also required, invoke
<code class="code">org.eclipse.ocl.pivot.uml.UML2AS.initialize(ResourceSet)</code> as well.
This initialization ensures that *.uml is understood and that standard pathmap: locations are resolvable. It also invokes
<code class="code">org.eclipse.uml2.uml.resources.util.UMLResourcesUtil.init(ResourceSet)</code> to ensure that all Eclipse and OMG UML namespaces and extensions are registered.
</p>
</div>
<div class="section" title="OCL Standard Library">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="OCLStandardLibrary"></a>OCL Standard Library</h3>
</div>
</div>
</div>
<p>If you want to use the default OCL Standard Library you should invoke
<code class="code">org.eclipse.ocl.pivot.model.OCLstdlib.install()</code> which installs a compiled shareable form of
<code class="code">/org.eclipse.ocl.library/model/OCL-2.5.oclstdlib</code>.
</p>
<p>If you want to use an alternate library examine the code for the standard installation above, and if you want to compile your library examine the
<code class="code">/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/GenerateOCLstdlibModel.mwe2</code> launcher for the
<code class="code">/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/acceleo/generateOCLstdlib.mtl</code> Acceleo template.
</p>
<p>Note that the library is extensible and importable so you may import your own library that in turn imports the standard library.</p>
<p>If you neglect to install an OCL Standard Library, you get the error &ldquo;No OCL Standard Library content available&rdquo;. If you provide a custom library that fails to meet the miinimal requirements of defining the basic library types (e.g. Boolean, Set, Tuple) and methods (e.g. OclAny::&ldquo;=&rdquo;) you get an error such as &ldquo;No 'Boolean' type in the OCL Standard Library&rdquo;.</p>
</div>
<div class="section" title="Pivot Delegates">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="PivotDelegates"></a>Pivot Delegates</h3>
</div>
</div>
</div>
<p>If you have textual OCL embedded within Ecore models you need to register the EMF delegates so that EMF gets, calls or validates dispatch the embedded OCL to the OCL delegates. The required registrations may be provided by
<code class="code">OCLDelegateDomain.initialize(ResourceSet)</code> from the
<code class="code">org.eclipse.ocl.pivot.delegate</code> package.
</p>
<p>This may be invoked with a null argument to install the registrations in the global EPackage.Registry rather than a specified local registry.</p>
<p>If you neglect to register delegates before generated EMF classes are initialized, you may get an NPE or an error of the form "An exception occurred while delegating evaluation of the ..."</p>
</div>
<div class="section" title="Xtext Parsers">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="XtextParsers"></a>Xtext Parsers</h3>
</div>
</div>
</div>
<p>If you want to be able to convert any textual form of OCL to its internal pivot form you need to initialize the relevant parser.</p>
<p>*.ocl Complete OCL documents are initialized by
<code class="code">CompleteOCLStandaloneSetup.doSetup()</code>.
</p>
<p>*.oclinecore metamodels are initialized by
<code class="code">OCLinEcoreStandaloneSetup.doSetup()</code>
</p>
<p>*.oclstdlib OCL Standard Library definitions are initialized by
<code class="code">OCLstdlibStandaloneSetup.doSetup()</code>.
</p>
<p>*.ecore, *.essentialocl, *.uml files or general use of the query API is initialized by
<code class="code">EssentialOCLStandaloneSetup.doSetup()</code>.
</p>
<p>Each of the above ensures that everything that it requires is installed. The various set ups can be found in one of the following packages:</p>
<div class="literallayout">
<p>
<code class="code">org.eclipse.ocl.xtext.completeocl.<br>
org.eclipse.ocl.xtext.essentialocl.<br>
org.eclipse.ocl.xtext.oclinecore.<br>
org.eclipse.ocl.xtext.oclstdlib.<br>
</code>
</p>
</div>
<p></p>
</div>
<div class="section" title="platform:/plugin and platform:/resource URIs">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="platformpluginandplatformresourceURIs"></a>platform:/plugin and platform:/resource URIs</h3>
</div>
</div>
</div>
<p>If you want to be able to use
<code class="code">platform:/plugin/...</code> or
<code class="code">platform:/resource/...</code> URIs in a standalone configuration you need to configure the EMF package and URI map registries appropriately. This is a costly activity that involves scanning the classpath and exploiting the content of any plugin.xml and MANIFEST.MF files that are found.
</p>
<div class="literallayout">
<p>
<code class="code">org.eclipse.ocl.domain.utilities.StandaloneProjectMap.getAdapter(resourceSet);<br>
</code>
</p>
</div>
<p></p>
<p>creates a
<code class="code">StandaloneProjectMap</code> to cache all the scan results, initializes the ResourceSet and installs itself as an adapter on the ResourceSet so that it can be retrieved again if needed. Users are strongly recommended to ensure that a single
<code class="code">StandaloneProjectMap</code> is shared by all clients and so avoid incurring the classpath scan cost more than once.
</p>
<p>(The
<code class="code">StandaloneProjectMap</code> has no OCL-specific functionality; it just cures a major problem in the standalone usage of EMF.)
</p>
</div>
<div class="section" title="Classpath">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="Classpath"></a>Classpath</h3>
</div>
</div>
</div>
<p>If your standalone environment supports OSGI bundles, as will be the case when you use Eclipse to launch a JUnit test or a transformation, the required plugin dependencies are easily configured in the MANIFEST.MF using JDT quick fixes, or the Manifest editor.</p>
<p>For a totally standalone Java launch, you must identify the exact spelling of each JAR that you require and identify it on your Java classpath. The Eclipse JARs may be found in the plugins folder adjacent to your eclipse.exe. So you may need
<code class="code">org.eclipse.ocl.common_1.0.0.v20120516-1543.jar</code> amongst many others. The required JARs can be recursively determined by looking at the Class Not Found Exceptions from the Java launch and locating the plugin with a similar name prefix. This is very tedious and has to be repeated each time you upgrade, so don&rsquo;t do it. Use OSGI. However if you must, the following dependency trees may provide some clues.
</p>
<p>The dependency tree for the basic parsing and evaluation is:</p>
<div class="literallayout">
<p>
<code class="code">org.eclipse.ocl.common<br>
&nbsp;&nbsp;org.eclipse.ocl.pivot<br>
&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.library<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.pivot.internal<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.xtext.base<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.xtext.essentialocl<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.xtext.completeocl<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.xtext.oclinecore<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.xtext.oclstdlib<br>
</code>
</p>
</div>
<p></p>
<p>Additionally the UI requires</p>
<div class="literallayout">
<p>
<code class="code">org.eclipse.ocl.common.ui<br>
&nbsp;&nbsp;org.eclipse.ocl.examples.markup<br>
&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.examples.markup.ui<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.xtext.essentialocl.ui<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.xtext.completeocl.ui<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.xtext.oclinecore.ui<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.xtext.oclstdlib.ui<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.examples.xtext.console<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.ocl.pivot.ui<br>
</code>
</p>
</div>
<p></p>
<p>You may also need the Xtext, EMF, MWE, Orbit plugins and their dependencies</p>
<div class="literallayout">
<p>
<code class="code">com.google.guava<br>
com.google.inject<br>
org.apache.log4j<br>
org.eclipse.emf.common<br>
&nbsp;&nbsp;org.eclipse.emf.ecore<br>
&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.emf.codegen<br>
&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.emf.ecore.xmi<br>
org.eclipse.xtext<br>
&nbsp;&nbsp;org.eclipse.xtext.common.types<br>
&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.xtext.common.types.ui<br>
&nbsp;&nbsp;org.eclipse.xtext.ui<br>
&nbsp;&nbsp;&nbsp;&nbsp;org.eclipse.xtext.ui.shared<br>
&nbsp;&nbsp;org.eclipse.xtext.util<br>
</code>
</p>
</div>
<p></p>
</div>
</div>
</body>
</html>