Ákos Horváth Gábor Bergmann Dániel Varró István Ráth Model Driven Software Development Lecture 3

Hasonló dokumentumok
Ákos Horváth Gábor Bergmann Dániel Varró István Ráth Model Driven Software Development Lecture 3

Simulation and transformation of domain-specific languages. Master s Thesis

Domain- specifikus modellezés az Eclipse Modeling Framework használatával

Szoftver-technológia II. Tervezési minták. Irodalom. Szoftver-technológia II.

Declarative Specification of Domain Specific Visual Languages. Master s Thesis. Dr. Dániel Varró assistant professor

Széchenyi István Egyetem

Code Generation. Ákos Horváth Gábor Bergmann Dániel Varró Model Driven Systems Development Lecture 8. Budapesti Műszaki és Gazdaságtudományi Egyetem

Using the CW-Net in a user defined IP network

Cloud computing. Cloud computing. Dr. Bakonyi Péter.

Performance Modeling of Intelligent Car Parking Systems

Cloud computing Dr. Bakonyi Péter.

Modell alapú rendszertervezés

KOGGM614 JÁRMŰIPARI KUTATÁS ÉS FEJLESZTÉS FOLYAMATA

Introduction. Szolgáltatásorientált rendszerintegráció Service-Oriented System Integration. Dr. Balázs Simon BME, IIT

Web Services. (webszolgáltatások): egy osztott alkalmazásfejlesztési plattform

Metamodellezés. Simon Balázs BME IIT, 2011.

Több app. Egy kódbázis

Genome 373: Hidden Markov Models I. Doug Fowler

EN United in diversity EN A8-0206/419. Amendment

Correlation & Linear Regression in SPSS

Adatbázis-kezelés ODBC driverrel

discosnp demo - Peterlongo Pierre 1 DISCOSNP++: Live demo

Modell Alapú Szoftverfejlesztés Eclipse-szel

Incremental Static Analysis of Large Source Code Repositories

Modellalkotás UML-ben

István Micsinai Csaba Molnár: Analysing Parliamentary Data in Hungarian

Java Development Alapképzés

Cluster Analysis. Potyó László

Csatlakozás a BME eduroam hálózatához Setting up the BUTE eduroam network

Miskolci Egyetem Gazdaságtudományi Kar Üzleti Információgazdálkodási és Módszertani Intézet. Correlation & Linear. Petra Petrovics.

Pénzügy, számvitel. Váradi Mónika

Fejlesztési projektek menedzselése IBM Rational CLM termékekkel. Ker-Soft Kft. Kaszás Orsolya - üzleti tanácsadó

EEA, Eionet and Country visits. Bernt Röndell - SES

Professional competence, autonomy and their effects

Földtani térképek kartografálásának segítése térinformatikai módszerekkel

On The Number Of Slim Semimodular Lattices

Utolsó módosítás:

A modern e-learning lehetőségei a tűzoltók oktatásának fejlesztésében. Dicse Jenő üzletfejlesztési igazgató

ENROLLMENT FORM / BEIRATKOZÁSI ADATLAP

ios alkalmazásfejlesztés Koltai Róbert

Ráth István. A fejlesztés evolúciója

Kinek szól a könyv? Hogyan épül fel a könyv? Megjelenés előtti szoftver A hálózati kézikönyv tartalma A könyv támogatása Kérdések és megjegyzések

Correlation & Linear Regression in SPSS

ANGOL NYELV KÖZÉPSZINT SZÓBELI VIZSGA I. VIZSGÁZTATÓI PÉLDÁNY

Rezgésdiagnosztika. Diagnosztika

SQL/PSM kurzorok rész

Ellenőrző lista. 2. Hálózati útvonal beállítások, kapcsolatok, névfeloldások ellenőrzése: WebEC és BKPR URL-k kliensről történő ellenőrzése.

EN United in diversity EN A8-0206/473. Amendment

STUDENT LOGBOOK. 1 week general practice course for the 6 th year medical students SEMMELWEIS EGYETEM. Name of the student:

Create & validate a signature

Osztott alkalmazások fejlesztési technológiái Áttekintés

Osztott Objektumarchitektúrák

