<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.event-b.org/index.php?action=history&amp;feed=atom&amp;title=DynamicContainer</id>
	<title>DynamicContainer - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.event-b.org/index.php?action=history&amp;feed=atom&amp;title=DynamicContainer"/>
	<link rel="alternate" type="text/html" href="https://wiki.event-b.org/index.php?title=DynamicContainer&amp;action=history"/>
	<updated>2026-05-15T04:27:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.event-b.org/index.php?title=DynamicContainer&amp;diff=3836&amp;oldid=prev</id>
		<title>imported&gt;Colin: /* Instructions for creating an extension */</title>
		<link rel="alternate" type="text/html" href="https://wiki.event-b.org/index.php?title=DynamicContainer&amp;diff=3836&amp;oldid=prev"/>
		<updated>2009-11-25T12:00:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Instructions for creating an extension&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:00, 25 November 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;This did not work. It is not possible to dynamically add to statically generated EMF classes.&#039;&#039;&#039;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Instructions for creating an extension===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Instructions for creating an extension===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>imported&gt;Colin</name></author>
	</entry>
	<entry>
		<id>https://wiki.event-b.org/index.php?title=DynamicContainer&amp;diff=3835&amp;oldid=prev</id>
		<title>imported&gt;Colin: New page: ===Instructions for creating an extension===  * Design an EMF meta model (ecore) of your extension&#039;s abstract syntax. The model should NOT deal with ownership of the extension (i.e. where ...</title>
		<link rel="alternate" type="text/html" href="https://wiki.event-b.org/index.php?title=DynamicContainer&amp;diff=3835&amp;oldid=prev"/>
		<updated>2009-11-25T11:59:15Z</updated>

		<summary type="html">&lt;p&gt;New page: ===Instructions for creating an extension===  * Design an EMF meta model (ecore) of your extension&amp;#039;s abstract syntax. The model should NOT deal with ownership of the extension (i.e. where ...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;===Instructions for creating an extension===&lt;br /&gt;
