310 likes | 426 Views
Breathe life into your metamodels Weaving behavior into Metamodels with Kermeta Didier Vojtisek Triskell Project-Team http://www.irisa.fr/triskell. Outline. Rationale What is Kermeta? Kermeta In Action What For? (task oriented view) How To? (metamodel oriented view) Conclusion.
E N D
Breathe life into your metamodels Weaving behavior into Metamodels with Kermeta Didier Vojtisek Triskell Project-Team http://www.irisa.fr/triskell
Outline Rationale What is Kermeta? Kermeta In Action What For? (task oriented view) How To? (metamodel oriented view) Conclusion
Rationale • Metamodel technology is well adapted to build tool and to capture DS(M)L concepts (ie. Its abtstract syntax) • Model, meta-model, meta-metamodel, DSLs, … • Meta-bla-bla too complex for the normal engineer • Designing DSML and associated tool chain is usually done by software engineer • On the other hand, engineers are familiars with • OO programming languages (Java,C#,C++,..) • UML (at least class diagram) • May have heard of Design-by-Contract • Kermeta leverages this familiarity to make Meta-modeling easy for the masses Kermeta Rationale
Breathing life into Meta-Models // MyKermetaProgram.kmt // An E-MOF metamodel is an OO program that does nothing require "StateMachine.ecore"// to import it in Kermeta // Kermeta lets you weave inaspects // Contracts (OCL WFR) require “StaticSemantics.ocl” // Method bodies (Dynamic semantics) require “DynamicSemantics.kmt” // Transformations Kermeta Rationale Context FSM inv: ownedState->forAll(s1,s2| s1.name=s2.name implies s1=s2) aspect class FSM { operation reset() : Void { currentState := initialState }} class Minimizer { operation minimize (source: FSM):FSM {…} }
Outline Rationale What is Kermeta? Kermeta In Action What For? (task oriented view) How To? (metamodel oriented view) Conclusion
Kermeta, a Kernel to Meta Kermeta Actions Constraints Transformations Metadata What is Kermeta?
Kermeta:a Kernel metamodeling language • Strict EMOF extension • Statically Typed • Generics, Function types (for OCL-like iterators) • Object-Oriented • Multiple inheritance / dynamic binding / reflection • Model-Oriented • Model are first class citizens, notion of model type • Design by contract • Aspect-Oriented • Simple syntax for static introduction • Arbitrary complex aspect weaving as a framework • Still “kernel” language • Seamless import of Java classes in Kermeta for GUI/IO etc. What is Kermeta?
Operational semantic • Operational semantic of MM is expressed into Kermeta which in turn is formalized into F. Fleurey's Phd Thesis • For example : OCL behavior is translated in Kermeta before evaluation • This operational semantics acts as a reference implementation What is Kermeta?
Outline Rationale What is Kermeta? Kermeta In Action What For? (task oriented view) How To? (metamodel oriented view) Conclusion
Example class State{ reference owningFSM : FSM[1..1]#ownedState attribute name : String attribute outgoingTransition : Transition[0..*]#source reference incomingTransition : Transition#target operation step(c : String) : kermeta::standard::~Void isdo end } class Transition{ reference source : State[1..1]#outgoingTransition reference target : State[1..1]#incomingTransition attribute input : String attribute output : String operation fire() : String isdo end } class FSM { attribute ownedState : State[0..*]#owningFSM reference initialState : State[1..1] reference currentState : State operation run() : kermeta::standard::~Void isdo end operation reset() : kermeta::standard::~Void isdo end } Kermeta in action : FSM example
Example Kermeta in action : FSM example operation fire() : String source.owningFSM.currentState := target result := output
operation step(c : String) : String // Get the valid transitions var validTransitions : Collection<Transition> validTransitions := outgoingTransition.select { t | t.input.equals(c) } // Check if there is one and only one valid transition if validTransitions.empty thenraise NoTransition.new end if validTransitions.size > 1 then raise NonDeterminism.new end // fire the transition result := validTransitions.one.fire Kermeta in action : FSM example
operation run() : Void fromvar str : String until str == "exit" loop stdio.writeln("current state is " + currentState.name) str := stdio.read("Enter an input string or 'exit' to exit simulation : ") stdio.writeln(str) if str != "exit"then do stdio.writeln("Output string : " + currentState.step(str)) rescue (ex : FSMException) stdio.writeln("ERROR : " + ex.toString) end end end stdio.writeln("* END OF SIMULATION *") Kermeta in action : FSM example
Kermeta in action : FSM example /** * Load a sample FSM from a xmi2 file */ operation loadFSM() : FSM isdo var repository : EMFRepository init EMFRepository.new var resource : EMFResource resource ?= repository.createResource("../models/fsm_sample1.xmi", "../metamodels/fsm.ecore") resource.load // Load the fsm (we get the main instance) result ?= resource.instances.one end
Improve MM design using Kermeta weaving • For example to separate abstract syntax from semantic domain require "FSM.ecore" aspect class FSM { reference currentState : State operation run() : Void is do … end operation reset() : Void is do … end } … Kermeta in action : FSM example
Kermeta workbench • Metamodel engineering environment • Editors (textual and graphical) (syntax highlighting, autocompletion, …) • Interpreter, (compiler is under development) • Workflow manager (user customizable transformation automation) • Various views • Compatibility with existing MM developed in Eclipse EMF • Connexion to team and third-party tools to build DSL/DSML • Concrete syntax examples : GMF/Topcased, Sintaks, … Kermeta in action
Kermeta workbench snapshot Kermeta in action
Outline Rationale What is Kermeta Kermeta in Action What For? (task oriented view) How To? (metamodel oriented view) Conclusion
Kermeta: What For? • Prototype operational semantics of MM • Get an instant interpreter for it • Generative environment for DSMLs • Complemented with Sintaks & TopcaseD editor generators • Static checking of models & transformations • Beyond WFR, model type conformance • Does T(MM1 m1) work for a model m2 conforming to MM2? • Alternative to QVT style Model Transformation • Model level aspect weaving • The AOSD-Europe Model Aspect Weaver What For?
Kermeta as a model transformation language • One of the possible use case of Kermeta • Should allow to express all kind of transformations • However, the language itself aims to stay minimal (a kernel for metamodeling) • Specific features (such as rules, …) can be implemented as a framework or within a MDK • With Kermeta the transformation is simply an object-oriented program that manipulates model elements What For?
B B C C A H MOF + actions == Transformation Metamodel == Kermeta metamodel D E :F :H :E :C :A F :C :C Transformation model Target model Transformation execution + eventual behavior if the source or target metamodels are expressed with Kermeta Transformations directly with Kermeta MOF MOF Source Metamodel Target Metamodel What For? Source model
Model level aspect weaving • At model level, Aspect Weaving boild down to: • Pattern matching (aka join point detection) • May be non trivial, with wildcards or semantic based • Model composition • Respecting WFRs • Kermeta approach • Arbitrary complex algorithms encapsulated into frameworks for model weaving • Simple syntax for simple cases • The implementation vector of AOSD-Europe approaches What For?
Using aspect weaving to build Kermeta What for ? Kermeta design See PA Muller et al. , « Weaving executability into meta-models » in Proc. MODELS 2005 for details
Outline Rationale What is Kermeta? Kermeta In Action What For? (task oriented view) How To? (metamodel oriented view) Conclusion
Kermeta Model Development Kits • How to organize tasks in a consistent fashion around metamodels? • MDK (Model Development Kit) = an OO/AO framework for a given Metamodel • Implementation of the operations of the metamodel • Constraints such as WFR • Library of useful transformations for this metamodel • Ex: interpreter and/or compiler in the case of a language, … • Provide support for concrete syntax • tree, graphical and textual editors using Kermeta generators (Sintaks) or thirdparty tools (from TopCaseD) How-to: MDK
Examples of MDKs • Production (operational use intended) • Ecore/Kermeta • Sintaks (concrete syntax <-> model) • RDL (Requirement Description Language) • UML2.1 • Profiles such as SysML, SPEEDS, MARTE • Java5 (complete metamodel based on Spoon) • And also Tracability, CWM, DocBook… • Research • Pattern matching, advanced model composition, model testing, … • Demos/Tutorials • FSM, Logo… How-to: MDK
Application example : Logo turtle robot Logo Semantic in Kermeta Semantic mapping Static constraints in OCL AS VM Transformation written in Kermeta Input scenario Embedded source code inside the robot Simulator in Kermeta Interaction between the current simulation (Kermeta) and the GUI (Java) Result of a real execution Result of a simulation interpreted with Kermeta
Used in RT projects • Artist2, the European network of excellence on real-time embedded systems • UsineLogicielle, a System@tic project where Kermeta based operational semantic is associated to functional requirement for test synthesis purposes. • Speeds, a European FP6 project for aspect-oriented metamodeling of avionics and automotive systems, including operational semantics aspects • OpenEmbedd, A French project building a MDE platform for realtime system. • Mopcom, a French project applying MDE to hardware for generating SOC and introduce dynamic reconfigurability to them. • Topcased, a consortium that aims to build modelers for avionics and system engineering How-to?
Outline Rationale What is Kermeta? Kermeta In Action What For? (task oriented view) How To? (metamodel oriented view) Conclusion
Conclusion • Kermeta is for the normal Software Engineer • Not just for PhDs • It’s just OO, plus a bit of Aspects and design by contract if needed • Lets you develop bunches of useful things around metamodels and encapsulate them into MDK • With static type checking through model types • Kermeta is a no risk approach • Your metamodels stay standard E-MOF MM • Can use whatever other tools are needed Conclusion
Smoothly interoperates • with Eclipse/EMF • Open Source, available on the INRIA Forge • Download it now! • Home page • http://www.kermeta.org • Development page • http://kermeta.gforge.inria.fr/ Conclusion Breathe life into your metamodels