SOPHOS simple + secure. A dobozba rejtett biztonság UTM 9. Kókai Gábor - Sophos Advanced Engineer Balogh Viktor - Sophos Architect SOPHOS

LAUDATIO TO Professor László Varga

ANGOL NYELV KÖZÉPSZINT SZÓBELI VIZSGA I. VIZSGÁZTATÓI PÉLDÁNY

KÉPI INFORMÁCIÓK KEZELHETŐSÉGE. Forczek Erzsébet SZTE ÁOK Orvosi Informatikai Intézet. Összefoglaló

Model-Driven Design and Verification of Component-Based Reactive Systems

Ráth István. DECOS Nemzeti Nap október 15. Budapesti Műszaki és Gazdaságtudományi Egyetem Méréstechnika és Információs Rendszerek Tanszék

4. Gyakorlat: Csoportházirend beállítások

Az M2M szabványosítási helyzete

Szoftver-technológia II. A RUP szoftverfolyamat. Irodalom

Az üzleti igények átültetése a gyakorlatba eszköz és módszertan: - ARIS és WebSphere megoldások együttes használata a folyamatmendzsmentben -

Skills Development at the National University of Public Service

Intézményi IKI Gazdasági Nyelvi Vizsga

Összegzés és hogyan tovább

C#, OOP. Osztályok tervezése C#-ban

CORBA Áttekintés. Mi a CORBA? OMG and OMA. Ficsor Lajos. Miskolci Egyetem Általános Informatikai Tanszék

problémák elvárások megoldások EAI MDA MOF CWM köztes Sw eszközök hatékonyság konklúzió 09:09 problémák elvárások megoldások EAI MDA MOF CWM

HU ISSN

A nagyméretű és nagy mennyiségű adatok kezelésének adatbázis technológiai következményei Vállalati információrendszerek GIKOF 2013

Longman Exams Dictionary egynyelvű angol szótár nyelvvizsgára készülőknek

Év Tájépítésze pályázat Wallner Krisztina. 1. Vízparti sétány kiépítése Balatonfüreden, 3 km hosszon

USER MANUAL Guest user

WCF, Entity Framework, ASP.NET, WPF 1. WCF service-t (adatbázissal Entity Framework) 2. ASP.NET kliens 3. WPF kliens

Tájékoztató a évi határon átnyúló pénzügyi fogyasztói jogviták rendezésével összefüggő és egyéb nemzetközi tevékenységről

Smaller Pleasures. Apróbb örömök. Keleti lakk tárgyak Répás János Sándor mûhelyébõl Lacquerware from the workshop of Répás János Sándor

Teszt topológia E1/1 E1/0 SW1 E1/0 E1/0 SW3 SW2. Kuris Ferenc - [HUN] Cisco Blog -

Statistical Inference

Felnőttképzés Európában

± ± ± ƒ ± ± ± ± ± ± ± ƒ. ± ± ƒ ± ± ± ± ƒ. ± ± ± ± ƒ

Bevezetés a kvantum-informatikába és kommunikációba 2015/2016 tavasz

Önkiszolgáló BI infrastruktúra az adatvezérelt teljesítménymenedzsmentben

A forrás pontos megnevezésének elmulasztása valamennyi hivatkozásban szerzői jogsértés (plágium).

Meteorológiai ensemble elırejelzések hidrológiai célú alkalmazásai

Contact us Toll free (800) fax (800)

AZ APACHE MAVEN ÉLETE ÉS HALÁLA.! Cservenák Tamás

Szoftver min ség és menedzsment

A kreatív iparág és az új média összefonódása

Road traffic-control equipment

Oracle SQL Developer Data Modeler és a DW adatmodellezés. Gollnhofer Gábor Meta Consulting Kft.

Közösség, projektek, IDE

Dependency preservation

FAMILY STRUCTURES THROUGH THE LIFE CYCLE

Zumtobel Lighting - ecocalc. Csizmadia Zoltán

Új funkciók az RBP-ben október 1-től New functions in RBP from 1 October Tatár Balázs

1. Gyakorlat: Telepítés: Windows Server 2008 R2 Enterprise, Core, Windows 7