&lt;br /&gt;
* Design an EMF meta model (ecore) of your extension&amp;#039;s abstract syntax. The model should NOT deal with ownership of the extension (i.e. where the extension is contained in the existing meta-models)&lt;br /&gt;
* Load and configure the gen model (this should be set for extensible providers) &amp;lt;still under investigation since extending provider would be the container which is defined dynamically now&amp;gt;&lt;br /&gt;
* Generate the code and edit code&lt;br /&gt;
* Customise the package initialiser with the code shown below to make your package extensible&lt;br /&gt;
* Add an extension to define the containment of the extension (the containment will be added dynamically to the meta-model being extended)&lt;br /&gt;
* Add extensions to declare new kinds of Rodin elements and attributes&lt;br /&gt;
* Write Java interfaces and classes for each new Rodin element&lt;br /&gt;
* Add extensions to declare synchronisers to persist your new meta-classes into Rodin elements.&lt;br /&gt;
* Write Java classes for each synchroniser&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;example code to make a package extensible&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
(the example is for the core package... core package should be changed to the name of your package)&lt;br /&gt;
&lt;br /&gt;
 public static CorePackage init() {&lt;br /&gt;
                ........&lt;br /&gt;
        //Link in any extensions&lt;br /&gt;
        getExtensions(theCorePackage,theMachinePackage,theContextPackage);&lt;br /&gt;
       	&lt;br /&gt;
       // Mark meta-data to indicate it can&amp;#039;t be changed&lt;br /&gt;
       theCorePackage.freeze();&lt;br /&gt;
 &lt;br /&gt;
       return theCorePackage;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /**&lt;br /&gt;
  * Method to get all extensions from extension registry.&lt;br /&gt;
  * Extensions can link additional EMF model content to this core model by defining a new EReference&lt;br /&gt;
  * (usually a containment) which holds instances of a new metaclass.&lt;br /&gt;
  * &lt;br /&gt;
  * @custom&lt;br /&gt;
 */&lt;br /&gt;
 private static final String extensionId = &amp;quot;org.eventb.emf.core.metamodel_extension&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 private static void getExtensions(EPackage theCorePackage,EPackage theMachinePackage,EPackage theContextPackage) {&lt;br /&gt;
       IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();&lt;br /&gt;
       IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(extensionId);&lt;br /&gt;
       org.eclipse.core.runtime.IExtension[] extensions = extensionPoint.getExtensions();&lt;br /&gt;
 &lt;br /&gt;
       for (org.eclipse.core.runtime.IExtension extension : extensions) {&lt;br /&gt;
              try {&lt;br /&gt;
                     EPackage extenderPackage = null;&lt;br /&gt;
                     IConfigurationElement [] elements = extension.getConfigurationElements();&lt;br /&gt;
                     for (IConfigurationElement element : elements) {&lt;br /&gt;
                            if (&amp;quot;ePackage&amp;quot;.equals(element.getName())){&lt;br /&gt;
                                    //String packageName = element.getAttribute(&amp;quot;name&amp;quot;);&lt;br /&gt;
                                   Registry packageRegistry = EPackage.Registry.INSTANCE;&lt;br /&gt;
                                   String extender_eNS_URI = element.getAttribute(&amp;quot;eNS_URI&amp;quot;);&lt;br /&gt;
                                   extenderPackage = packageRegistry.getEPackage(extender_eNS_URI);&lt;br /&gt;
                            }&lt;br /&gt;
                     }&lt;br /&gt;
                     if (extenderPackage==null){&lt;br /&gt;
                            EventbcoreEditPlugin.INSTANCE.logError(null, &amp;quot;extending ePackage not found during Event-B EMF metamodel extension&amp;quot;);&lt;br /&gt;
                     }else{&lt;br /&gt;
                            for (IConfigurationElement element : elements) {&lt;br /&gt;
                                   if (&amp;quot;eReference&amp;quot;.equals(element.getName())){&lt;br /&gt;
                                          String eReferenceName = element.getAttribute(&amp;quot;name&amp;quot;);&lt;br /&gt;
                                          String parentName = element.getAttribute(&amp;quot;parent&amp;quot;);&lt;br /&gt;
                                          boolean containment = Boolean.parseBoolean(element.getAttribute(&amp;quot;containment&amp;quot;));&lt;br /&gt;
                                          String eTypeName = element.getAttribute(&amp;quot;eType&amp;quot;);&lt;br /&gt;
                                          String required = element.getAttribute(&amp;quot;required&amp;quot;);&lt;br /&gt;
                                          String singular = element.getAttribute(&amp;quot;singular&amp;quot;);&lt;br /&gt;
                                          Object parent=null;&lt;br /&gt;
                                          if ((parent = theCorePackage.getEClassifier(parentName)) == null)&lt;br /&gt;
                                                 if ((parent = theContextPackage.getEClassifier(parentName))==null)									&lt;br /&gt;
                                                        if ((parent = theMachinePackage.getEClassifier(parentName))==null);&lt;br /&gt;
 &lt;br /&gt;
                                          if (parent instanceof EClass){&lt;br /&gt;
                                                 EClass eType = (EClass)extenderPackage.getEClassifier(eTypeName);&lt;br /&gt;
                                                 EReference eReference = EcoreFactory.eINSTANCE.createEReference();&lt;br /&gt;
                                                 eReference.setName(eReferenceName);&lt;br /&gt;
                                                 eReference.setEType(eType);&lt;br /&gt;
                                                 eReference.setContainment(containment);&lt;br /&gt;
                                                 eReference.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY); //change to set from required and singular&lt;br /&gt;
                                                 ((EClass)parent).getEStructuralFeatures().add(eReference);&lt;br /&gt;
                                          }&lt;br /&gt;
                                   }&lt;br /&gt;
                            }&lt;br /&gt;
                     }&lt;br /&gt;
              }&lt;br /&gt;
              catch (Exception e) {&lt;br /&gt;
                     EventbcoreEditPlugin.INSTANCE.logError(e, &amp;quot;failed getting Event-B EMF extensions&amp;quot;);&lt;br /&gt;
              }&lt;br /&gt;
       }&lt;br /&gt;
 }&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;example metamodel-extension (containment definition)&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
   &amp;lt;extension&lt;br /&gt;
         point=&amp;quot;org.eventb.emf.core.metamodel_extension&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;ePackage&lt;br /&gt;
            eNS_URI=&amp;quot;http://emf.eventb.org/models/records&amp;quot;&lt;br /&gt;
            name=&amp;quot;RecordsPackage&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;/ePackage&amp;gt;&lt;br /&gt;
      &amp;lt;eReference&lt;br /&gt;
            containment=&amp;quot;true&amp;quot;&lt;br /&gt;
            eType=&amp;quot;AbstractRecord&amp;quot;&lt;br /&gt;
            name=&amp;quot;records&amp;quot;&lt;br /&gt;
            parent=&amp;quot;Context&amp;quot;&lt;br /&gt;
            required=&amp;quot;false&amp;quot;&lt;br /&gt;
            singular=&amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;/eReference&amp;gt;&lt;br /&gt;
   &amp;lt;/extension&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Colin</name></author>
	</entry>
</feed>