SlideShare une entreprise Scribd logo
1  sur  68
Dr. Jan Köhnlein, itemis AG




EMF – Beyond the Basics
Eclipse Modeling
  Framework
Eclipse Modeling
     Framework
• Create Ecore models
Eclipse Modeling
     Framework
• Create Ecore models
 • from Java, XSD, UML, MOF
Eclipse Modeling
     Framework
• Create Ecore models
 • from Java, XSD, UML, MOF
 • or from scratch
Eclipse Modeling
     Framework
• Create Ecore models
 • from Java, XSD, UML, MOF
 • or from scratch
• Generate Java-Code from Ecore
Eclipse Modeling
     Framework
• Create Ecore models
 • from Java, XSD, UML, MOF
 • or from scratch
• Generate Java-Code from Ecore
• Runtime library to process Ecore models
  and instances
Ecore
  EPackage                              EClassifer
                                    * name:String
name: String
                          eClassifiers
nsURI: String


          eSuperTypes
                          *
                         EClass                      EDatatype
                    abstract: boolean
   eReferenceType
                                                          eAttributeType

                           * eStructuralFeatures
                   EStructuralFeature
                 name: String
                 lowerBound: int
                 upperBound: int




        EReference                   EAttribute
   containment: boolean

            *
                eOpposite
Ecore Instances
Ecore Instances
• EObject
Ecore Instances
• EObject
 • Instance of an EClass
Ecore Instances
• EObject
 • Instance of an EClass
 • Values for EAttributes
Ecore Instances
• EObject
 • Instance of an EClass
 • Values for EAttributes
 • References for EReferences
Ecore Instances
• EObject
 • Instance of an EClass
 • Values for EAttributes
 • References for EReferences
• Ecore is self-describing
Ecore Instances
• EObject
 • Instance of an EClass
 • Values for EAttributes
 • References for EReferences
• Ecore is self-describing
 • EClass, EPackage etc. extend EObject
Example Ecore/Instance


                  << EPackage >>                                    <<Node>>
                    TreePackage                          parent                      parent
                                                                    myNode0
              name: quot;Treequot;
              nsURI: quot;http://www.itemis..quot;


                     <<EClass>>
                          Node
              name: quot;Nodequot;
                                                                         children
              abstract: false



     <<EReference>>                << EReference >>
         children                       parent
name: quot;childrenquot;               name: quot;parentquot;
containment: true              containment: false
                                                            << Node >>         << Node >>
upperBound: -1                 upperBound: 1
                                                             myNode2            myNode1
lowerBound: 0                  lowerBound: 0
 eOpposite                                   eOpposite
Example: Java View
               TreePackage::EPackage
              name: quot;Treequot;
                                                         myNode0::Node
              nsURI: quot;http://www.itemis..quot;                               parent



                    Node::EClass
              name: quot;Nodequot;
                                                         children
              abstract: false
                                                               ::EList


  children::EReference            parent::EReference
name: quot;childrenquot;               name: quot;parentquot;
containment: true              containment: false
upperBound: -1                 upperBound: 1
                                                         myNode1::Node
lowerBound: 0                  lowerBound: 0
 eOpposite                                   eOpposite
Example: Java View
               TreePackage::EPackage
              name: quot;Treequot;
                                                         myNode0::Node
              nsURI: quot;http://www.itemis..quot;                               parent



                    Node::EClass
              name: quot;Nodequot;
                                                         children
              abstract: false
                                                               ::EList


  children::EReference            parent::EReference
name: quot;childrenquot;               name: quot;parentquot;
containment: true              containment: false
upperBound: -1                 upperBound: 1
                                                         myNode1::Node
lowerBound: 0                  lowerBound: 0
 eOpposite                                   eOpposite




             Node myNode0 = TreeFactory.eINSTANCE.createNode();
             Node myNode1 = TreeFactory.eINSTANCE.createNode();
             myNode0.getChildren().add(myNode1);
Ecore Reflection
      EStructuralFeature




              *   eStructuralFeatures
            EClass                                       EObject                 eContents
                                   eClass
getEStructuralFeature(String):                eGet(EStructuralFeature): Object
  EStructuralFeature                          eSet(EStructuralFeature, Object)   *
              *   eClassifiers                                   eContainer




           EPackage                                            EFactory
                                            eFactory
getEClassifier(String):EClassifier                       create(EClass):EObject
Dynamic EMF
// load Ecore file
URI resourceURI = URI.createPlatformResourceURI(
   quot;de.itemis.treemodel/model/treemodel.ecorequot;, true);