BÍRÁLATOK ÉS KONFERENCIÁK

Mikroszkopikus közlekedési szimulátor fejlesztése és validálása (Development and validating an urban traffic microsimulation)

Utolsó módosítás:

Phenotype. Genotype. It is like any other experiment! What is a bioinformatics experiment? Remember the Goal. Infectious Disease Paradigm

Átírás:

Domain-specific modeling (and the Eclipse Modeling Framework) Ákos Horváth Gábor Bergmann Dániel Varró István Ráth Model Driven Software Development Lecture 3 Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

OVERVIEW Metamodeling and Domain Specific Modeling

Domain specific modeling languages Business analyst Business process System designer Dependability expert Dependability model Risk model Security expert Software developer Programming language Software model Metamodeling and Domain Specific Modeling Software architect

Concrete syntax Usage example of DSMs Abstract syntax Well-formedness constraints Behavioural semantics, simulation, refactoring Call graph (view) Metamodeling and Domain Specific Modeling State machines (different DSM)

Graphical syntax Structure of DSMs Abstract syntax Well-formedness constraints Behavioural semantics, simulation, refactoring Mapping Code generation Textual syntax View Code (documentation, configuration) Metamodeling and Domain Specific Modeling

Aspects of Defining DSMLs Abstract syntax Collaborate Wellformedness constraints DSML Views translations mappings Concrete syntax Behavioural (dynamic) semantics Metamodeling and Domain Specific Modeling

Role of EMF/Ecore technology in DSL GMF, Graphiti, EuGENia, Sirius, Spray, Xtext, Edit Goal: Provide common base for advanced DSL tools Consistent model manipulation Persist models Tree based editor EMF Compare EMF Store, CDO, Collaborate EMF modeling core Process & View Acceleo, ATL, Epsilon, IncQuery, QVT, Xtend, Metamodeling and Domain Specific Modeling

DOMAIN SPECIFIC MODELING Metamodeling and Domain Specific Modeling

Designing modeling languages Language design checklist o Abstract syntax (metamodel) Taxonomy and relationships of model elements Well-formedness rules o Semantics (does not strictly belong to a language) Static Behavioural o??? o Concrete syntax Textual notation Visual notation Metamodeling and Domain Specific Modeling

Revisiting the example Generalization Automaton initial states transitions Association Instantiation Meta (Language) level AccState State from color:{r,g,b} to Metamodel Transition Class Attribute (Instance) Model level Object Link fr t3 ini to s1 st st a1 s3 fr tr st tr to t1 s2 t2 to fr Model in abstract syntax Metamodeling and Domain Specific Modeling

Revisiting the example Automaton Meta (Language) level initial states transitions AccState State from Transition color:{r,g,b} to Metamodel Model level fr t3 ini to s1 st st a1 s3 fr tr st tr to t1 s2 t2 to fr a1 s1 t3 t1 s3 s2 t2 Abstract syntax Concrete syntax Metamodeling and Domain Specific Modeling

Example: Concrete Syntax request() { if (state == "idle" && this.load<10) state = "calculating"; } response() { if (state == "calculating") state = "idle" } Graphical notation Textual notation Metamodeling and Domain Specific Modeling

Textual notation: Textual vs. Visual + Easy to write: Able to capture complex expressions - Difficult to read: Difficult to comprehend and manage after certain complexity (e.g what refers me?) Visual notation: + Easy to read: Able to express (selected / subset of) details in an intuitive, understandable form + Safe to write: Able to construct syntactically correct models - Difficult to write: graphical editing is slower Metamodeling and Domain Specific Modeling

