Upload
inigo
View
32
Download
0
Tags:
Embed Size (px)
DESCRIPTION
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. - PowerPoint PPT Presentation
Citation preview
Breathe life into your metamodels
Weaving behavior into Metamodels with Kermeta
Didier VojtisekTriskell Project-Team
http://www.irisa.fr/triskell
2
Outline
Rationale
What is Kermeta?
Kermeta In Action
What For? (task oriented view)
How To? (metamodel oriented view)
Conclusion
3
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
Ker
met
a R
atio
nale
4
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 in aspects// Contracts (OCL WFR)require “StaticSemantics.ocl”// Method bodies (Dynamic semantics)require “DynamicSemantics.kmt”// Transformations
run()
reset()
FSM
name: EString
step()
State input: EString
output: EString
fire()
Transition
initialState
1
owningFSM 1 ownedState*currentState
0..1
source
1
outgoingTransition
*target
1
incomingTransition
0..1
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 {…}}
Ker
met
a R
atio
nale
5
Outline
Rationale
What is Kermeta?
Kermeta In Action
What For? (task oriented view)
How To? (metamodel oriented view)
Conclusion
6
Kermeta, a Kernel to Meta
Actions
Transformations
Constraints
Metadata
Kermeta
Wha
t is
Ker
met
a?
7
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.
Wha
t is
Ker
met
a?
8
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
Wha
t is
Ker
met
a?
9
Outline
Rationale
What is Kermeta?
Kermeta In Action
What For? (task oriented view)
How To? (metamodel oriented view)
Conclusion
10
Example
run()
reset()
FSM
name: EString
step()
State input: EString
output: EString
fire()
Transition
initialState
1
owningFSM 1 ownedState*currentState
0..1
source
1
outgoingTransition
*target
1
incomingTransition
0..1
Ker
met
a in
act
ion
: FS
M e
xam
ple
class FSM{attribute ownedState : State[0..*]#owningFSMreference initialState : State[1..1]reference currentState : Stateoperation run() : kermeta::standard::~Void is doendoperation reset() : kermeta::standard::~Void is doend}
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 is do end}class Transition{ reference source : State[1..1]#outgoingTransition reference target : State[1..1]#incomingTransition attribute input : String attribute output : String operation fire() : String is do end}
11
Example
run()
reset()
FSM
name: EString
step()
State input: EString
output: EString
fire()
Transition
initialState
1
owningFSM 1 ownedState*currentState
0..1
source
1
outgoingTransition
*target
1
incomingTransition
0..1
operation fire() : String
source.owningFSM.currentState := target result := output
Ker
met
a in
act
ion
: FS
M e
xam
ple
12
run()
reset()
FSM
name: EString
step()
State input: EString
output: EString
fire()
Transition
initialState
1
owningFSM 1 ownedState*currentState
0..1
source
1
outgoingTransition
*target
1
incomingTransition
0..1
// 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 then raise NoTransition.new end if validTransitions.size > 1 then raise NonDeterminism.new end // fire the transition result := validTransitions.one.fire
operation step(c : String) : String
Ker
met
a in
act
ion
: FS
M e
xam
ple
13
run()
reset()
FSM
name: EString
step()
State input: EString
output: EString
fire()
Transition
initialState
1
owningFSM 1 ownedState*currentState
0..1
source
1
outgoingTransition
*target
1
incomingTransition
0..1
from var 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 *")
operation run() : Void
Ker
met
a in
act
ion
: FS
M e
xam
ple
14
S1 S3S2
a/b x/y
b/a
y/x
/** * Load a sample FSM from a xmi2 file */operation loadFSM() : FSM is do 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.oneend
Ker
met
a in
act
ion
: FS
M e
xam
ple
15
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
}
…
Ker
met
a in
act
ion
: FS
M e
xam
ple
16
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, …
Ker
met
a in
act
ion
17
Kermeta workbench snapshotK
erm
eta
in a
ctio
n
18
Outline
Rationale
What is Kermeta
Kermeta in Action
What For? (task oriented view)
How To? (metamodel oriented view)
Conclusion
19
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
Wha
t For
?
20
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
Wha
t For
?
21
Transformations directly with Kermeta
Source model
Source Metamodel Target MetamodelTransformation model
MOF + actions ==Transformation Metamodel ==Kermeta metamodel
Target modelTransformation execution
A
B C
:A :C
:C
:H :C
F
D E
H
B C
:F :E
MOF MOF
+ eventual behavior if the source or target
metamodels are expressed with Kermeta
Wha
t For
?
23
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
Wha
t For
?
24
Using aspect weaving to build Kermeta
ExecutableEMOF
M3
M2EMOF
ActionMeta-model
Composition
Primarymeta-model
Promotion
ActionMeta-model
Aspect meta-model
UML
EMOF
EMOF
ExecutableEMOF
ExecutableEMOF
M3
M2EMOF
ActionMeta-model
Composition
Primarymeta-model
Promotion
ActionMeta-model
Aspect meta-model
UML
EMOF
EMOF
ExecutableEMOF
Wha
t for
? K
erm
eta
desi
gn
See PA Muller et al. ,« Weaving executability into meta-models » in Proc. MODELS 2005 for details
See PA Muller et al. ,« Weaving executability into meta-models » in Proc. MODELS 2005 for details
25
Outline
Rationale
What is Kermeta?
Kermeta In Action
What For? (task oriented view)
How To? (metamodel oriented view)
Conclusion
26
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:
MD
K
27
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:
MD
K
28
Application example : Logo turtle robot
Static constraints in OCL
Simulator in Kermeta
Result of a simulation interpreted with Kermeta
Input scenario
Embedded source code inside the robot
Result of a real execution
Transformation written in Kermeta
Interaction between the current simulation (Kermeta) and the GUI (Java)
Logo Semantic in Kermeta
AS VMSemantic mapping
29
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?
30
Outline
Rationale
What is Kermeta?
Kermeta In Action
What For? (task oriented view)
How To? (metamodel oriented view)
Conclusion
31
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
Con
clus
ion
32
Smoothly interoperates Smoothly interoperates with Eclipse/EMFwith Eclipse/EMF
Open Source, available Open Source, available on the INRIA Forgeon the INRIA Forge►Download it Download it now!now! Breathe life into your metamodels
Con
clus
ion
● Home page– http://www.kermeta.org
● Development page – http://kermeta.gforge.inria.fr/