Resource resource = new XMIResourceImpl(resourceURI);
		
// extract Ecore model
EPackage treePackage = (EPackage) resource.getContents().get(0);
EFactory factory = treePackage.getEFactoryInstance();
EClass nodeClass = (EClass) treePackage.getEClassifier(quot;Nodequot;);
EStructuralFeature childrenReference =
   nodeClass.getEStructuralFeature(quot;childrenquot;);
		
// create instances using reflective API
EObject myNode0 = factory.create(nodeClass);
EObject myNode1 = factory.create(nodeClass);	 	
((EList) myNode0.eGet(childrenReference)).add(myNode1);
References
References
References
                                                  Resource




     Element
                                                                                      Element
                                                                  Element
                        Element               Element



                                                                                      Element
                                                                                          Element Element
                                           Element                                            Element
     Element
                                                                       Element



Element
                                    Element Element
                                                Element                                   Element
        Element
    Element                             Element
                       Element                               Element        Element
                                                                       Element
                                                                  Element

                                                                                  Element
                                                                                                  Element
               Element                                                                Element Element
                   Element Element
                               Element                                                    Element
                       Element
References
                                                    Resource




       Element
                                                                                        Element
                                                                    Element
                          Element               Element

Containment
                                                                                        Element
                                                                                            Element Element
                                             Element                                            Element
       Element
                                                                         Element



  Element
                                      Element Element
                                                  Element                                   Element
          Element
      Element                             Element
                         Element                               Element        Element
                                                                         Element
                                                                    Element

                                                                                    Element
                                                                                                    Element
                 Element                                                                Element Element
                     Element Element
                                 Element                                                    Element
                         Element
References
                                                    Resource




       Element
                                                                                        Element
                                                                    Element
                          Element               Element

Containment
                                                                                        Element
                                                                                            Element Element
                                             Element                                            Element
       Element
                                                                         Element



  Element
                                      Element Element
                                                  Element                                   Element
          Element
      Element                             Element
                         Element                               Element        Element
                                                                         Element
                                                                    Element

                                                                                    Element
                                                                                                    Element
                 Element                                                                Element Element
                     Element Element
                                 Element                                                    Element
                         Element

                                           Cross-References
References
                                                                                         Resource
                                                    Resource

                                                                                        Containment
       Element
                                                                                        Element
                                                                    Element
                          Element               Element

Containment
                                                                                        Element
                                                                                            Element Element
                                             Element                                            Element
       Element
                                                                         Element



  Element
                                      Element Element
                                                  Element                                   Element
          Element
      Element                             Element
                         Element                               Element        Element
                                                                         Element
                                                                    Element

                                                                                    Element
                                                                                                    Element
                 Element                                                                Element Element
                     Element Element
                                 Element                                                    Element
                         Element

                                           Cross-References
Big Models
Lots of elements...


  Big Models
Lots of elements...


  Big Models
 ...and lots of references
Divide
   &
Conquer
Resource

                                                                    Element
           Element

                               Element          Element


                                                                          Element
     Element

                                          Element

                                                                               Element
                                                                    Element Element
Element
                                                                        Element
        Element
    Element          Element
                                     Element
                                             Element
                                         Element          Element


           Element
                           Element
               Element Element
                   Element
                                                Element
                                                                Element
                                                    Element Element
                                                        Element
ResourceSet



      Resource                                                                           Resource
                                     Resource              Resource


           Element                                             Element
                                      Element                                             Element




                                                                                               Element
     Element                                             Element




Element                                             Element                                          Element
                                                                                          Element Element
        Element                                             Element                           Element
    Element                                             Element
                     Element                                             Element




           Element                                             Element
                           Element                                             Element
               Element Element                                     Element Element
                   Element                                             Element
Lazy Loading
Proxy
                                         EObject


• Not yet loaded EObject
                                    eIsProxy(): boolean




• Instantiated on load for           InternalEObject

  external reference
                                   eProxyURI(): String
                                   eSetProxyURI(String)



• eProxyURI attribute set
• Replaced on resolution
                                       EObjectImpl




                                         EcoreUtil
                             resolve(EObject, ResourceSet)
                             resolve(EObject, Resource)
                             resolve(EObject, EObject)
Proxy Resolution
          ResourceSet



            Resource




                          PROXY
            Element




  Element
        Element Element
Proxy Resolution
                        ResourceSet



          Resource




                          PROXY
          Element