Abstract Syntax Example: UML model Graphical notation (Class Diagram) Metamodeling and Domain </packagedelement> Specific Modeling <?xml version="1.0" encoding="utf-8"?> <uml:package name="geography" xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/xmi/2.1" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/uml" xmi:id="_7qi_as2ued-vcp9iy9gyhg"> [...] <packagedelement xmi:type="uml:class" name="country" xmi <ownedattribute name="name" aggregation="composite" xm <type xmi:type="uml:primitivetype" href="pathmap://u </ownedattribute> <ownedattribute name="formercapitals" aggregation="com <uppervalue value="*" xmi:type="uml:literalunlimited <lowervalue xmi:type="uml:literalinteger" xmi:id="_y </ownedattribute> <ownedoperation name="coup" xmi:id="_fhicec2ved-vcp9iy <ownedparameter direction="return" xmi:id="_le7b8c2v </ownedoperation> </packagedelement> <packagedelement xmi:type="uml:class" name="city" xmi:id <ownedattribute name="name" aggregation="composite" xm <type xmi:type="uml:primitivetype" href="pathmap://u </ownedattribute> <ownedattribute name="founded" aggregation="composite" <type xmi:type="uml:primitivetype" href="pathmap://u </ownedattribute> </packagedelement> <packagedelement xmi:type="uml:association" xmi:id="_xq_ <ownedend name="cities" type=" KgpUC2vEd-VCP9iY9GYHg" <uppervalue value="*" xmi:type="uml:literalunlimited <lowervalue value="1" xmi:type="uml:literalinteger" </ownedend> Textual notation <ownedend name="country" type="_ggassc2ved-vcp9iy9gyhg <uppervalue xmi:type="uml:literalunlimitednatural" (XMI 2.1) x <lowervalue xmi:type="uml:literalinteger" value="1" </ownedend>

One-to-many Multiplicity of Notations o 1 abstract syntax many textual and visual notations Human-readable-writable textual or visual syntax Textual syntax for exchange or storage (typically XML) In case of UML, each diagram is only a partial view o 1 abstract model many concrete forms in 1 syntax! Whitespace, diagram layout Comments Syntactic sugar o 1 semantic interpretation many abstract models e.g. UML2 Attribute vs. one-way Association Metamodeling and Domain Specific Modeling

METALEVELS Metamodeling and Domain Specific Modeling

Metalevels Automaton AccState «instance» initial State states color:{r,g,b} from to transitions Transition Meta relationship between models fr ini t3 to st st s1 a1 s3 tr st tr fr to t1 s2 t2 to fr Clear level separation: o Loses some flexibility Metamodeling and Domain Specific Modeling o Much easier to understand o Usually enough to keep two levels in mind at once

Metalevels in MOF OMG s MOF (Meta Object Facility) o 4-layer approach M3 level meta-metamodel MOF Model Fixed: MetaClass, MetaAttr, M2 level metamodel UML Metamodel MetaClass ( Class, MetaAttr ( name )) MetaClass ( Attr, MetaAttr ( name )) M1 level model UML Model Class( Car,Attr( licenseplate )) M0 level data Application Data Car( ABC-123 ), Car( DEF-456 ) o Why exactly four levels? Metamodeling and Domain Specific Modeling

Metalevels in other approaches EMF (Eclipse Modeling Framework) meta-metamodel Ecore Fixed: EClass, EAttr metamodel Ecore Model (EPackage) «instance» EClass( Car,EAttr( licenseplate )) model Multi-level metamodeling o VPM o Ontologies Application Data (Resource) «instance» Car( ABC-123 ), Car( DEF-456 ) Metamodeling and Domain Specific Modeling

SEMANTICS Metamodeling and Domain Specific Modeling

Semantics Semantics: the meaning of concepts in a language o Static: what does a snapshot of a model mean? o Dynamic: how does the model change/evolve/behave? Static Semantics o Interpretation of metamodel elements o Meaning of concepts in the abstract syntax o Formal: mathematical statements about the interpretation E.g. formally defined semantics of OCL Metamodeling and Domain Specific Modeling

Dynamic Semantics Operational o Modeling the operational behavior of language concepts o interpreted o e.g. defining how the finite automaton may change state at run-time o Sometimes dynamic features are introduced only for formalizing dynamic sematics Denotational (Translational) o translating concepts in one language to another language (called semantic domain) o compiled o E.g. explaining state machines as Petri-net Metamodeling and Domain Specific Modeling

Example: Denotational semantics Automaton Meta (Language) level initial states transitions AccState State from Transition color:{r,g,b} to Metamodel Model level t3 fr to ini st st s1 a1 s3 tr st tr fr to a1 s1 t3 s3 t1 s2 t2 to fr t1 s2 t2 Abstract syntax Semantic Domain Metamodeling and Domain Specific Modeling

Example: Operational semantics Dynamic feature Meta (Language) level current AccState Automaton initial states transitions State from Transition color:{r,g,b} to Metamodel (Instance) Model level At first, current = initial fr ini st st s1 a1 s3 tr st tr fr to t1 s2 t2 to fr Metamodeling and Domain Specific Modeling t3 to Model in abstract syntax Possible evolution: current is redirected along a transition

Relationship of models scanning and parsing Concrete syntax Abstract syntax layout operational semantics denotational semantics semantic feedback Semantic domain/ Programming language Metamodeling and Domain Specific Modeling

DOMAIN-SPECIFIC MODELING LANGUAGES IN ENGINEERING PRACTICE Metamodeling and Domain Specific Modeling

Well known DSLs MATLAB, SQL, Erlang, Shell scripts, AWK, Verilog, YACC, R,S, Mathematica, XSLT, XMI, OCL, Template languages, Metamodeling and Domain Specific Modeling

Automotive Industry standard DSMLs o AUTOSAR, MATLAB StateFlow, EAST-AADL Aerospace o AADL Railways o UML-MARTE Systems engineering o SysML, UML-FT Metamodeling and Domain Specific Modeling

Technologies MATLAB Rational Software Architect Eclipse o EMF, Sirius o Xtext/Xcore/etc. Microsoft o DSL Tools (Visual Studio) MetaCase o MetaEdit+ JetBrains MPS GEMS, GME, ViatraDSM COTS Language engineering (industry) Academia Metamodeling and Domain Specific Modeling

MetaEdit+ Metamodeling and Domain Specific Modeling

Eclipse GMF Metamodeling and Domain Specific Modeling

Microsoft DSL Tools Metamodeling and Domain Specific Modeling

MPS Metamodeling and Domain Specific Modeling

GME Metamodeling and Domain Specific Modeling

ViatraDSM Metamodeling and Domain Specific Modeling

Metamodeling Summary of DSMs o Structural, formal definition of domains o Abstract syntax Domain-Specific Modeling o Concrete notations o Syntax known by experts of the field Metalevels o Meta-relationship between models Semantics o Formal dynamic Denotational / Operational Metamodeling and Domain Specific Modeling

ECLIPSE MODELING FRAMEWORK Metamodeling and Domain Specific Modeling

What does EMF provide? EMF = Eclipse Modeling Framework o Reflective Metamodeling Core (Ecore MOF 2.0) o Support for Domain Specific Languages o Editing Support (Notification, Undo, Commands) o Basic Editor Support o XMI Serialization, DB Persistence o Eclipse Integration Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EMF model structure Containment hierarchy ResourceSet EObject Root object (typically single) EObject EObject EObject EObject Resource EObject Containment reference EObject Cross-reference Resource (typically file) Resource Objects with attributes Metamodeling and Domain Specific Modeling

ECORE METAMODELLING Metamodeling and Domain Specific Modeling

Core Ecore constructs Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Core Ecore constructs Class with arbitrary num. of superclasses associations attributes Typed Attribute Méréstechnika és Információs Rendszerek Tanszék Unidirectional (binary) relation (Association) typed optional inverse end multiplicities Metamodeling and Domain Specific Modeling

Complete Ecore hiearchy Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Complete Ecore hiearchy Abstract Class Aside: EClass deep_instantiates(2) EObject = every EClass instance implicitly subtypes EObject = every instance of every instance of EClass implicitly instantiates EObject Methods connected to the EClasses EMF-based Enums Parameter for the Eoperation Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

DEFINING A DSM THE EMF WAY Metamodeling and Domain Specific Modeling

The Classical EMF/Ecore Waterfall Design domain metamodel (Questionnaire.ecore) Specify derived features & constraints (OCL, Epsilon, IncQuery, Java) Generate tooling (Questionnaire.genmodel) Edit instance models (Form1.questionnaire) Validate instance models Metamodeling and Domain Specific Modeling

The EMF Toolkit Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

The EMF Toolkit Metamodel of the Domain / Modeling language Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

The EMF Toolkit Mapping of the Ecore model to the impl platform Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