Element
      Element Element
Proxy Resolution
                        ResourceSet



          Resource                    Resource




                          PROXY
          Element




Element
      Element Element
Proxy Resolution
                        ResourceSet



          Resource                       Resource



                                           Element
                          PROXY
          Element



                                                Element


Element
      Element Element
                                      Element             Element
                                                Element
Proxy Resolution
                        ResourceSet



          Resource                       Resource



                                           Element
                          PROXY
          Element



                                                Element


Element
      Element Element
                                      Element             Element
                                                Element
How about unloading?
                               ResourceSet




                                               Resource
                    Resource                  Resource
                                              (unloaded)




                                              PROXY
                                              Element
          Element



                                              PROXY
                                              Element


Element
      Element Element
                                    PROXY                  PROXY
                                    Element                Element
                                              PROXY
                                              Element
How about unloading?
                               ResourceSet




                                               Resource
                    Resource                  Resource
                                              (unloaded)




                                              PROXY
                                              Element
          Element



                                              PROXY
                                              Element


Element
      Element Element
                                    PROXY                  PROXY
                                    Element                Element
                                              PROXY
                                              Element
How about unloading?
                               ResourceSet




                                               Resource
                    Resource                  Resource
                                              (unloaded)




                                              PROXY
                                              Element                        PROXY
          Element



                                              PROXY
                                              Element                        PROXY


Element
      Element Element
                                    PROXY                  PROXY
                                    Element                Element   PROXY           PROXY
                                              PROXY
                                              Element                        PROXY
Lazy Loading

• Proxy Resolution / Lazy Loading
 • Transparently when navigating references
• Unload
 • Proxifies elements
 • Keeps elements connected by default
Enabling Proxies
• For cross-references
 • Set
    EResource.isResolveProxies
• For containment references
 • Additionally set
    GenModel.isContainmentProxies
eProxyURI