The EMF Toolkit Code templates for generating implementation Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

The EMF Toolkit Code generation is carried out based upon the generator model code templates Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

The EMF Toolkit Core model manipulation and persistence impl. (Java library) Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

The EMF Toolkit Displaying EMF objects Command based model manipulation (with undo/redo support) Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

The EMF Toolkit Automatically generated tree view editor Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Creation of Ecore metamodels Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Creation of Ecore metamodels UML class diagram Rational Software Architect EclipseUML (Omondo) Borland Together Architect Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Creation of Ecore metamodels An XML schema is the metamodel of an XML document Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Creation of Ecore metamodels Simple programming language for defining Ecore models Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Creation of Ecore metamodels Direct Ecore defining Ecore tree editor Ecore Tools diagram Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Creation of Ecore metamodels Specially annotated Java interfaces, defines the metamodel Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

THE PETRI NET EXAMPLE Metamodeling and Domain Specific Modeling

Domain Metamodel: Petri Nets Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EMF model Ecore representation Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EMF model Ecore representation EPackage Path of containing resource Type of EReference EClass Inheritance Type of EAttribute Root element Méréstechnika és Információs Rendszerek Tanszék Reference to all model elements Metamodeling and Domain Specific Modeling

Class Definition in PetriNet.ecore <eclassifiers xsi:type="ecore:eclass" name="place" esupertypes="#//petrinet/pnelement"> <estructuralfeatures xsi:type="ecore:eattribute" name="token" lowerbound="1" etype="ecore:edatatype http://www.eclipse.org/emf/2002/ecore#//eint"/> <estructuralfeatures xsi:type="ecore:ereference" name="outgoingarcs" upperbound="-1" etype="#//petrinet/ptarc" containment="true" eopposite="#//petrinet/ptarc/fromplace"/> <estructuralfeatures xsi:type="ecore:ereference" name="incomingarcs" upperbound="-1" etype="#//petrinet/tparc" eopposite="#//petrinet/tparc/toplace"/> </eclassifiers> Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Class Definition in PetriNet.ecore <eclassifiers xsi:type="ecore:eclass" name="place" esupertypes="#//petrinet/pnelement"> Class <estructuralfeatures xsi:type="ecore:eattribute" name="token" lowerbound="1" etype="ecore:edatatype http://www.eclipse.org/emf/2002/ecore#//eint"/> Attribute <estructuralfeatures xsi:type="ecore:ereference" name="outgoingarcs" upperbound="-1" etype="#//petrinet/ptarc" containment="true" Reference eopposite="#//petrinet/ptarc/fromplace"/> Multiplicity Containment <estructuralfeatures xsi:type="ecore:ereference" name="incomingarcs" upperbound="-1" etype="#//petrinet/tparc" eopposite="#//petrinet/tparc/toplace"/> </eclassifiers> Type Opposite End Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

CODE GENERATION FROM ECORE Metamodeling and Domain Specific Modeling

Goal: Generator model (.genmodel) o Specify the attributes of the code generation EMF model o Tree Editor o Refers to the Ecore model Code generation attributes o Java version (e.g., use Enums in case of Java 5 and higher) o Package/project names o Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Code Generation from Ecore (.genmodel) Ecore model remains pure and independent Customizable (wrappers, code formatters, etc.) Generated plugins: o Model persistency (EMF.model) o Model management (EMF.edit) o Model editor (EMF.editor) Has some limitations o What happens when the underlying.ecore changes? Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Generator model Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Generator model referred Ecore elements General parameters Edit specific attributes Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling Editor specific attributes

Generated EMF components 3. Tree Editor 2. Model Manipulation 1. Model Persistency Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Generated EMF components Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EMF.model Optimized persistency handling Fully featured Java code of the Ecore model Specific factories for all packages Notification mechanism (observer pattern) Possible extension points: o Advanced editor o Own file format with parser Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EClass implementation <interface> Notifier BasicNotifierImpl Notification/Observer Layer <interface> EObject <interface> Place BasicEObjectImpl EObjectImpl PlaceImpl Common Implementation Layer Generalize the already defined framework element Business Layer Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Auto-Generated Interface ESuperClass EMF specific annotations Getters/Setters for attributes No setter when multiplicity > 1 (use add/remove instead) EList: EMF list interface (~10 implementations Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EObject API <interface> Place getincomingarcs(): Elist getoutgoingarcs(): Elist gettoken(): int settoken(value:int) PlaceImpl getincomingarcs(): Elist getoutgoingarcs(): Elist gettoken(): int settoken(value:int) Every class contains framework-specific methods: o Reflective get/set (eget, eset) o Consistent manipulation (einverseremove) o Notifications for feature changes (very useful e.g. in GUI!) Inherited from common supertype EObject o see deep instantiation earlier Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EOperation Implementation Represents the frame of a Java method Present in both the interface and implementing class Important: o Have to change the generated annotation to NOT so that next code generation phase does not overwrite it o Have to implement the method manually Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Client Programming with EMF Place p1 = PetrinetFactory.eINSTANCE.createPlace(); p1.setname("p1"); Place p2 = PetrinetFactory.eINSTANCE.createPlace(); p2.setname("p2"); Transition t1 = PetrinetFactory.eINSTANCE.createTransition(); t1.setname("t1"); // Inverse direction (p1.outgoingarcs) is set automatically PTArc a0 = PetrinetFactory.eINSTANCE.createPTArc(); a0.setfromplace(p1); a0.settotransition(t1); TPArc a1 = PetrinetFactory.eINSTANCE.createTPArc(); a1.settoplace(p2); a1.setfromtransition(t1); Set target of PT arc Create a place Create a transition Create a PT arc Set source of PT arc Advanced client programming: Reflective Ecore API Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

The org.eclipse.emf.ecore.util Package Contains utility classes and interfaces: o ECoreEContentAdapter: maintains itself as a notification adapter for a whole containment (sub)tree o UsageCrossReferencer: finds each ModelElement pointing to the corresponding EObject o ContentTreeIterator: An iterator over the tree contents of a collection of EObjects o Copier: deep copy of EObject Elements and EReferences o Etc. (This is not generated but a generic component) Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Generated EMF components Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EMF.Edit Separates the GUI and the model Generator pattern: o Provider class for each model element o Base class: ItemProvider o Forward EMF model change notifications to the viewer Provides: o Element text o Icon o Description of features in EClass Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EMF.Edit Handles EMF.model notifications Model manipulation commands (base + own) Converts model notifications to GUI notifications Model manipulation through commands o Possible alternative to direct setters o Undoable, redoable o ItemProvider.createAddCommand( ) etc. Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Generated EMF components Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

EMF.Editor EMF.Editor generates the SWT/JFace for the graphical editor Generates: o Tree editor o Wizards o Menus o plugins Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

The editor of Petri Net models <?xml version="1.0" encoding="utf-8"?> <PetriNets.petrinet:PetriNet xmi:version="2.0" xmlns:xmi="http://www.omg.org/xmi" xmlns:petrinets.petrinet= "http:///petrinets/petrinet.ecore"> <transitions name="t1" incomingarcs= "//@places.0/@outgoingarcs.0"> <outgoingarcs weight="2" toplace="//@places.1"/> </transitions> <places name="p1" token="1"> <outgoingarcs weight="1" totransition="//@transitions.0"/> </places> <places name="p2" incomingarcs= "//@transitions.0/@outgoingarcs.0"/> </PetriNets.petrinet:PetriNet> Tree View Place p1 XMI 2.0 View Reference: URI (or XMI.id) Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

TOOLS, API AND UTILITIES Metamodeling and Domain Specific Modeling

Basic EMF tools Validation o Validate constraints over EMF models Query o High-level query language for EMF o See also: EMF-IncQuery Compare o To structurally compare EMF models (e.g., versioning) Teneo o Persistency layer over relation databases SDO o Service Oriented Architecture based on EMF CDO o distributed, client-server EMF models Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

Ecore Tools: Ecore Diagram Editor Graphical DSL to define EMF metamodels o Based on GMF Metamodeling and Domain Specific Modeling

Textual DSL for defining metamodel + textual syntax Context-free grammar! Generates: o Metamodel o Parser o Editor features Xtext Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling

GMF Méréstechnika és Információs Rendszerek Tanszék Metamodeling and Domain Specific Modeling