• Resource URI + Fragment
  [scheme:][//authority][/path][#fragment]

• Examples:
  http://www.itemis.de/files/model.ecore#/

  file:/Users/koehnlein/test.xmi#/children.0

  platform:/resource/myproject/m2.uml#12345126
Resource URIs
• Relative or absolute                 URIConverter
                         normalize(URI): URI
                         createInputStream(URI): InputStream
                         createOutputStream(URI): OutputStream


• URIConverter
                         exists(URI)
                         delete(URI)
                         getURIMap(): Map<URI, URI>



 • Resolves URIs
 • Access to resources
                                ExtensibleURIConverter




 • Abstraction on
                                              *
                                        URIHandler
                         canHandle(URI): boolean
                         createInputStream(URI): InputStream
    I/O Access           createOutputStream(URI): OutputStream
                         exists(URI)
                         delete(URI)
Fragment
Strategies
Fragment Paths
              ::Resource
uri=quot;http://www.itemis.de/model.treequot;



                                        • Example
                   0
               ::Node

                                          •   #/0/children.3

                                        • Compact
                   children


                                        • Fragile with respect
             .1    .2     .3
        ::Node
                                          to reorderig
               ::Node
                       ::Node
Fragment Paths With Keys
                                        • Define EAttribute as key
              ::Resource
uri=quot;http://www.itemis.de/model.treequot;


                                          for EReference
                   0


                                        • Example
              ::Node
         name=quot;rootquot;




                                          •   name key of children
                   children



                                          •
 .Sven           .Peter      .Ed
                                              #/0/children.Ed
  ::Node
name=quot;Svenquot;


                                        • Assert no collisions !
           ::Node
       name=quot;Peterquot;
                         ::Node
                       name=quot;Edquot;
EAttributes as ID
              ::Resource
uri=quot;http://www.itemis.de/model.treequot;


                                        • Set ID flag on EAttribute
                   0

                                        • Example
              ::Node
        index=0



                                          •   index defined as ID

                                          •   #3
             1      2        3
    ::Node


                                        • Initialize without collisions
 index=1
               ::Node
           index=2
                          ::Node
                       index=3
Extrinsic IDs
                           ::Resource
             uri=quot;http://www.itemis.de/model.treequot;
             eObjectToIDMap = {...}




                                                     • Resource manages IDs
                           ::Node
                     index=0


                                                     • Example
    quot;ab3827d8quot;



                                                      •   #276fe78d

                                                     • UUIDs in UML2
                  ::Node

                            ::Node
quot;37fe34c2quot;
                                     ::Node
      quot;87f33bd2quot;
                  quot;276fe78dquot;
Tracking Inverse
  References
ECrossReferenceAdapter

                                           Adapter
                              notifyChanged(Notification)
                              isAdapterForType(Object): boolean



• Works for loaded
  Resources within                    EContentAdapter


  a ResourceSet
                                  ECrossReferenceAdapter
                     getInverseReferences(EObject): List<Setting>
                     getNonNavigableReferences(EObject): List<Setting>
EMF Index

• Indexes all resources in workspace
• Query elements and cross-references
EMF Index

• Indexes all resources in workspace
• Query elements and cross-references

                               Load
                             Resources
EMF Transactions
EMF Transactions
EMF Transactions
 TransactionChangeRecorder
beginRecording()                          ResourceSet
endRecording()




                                       CommandStack
 TransactionalEditingDomain
                                     execute(Command)
runExclusive(Runnable): Object
                                     undo()
                                     redo()



                                   RecordingCommand
                                 execute()
Global Singletons
Global Singletons
Global Singletons
• Configured with Eclipse extensions
Global Singletons
• Configured with Eclipse extensions
• EPackage.Registry:
  Dynamic and static Ecore models
Global Singletons
• Configured with Eclipse extensions
• EPackage.Registry:
  Dynamic and static Ecore models
• Resource.Factory.Registry
  Resource implementations
Global Singletons
• Configured with Eclipse extensions
• EPackage.Registry:
  Dynamic and static Ecore models
• Resource.Factory.Registry
  Resource implementations
• (Extensible)URIConverter
Global Singletons
• Configured with Eclipse extensions
• EPackage.Registry:
  Dynamic and static Ecore models
• Resource.Factory.Registry   Override
  Resource implementations       in

• (Extensible)URIConverter    Resource
                                Set
Questions?

Contenu connexe

Tendances

[B31] LOGMinerってレプリケーションソフトで使われているけどどうなってる? by Toshiya Morita
[B31] LOGMinerってレプリケーションソフトで使われているけどどうなってる? by Toshiya Morita[B31] LOGMinerってレプリケーションソフトで使われているけどどうなってる? by Toshiya Morita
[B31] LOGMinerってレプリケーションソフトで使われているけどどうなってる? by Toshiya Morita
Insight Technology, Inc.
 

Tendances (15)

テスト分析・設計を体感しよう ~マインドマップを活用してテスト観点を発想しよう
テスト分析・設計を体感しよう ~マインドマップを活用してテスト観点を発想しようテスト分析・設計を体感しよう ~マインドマップを活用してテスト観点を発想しよう
テスト分析・設計を体感しよう ~マインドマップを活用してテスト観点を発想しよう
 
DXのための内製化のススメ
DXのための内製化のススメDXのための内製化のススメ
DXのための内製化のススメ
 
リクルートにおける画像解析事例紹介
リクルートにおける画像解析事例紹介リクルートにおける画像解析事例紹介
リクルートにおける画像解析事例紹介
 
テスト自動化のパターンと実践
テスト自動化のパターンと実践テスト自動化のパターンと実践
テスト自動化のパターンと実践
 
スクラム開発を始めよう!TFS を使った日常コミュケーションとチームワーク
スクラム開発を始めよう!TFS を使った日常コミュケーションとチームワークスクラム開発を始めよう!TFS を使った日常コミュケーションとチームワーク
スクラム開発を始めよう!TFS を使った日常コミュケーションとチームワーク
 
[B31] LOGMinerってレプリケーションソフトで使われているけどどうなってる? by Toshiya Morita
[B31] LOGMinerってレプリケーションソフトで使われているけどどうなってる? by Toshiya Morita[B31] LOGMinerってレプリケーションソフトで使われているけどどうなってる? by Toshiya Morita
[B31] LOGMinerってレプリケーションソフトで使われているけどどうなってる? by Toshiya Morita
 
テストエンジニア版RPG風スキルマップ JaSST'17東北
テストエンジニア版RPG風スキルマップ JaSST'17東北テストエンジニア版RPG風スキルマップ JaSST'17東北
テストエンジニア版RPG風スキルマップ JaSST'17東北
 
CEDEC 2011 コンピュータ・グラフィクス関連の最新論文紹介 ~Shape Matching法とその周辺技術~
CEDEC 2011 コンピュータ・グラフィクス関連の最新論文紹介 ~Shape Matching法とその周辺技術~CEDEC 2011 コンピュータ・グラフィクス関連の最新論文紹介 ~Shape Matching法とその周辺技術~
CEDEC 2011 コンピュータ・グラフィクス関連の最新論文紹介 ~Shape Matching法とその周辺技術~
 
Snowflake architecture and_performance_kansaidb20180421
Snowflake architecture and_performance_kansaidb20180421Snowflake architecture and_performance_kansaidb20180421
Snowflake architecture and_performance_kansaidb20180421
 
20180918_ops on azure-main
20180918_ops on azure-main20180918_ops on azure-main
20180918_ops on azure-main
 
大規模負荷試験時にやったこと
大規模負荷試験時にやったこと大規模負荷試験時にやったこと
大規模負荷試験時にやったこと
 
ソフトウェア更新プログラム (パッチ) 管理手法勉強会 1 回目
ソフトウェア更新プログラム (パッチ) 管理手法勉強会 1 回目ソフトウェア更新プログラム (パッチ) 管理手法勉強会 1 回目
ソフトウェア更新プログラム (パッチ) 管理手法勉強会 1 回目
 
20150829 Java女子部勉強会 Java EEハンズオン
20150829 Java女子部勉強会 Java EEハンズオン20150829 Java女子部勉強会 Java EEハンズオン
20150829 Java女子部勉強会 Java EEハンズオン
 
unity 軌跡
unity 軌跡unity 軌跡
unity 軌跡
 
IT企業のジャーマネ視点から Power Apps 導入など
IT企業のジャーマネ視点から Power Apps 導入などIT企業のジャーマネ視点から Power Apps 導入など
IT企業のジャーマネ視点から Power Apps 導入など
 

Similaire à EMF - Beyond The Basics

Building RESTful Java Applications with EMF
Building RESTful Java Applications with EMFBuilding RESTful Java Applications with EMF
Building RESTful Java Applications with EMF
Kenn Hussey
 
Deep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explainedDeep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explained
Holger Schill
 
Memory Leaks In Internet Explorer
Memory Leaks In Internet ExplorerMemory Leaks In Internet Explorer
Memory Leaks In Internet Explorer
Christopher Blum
 
Memory Leaks In Internet Explorer
Memory Leaks In Internet ExplorerMemory Leaks In Internet Explorer
Memory Leaks In Internet Explorer
Christopher Blum
 
Alfresco in few points - Search Tutorial
Alfresco in few points - Search TutorialAlfresco in few points - Search Tutorial
Alfresco in few points - Search Tutorial
PASCAL Jean Marie
 

Similaire à EMF - Beyond The Basics (20)

Building RESTful Java Applications with EMF
Building RESTful Java Applications with EMFBuilding RESTful Java Applications with EMF
Building RESTful Java Applications with EMF
 
Deep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explainedDeep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explained
 
Memory Leaks In Internet Explorer
Memory Leaks In Internet ExplorerMemory Leaks In Internet Explorer
Memory Leaks In Internet Explorer
 
Spring ME
Spring MESpring ME
Spring ME
 
Memory Leaks In Internet Explorer
Memory Leaks In Internet ExplorerMemory Leaks In Internet Explorer
Memory Leaks In Internet Explorer
 
Pro bun-fighting - Working with JavaScript projects
Pro bun-fighting - Working with JavaScript projectsPro bun-fighting - Working with JavaScript projects
Pro bun-fighting - Working with JavaScript projects
 
Alfresco in few points - Search Tutorial
Alfresco in few points - Search TutorialAlfresco in few points - Search Tutorial
Alfresco in few points - Search Tutorial
 
"this" in JavaScript
"this" in JavaScript"this" in JavaScript
"this" in JavaScript
 
Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009
 
SPL, not a bridge too far
SPL, not a bridge too farSPL, not a bridge too far
SPL, not a bridge too far
 
Ruby Classes
Ruby ClassesRuby Classes
Ruby Classes
 
Overcoming The Impedance Mismatch Between Source Code And Architecture
Overcoming The Impedance Mismatch Between Source Code And ArchitectureOvercoming The Impedance Mismatch Between Source Code And Architecture
Overcoming The Impedance Mismatch Between Source Code And Architecture
 
Akka and the Zen of Reactive System Design
Akka and the Zen of Reactive System DesignAkka and the Zen of Reactive System Design
Akka and the Zen of Reactive System Design
 
JavaScript Essentials
JavaScript EssentialsJavaScript Essentials
JavaScript Essentials
 
The Xtext Grammar Language
The Xtext Grammar LanguageThe Xtext Grammar Language
The Xtext Grammar Language
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
JSF Custom Components
JSF Custom ComponentsJSF Custom Components
JSF Custom Components
 
Iphone course 1
Iphone course 1Iphone course 1
Iphone course 1
 
03 managing relationships
03   managing relationships03   managing relationships
03 managing relationships
 
EMF Index
EMF IndexEMF Index
EMF Index
 

Plus de Dr. Jan Köhnlein

A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editing
Dr. Jan Köhnlein
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editing
Dr. Jan Köhnlein
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editing
Dr. Jan Köhnlein
 

Plus de Dr. Jan Köhnlein (20)

The Eclipse Layout Kernel sirius con 2017
The Eclipse Layout Kernel   sirius con 2017The Eclipse Layout Kernel   sirius con 2017
The Eclipse Layout Kernel sirius con 2017
 
A New Approach Towards Web-based IDEs
A New Approach Towards Web-based IDEsA New Approach Towards Web-based IDEs
A New Approach Towards Web-based IDEs
 
Responsiveness
ResponsivenessResponsiveness
Responsiveness
 
Getting rid of backtracking
Getting rid of backtrackingGetting rid of backtracking
Getting rid of backtracking
 
Graphical Views For Xtext With FXDiagram
Graphical Views For Xtext With FXDiagramGraphical Views For Xtext With FXDiagram
Graphical Views For Xtext With FXDiagram
 
XRobots
XRobotsXRobots
XRobots
 
Diagrams, Xtext and UX
Diagrams, Xtext and UXDiagrams, Xtext and UX
Diagrams, Xtext and UX
 
Scoping
ScopingScoping
Scoping
 
Xtext, diagrams and ux
Xtext, diagrams and uxXtext, diagrams and ux
Xtext, diagrams and ux
 
Diagram Editors - The FXed Generation
Diagram Editors - The FXed GenerationDiagram Editors - The FXed Generation
Diagram Editors - The FXed Generation
 
Code Generation With Xtend
Code Generation With XtendCode Generation With Xtend
Code Generation With Xtend
 
Graphical Views For Xtext
Graphical Views For XtextGraphical Views For Xtext
Graphical Views For Xtext
 
Eclipse Diagram Editors - An Endangered Species
Eclipse Diagram Editors - An Endangered SpeciesEclipse Diagram Editors - An Endangered Species
Eclipse Diagram Editors - An Endangered Species
 
Java DSLs with Xtext
Java DSLs with XtextJava DSLs with Xtext
Java DSLs with Xtext
 
DSLs for Java Developers
DSLs for Java DevelopersDSLs for Java Developers
DSLs for Java Developers
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editing
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editing
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editing
 
Pragmatic DSL Design with Xtext, Xbase and Xtend 2
Pragmatic DSL Design with Xtext, Xbase and Xtend 2Pragmatic DSL Design with Xtext, Xbase and Xtend 2
Pragmatic DSL Design with Xtext, Xbase and Xtend 2
 
What's Cooking in Xtext 2.0
What's Cooking in Xtext 2.0What's Cooking in Xtext 2.0
What's Cooking in Xtext 2.0
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

EMF - Beyond The Basics

  • 1. Dr. Jan Köhnlein, itemis AG EMF – Beyond the Basics
  • 2.
  • 3. Eclipse Modeling Framework
  • 4. Eclipse Modeling Framework • Create Ecore models
  • 5. Eclipse Modeling Framework • Create Ecore models • from Java, XSD, UML, MOF
  • 6. Eclipse Modeling Framework • Create Ecore models • from Java, XSD, UML, MOF • or from scratch
  • 7. Eclipse Modeling Framework • Create Ecore models • from Java, XSD, UML, MOF • or from scratch • Generate Java-Code from Ecore
  • 8. Eclipse Modeling Framework • Create Ecore models • from Java, XSD, UML, MOF • or from scratch • Generate Java-Code from Ecore • Runtime library to process Ecore models and instances
  • 9. Ecore EPackage EClassifer * name:String name: String eClassifiers nsURI: String eSuperTypes * EClass EDatatype abstract: boolean eReferenceType eAttributeType * eStructuralFeatures EStructuralFeature name: String lowerBound: int upperBound: int EReference EAttribute containment: boolean * eOpposite
  • 12. Ecore Instances • EObject • Instance of an EClass
  • 13. Ecore Instances • EObject • Instance of an EClass • Values for EAttributes
  • 14. Ecore Instances • EObject • Instance of an EClass • Values for EAttributes • References for EReferences
  • 15. Ecore Instances • EObject • Instance of an EClass • Values for EAttributes • References for EReferences • Ecore is self-describing
  • 16. Ecore Instances • EObject • Instance of an EClass • Values for EAttributes • References for EReferences • Ecore is self-describing • EClass, EPackage etc. extend EObject
  • 17. Example Ecore/Instance << EPackage >> <<Node>> TreePackage parent parent myNode0 name: quot;Treequot; nsURI: quot;http://www.itemis..quot; <<EClass>> Node name: quot;Nodequot; children abstract: false <<EReference>> << EReference >> children parent name: quot;childrenquot; name: quot;parentquot; containment: true containment: false << Node >> << Node >> upperBound: -1 upperBound: 1 myNode2 myNode1 lowerBound: 0 lowerBound: 0 eOpposite eOpposite
  • 18. Example: Java View TreePackage::EPackage name: quot;Treequot; myNode0::Node nsURI: quot;http://www.itemis..quot; parent Node::EClass name: quot;Nodequot; children abstract: false ::EList children::EReference parent::EReference name: quot;childrenquot; name: quot;parentquot; containment: true containment: false upperBound: -1 upperBound: 1 myNode1::Node lowerBound: 0 lowerBound: 0 eOpposite eOpposite
  • 19. Example: Java View TreePackage::EPackage name: quot;Treequot; myNode0::Node nsURI: quot;http://www.itemis..quot; parent Node::EClass name: quot;Nodequot; children abstract: false ::EList children::EReference parent::EReference name: quot;childrenquot; name: quot;parentquot; containment: true containment: false upperBound: -1 upperBound: 1 myNode1::Node lowerBound: 0 lowerBound: 0 eOpposite eOpposite Node myNode0 = TreeFactory.eINSTANCE.createNode(); Node myNode1 = TreeFactory.eINSTANCE.createNode(); myNode0.getChildren().add(myNode1);
  • 20. Ecore Reflection EStructuralFeature * eStructuralFeatures EClass EObject eContents eClass getEStructuralFeature(String): eGet(EStructuralFeature): Object EStructuralFeature eSet(EStructuralFeature, Object) * * eClassifiers eContainer EPackage EFactory eFactory getEClassifier(String):EClassifier create(EClass):EObject
  • 21. Dynamic EMF // load Ecore file URI resourceURI = URI.createPlatformResourceURI( quot;de.itemis.treemodel/model/treemodel.ecorequot;, true); Resource resource = new XMIResourceImpl(resourceURI); // extract Ecore model EPackage treePackage = (EPackage) resource.getContents().get(0); EFactory factory = treePackage.getEFactoryInstance(); EClass nodeClass = (EClass) treePackage.getEClassifier(quot;Nodequot;); EStructuralFeature childrenReference = nodeClass.getEStructuralFeature(quot;childrenquot;); // create instances using reflective API EObject myNode0 = factory.create(nodeClass); EObject myNode1 = factory.create(nodeClass); ((EList) myNode0.eGet(childrenReference)).add(myNode1);
  • 24. References Resource Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element
  • 25. References Resource Element Element Element Element Element Containment Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element
  • 26. References Resource Element Element Element Element Element Containment Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Cross-References
  • 27. References Resource Resource Containment Element Element Element Element Element Containment Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Cross-References
  • 29. Lots of elements... Big Models
  • 30. Lots of elements... Big Models ...and lots of references
  • 31. Divide & Conquer
  • 32.
  • 33. Resource Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element
  • 34. ResourceSet Resource Resource Resource Resource Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element Element
  • 36. Proxy EObject • Not yet loaded EObject eIsProxy(): boolean • Instantiated on load for InternalEObject external reference eProxyURI(): String eSetProxyURI(String) • eProxyURI attribute set • Replaced on resolution EObjectImpl EcoreUtil resolve(EObject, ResourceSet) resolve(EObject, Resource) resolve(EObject, EObject)
  • 37. Proxy Resolution ResourceSet Resource PROXY Element Element Element Element
  • 38. Proxy Resolution ResourceSet Resource PROXY Element Element Element Element
  • 39. Proxy Resolution ResourceSet Resource Resource PROXY Element Element Element Element
  • 40. Proxy Resolution ResourceSet Resource Resource Element PROXY Element Element Element Element Element Element Element Element
  • 41. Proxy Resolution ResourceSet Resource Resource Element PROXY Element Element Element Element Element Element Element Element
  • 42. How about unloading? ResourceSet Resource Resource Resource (unloaded) PROXY Element Element PROXY Element Element Element Element PROXY PROXY Element Element PROXY Element
  • 43. How about unloading? ResourceSet Resource Resource Resource (unloaded) PROXY Element Element PROXY Element Element Element Element PROXY PROXY Element Element PROXY Element
  • 44. How about unloading? ResourceSet Resource Resource Resource (unloaded) PROXY Element PROXY Element PROXY Element PROXY Element Element Element PROXY PROXY Element Element PROXY PROXY PROXY Element PROXY
  • 45. Lazy Loading • Proxy Resolution / Lazy Loading • Transparently when navigating references • Unload • Proxifies elements • Keeps elements connected by default
  • 46. Enabling Proxies • For cross-references • Set EResource.isResolveProxies • For containment references • Additionally set GenModel.isContainmentProxies
  • 47. eProxyURI • Resource URI + Fragment [scheme:][//authority][/path][#fragment] • Examples: http://www.itemis.de/files/model.ecore#/ file:/Users/koehnlein/test.xmi#/children.0 platform:/resource/myproject/m2.uml#12345126
  • 48. Resource URIs • Relative or absolute URIConverter normalize(URI): URI createInputStream(URI): InputStream createOutputStream(URI): OutputStream • URIConverter exists(URI) delete(URI) getURIMap(): Map<URI, URI> • Resolves URIs • Access to resources ExtensibleURIConverter • Abstraction on * URIHandler canHandle(URI): boolean createInputStream(URI): InputStream I/O Access createOutputStream(URI): OutputStream exists(URI) delete(URI)
  • 50. Fragment Paths ::Resource uri=quot;http://www.itemis.de/model.treequot; • Example 0 ::Node • #/0/children.3 • Compact children • Fragile with respect .1 .2 .3 ::Node to reorderig ::Node ::Node
  • 51. Fragment Paths With Keys • Define EAttribute as key ::Resource uri=quot;http://www.itemis.de/model.treequot; for EReference 0 • Example ::Node name=quot;rootquot; • name key of children children • .Sven .Peter .Ed #/0/children.Ed ::Node name=quot;Svenquot; • Assert no collisions ! ::Node name=quot;Peterquot; ::Node name=quot;Edquot;
  • 52. EAttributes as ID ::Resource uri=quot;http://www.itemis.de/model.treequot; • Set ID flag on EAttribute 0 • Example ::Node index=0 • index defined as ID • #3 1 2 3 ::Node • Initialize without collisions index=1 ::Node index=2 ::Node index=3
  • 53. Extrinsic IDs ::Resource uri=quot;http://www.itemis.de/model.treequot; eObjectToIDMap = {...} • Resource manages IDs ::Node index=0 • Example quot;ab3827d8quot; • #276fe78d • UUIDs in UML2 ::Node ::Node quot;37fe34c2quot; ::Node quot;87f33bd2quot; quot;276fe78dquot;
  • 54. Tracking Inverse References
  • 55. ECrossReferenceAdapter Adapter notifyChanged(Notification) isAdapterForType(Object): boolean • Works for loaded Resources within EContentAdapter a ResourceSet ECrossReferenceAdapter getInverseReferences(EObject): List<Setting> getNonNavigableReferences(EObject): List<Setting>
  • 56. EMF Index • Indexes all resources in workspace • Query elements and cross-references
  • 57. EMF Index • Indexes all resources in workspace • Query elements and cross-references Load Resources
  • 60. EMF Transactions TransactionChangeRecorder beginRecording() ResourceSet endRecording() CommandStack TransactionalEditingDomain execute(Command) runExclusive(Runnable): Object undo() redo() RecordingCommand execute()
  • 63. Global Singletons • Configured with Eclipse extensions
  • 64. Global Singletons • Configured with Eclipse extensions • EPackage.Registry: Dynamic and static Ecore models
  • 65. Global Singletons • Configured with Eclipse extensions • EPackage.Registry: Dynamic and static Ecore models • Resource.Factory.Registry Resource implementations
  • 66. Global Singletons • Configured with Eclipse extensions • EPackage.Registry: Dynamic and static Ecore models • Resource.Factory.Registry Resource implementations • (Extensible)URIConverter
  • 67. Global Singletons • Configured with Eclipse extensions • EPackage.Registry: Dynamic and static Ecore models • Resource.Factory.Registry Override Resource implementations in • (Extensible)URIConverter Resource Set

Notes de l'éditeur