MDSD with Eclipse and oAW

43
Open Source Modeling Open Source Modeling Bernd Kolb [email protected] e www.kolbware.de Markus Voelter [email protected] g www.voelter.de Peter Friese peter.friese@ite mis.de oaw.itemis.eu

description

Open Source Modeling. MDSD with Eclipse and oAW. Markus Voelter [email protected] www.voelter.de. Bernd Kolb [email protected] www.kolbware.de. Peter Friese [email protected] oaw.itemis.eu. Open Source MDSD. Overview. MDSD with Eclipse and oAW. Eclipse Modeling in a Nutshell. - PowerPoint PPT Presentation

Transcript of MDSD with Eclipse and oAW

Page 1: MDSD  with Eclipse and oAW

Open Source ModelingOpen Source Modeling

Bernd [email protected]

Markus [email protected]

Peter Friese [email protected] oaw.itemis.eu

Page 2: MDSD  with Eclipse and oAW

Open Source MDSDOpen Source MDSD

Page 3: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Eclipse Modeling is the umbrella project for all things modeling that happen on the Eclipse platform:

The Eclipse Modeling Project focuses on the evolution and promotion of model-based development technologies within the Eclipse community by providing a unified set of modeling frameworks, tooling, and standards implementations.

Eclipse Modeling is not formally related to OMG, but implements several of their standards.

It is fair to say that many leading edge modeling tools are hosted/developed at Eclipse Modeling.

Everything Open Source under the Eclipse Public License

Page 4: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

The Eclipse Modeling Framework (EMF) serves as the foundation: It provides the Ecore Metametamodel and frameworks and tools around it for tasks such as Editing Transactions Validation Query Distribution/Persistence (CDO, Net4j, Teneo)

Page 5: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

The Graphical Modeling Framework (GMF) is used for building custom graphical editors based on meta models defined via EMF. It is currently in version 2.x Proven technology, used in many industrial-strength

systems Based on Eclipse GEF

The Textual Modeling Framework is used for building custom textual editors. Project is currently being set up Will be populated initially from oAW Xtext and INRIA

TCS.

Page 6: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

UML 2.x: An implementation of the UML 2 meta model based on EMF UML 2 Tools: GMF editors for the UML 2 models

OCL: APIs for OCL expression syntax for implementing queries and contraints.

XSD Infoset: reference library that provides an API for use with any code that examines, creates or modifies W3C XML Schema.

Page 7: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

M2M (Model-to-Model) : delivers an extensible framework for model-to-model transformation languages. ATL: M2M language from INRIA QVT implementations

M2T (Model-to-Text) : focuses on technologies for transforming models into text (code generation) JET : provides code generation framework & facilities

that are used by EMF. Xpand: oAW’s code generation engine, to be part of

M2T in the Ganymede release

Page 8: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

An integrated, tested, one-stop toolkit for MDSD

Version 4.3 is current (4.3.1 being built)

Proven track record in various domains & project contexts

Stable, productive and helpful developer, support and user communities

www.openarchitectureware.org and eclipse.org/gmt/oaw

Integration with Eclipse: Uses EMF as a basis Graphical editors based on GMF All editors and tooling based on Eclipse

Page 9: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Version 5 currently under development:

Migration of oAW Components to Eclipse Modeling proper: Xpand, Xtend, Check Model-to-Text (M2T) Xtext Textual Modeling Framework (TMF) Workflow Modeling Workflow Engine (MWE)

More features New backend: a VM for M2T (and maybe more languages) Mixing Languages: Xpand, Xtend, Check in one file Xtext: Grammar Fragments and the stuff from the 4.3 beta Generic Tree/Form Editor, mixing editors Wizard Framework

Page 10: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Page 11: MDSD  with Eclipse and oAW

Open Source MDSDOpen Source MDSD

Page 12: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

EMF EMOF implementation Roughly similar to the capabilities of UML Class Diagram No bidirectional associations, only unidir. references

UML2▪ Reference implementation of the OMG’s UML2 spec▪ UML2 Class Models can be transformed into an EMF meta

model

Default EMF tree editor

GMF Ecore demo editor / Ecore Tools

Xtext Grammar

Page 13: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

One approach is to use a UML tool (one which supports Eclipse UML2 export) and transform the model into an Ecore meta model.

An alternative is to use a suitable textual notation(make sure you can distribute the model over several files…!)

oAW uml2ecore

• Ecore File

• Name Management (qualified, namespaces)

• Various constraints

Page 14: MDSD  with Eclipse and oAW

Open Source MDSDOpen Source MDSD

Page 15: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

EMF’s default reflective editor can be used out of the box to create instances of any meta model Generic, But not very usable or scalable

Page 16: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

GMF – The Graphical Modeling Framework

Define customgraphical editorsfor your metamodel

Use the editor to“draw” instancesof the meta model

Page 17: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Page 18: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Xtext makes this much more feasible.

Based on an EBNF grammar it generates ANTLR3-based parser EMF-based metamodel Eclipse editor with

▪ syntax highlighting▪ code completion▪ customizable outline▪ code folding▪ real-time constraint checking

Xtext is part of openArchitectureWare / Eclipse Modeling

Page 19: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Page 20: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Page 21: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Grammar is definedin an EBNF-like formatin the Xtext editor.

The editor providescode completion andconstraint checkingfor the grammarsthemselves

Grammar is a collectionof Rules. Rules start with their name followed by: and ending with ;

Page 22: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

The Xtext generator builds an EMF meta model from the grammar.

The generated parser then instantiates the meta model from a model.

Processing Xtext models is based on this meta model: all existing EMF tooling is suitable for processing. We’ll show a code gen

template later

Page 23: MDSD  with Eclipse and oAW

Open Source MDSDOpen Source MDSD

Page 24: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Validation is very important! Constrain the models over what Ecore can express

directly Fail early in the development process – more semantics! Report errors and warnings to the user Only run transformations and generators on a valid model

OCL Implementation for OMG’s spec No nice editor yet

Check Part of M2T’s Xpand OCL like with some useful extensions

Page 25: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Uses the oAW Check language, based on Xtend Used to validate the static semantics of the models

Report Warnings and Errors Based completely on the generated meta model,

no concrete syntax hassles Tool support (syntax highlighting, code completion, …)

Page 26: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

The constraints defined for the language are evaluated in the editoron the fly. Xtext/TMF GMF

Constraints can also be checked as part of a work-flow that processes the models.

Page 27: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

OCL-like expression language used throughout oAW Can be used in constraint checks, model transformations and

generators Add “methods” to meta types (Java calls are possible if

necessary) path expressions, set operations, (some) higher order

functions Polymorphism (multiple dispatch) Tool support

(syntax highlighting, code completion, debugger)

Page 28: MDSD  with Eclipse and oAW

Open Source MDSDOpen Source MDSD

Page 29: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

oAW’s Xpand template language is a powerful and well established code generation facility with nice tooling.

You can easily traverse the model/meta model using the Xtend language (à la OCL)

Page 30: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Designed specifically for code (actually, text) generation

OO template engine supporting template polymorphism

French quotation marks as escape characters

Embedded Expressions based on Xtend (OCL-like)

Support for Recursion

Support for Template Varibility using AOP

Metamodel-aware Editor with Code Completion and Syntax Highlighting

Debugger

Page 31: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Import: make meta models visible to template file Define: define a new template File: open a file into which output is written Expand: Call another template for one or several

elements Foreach: iterate over coll., generate code for each

element If: conditional template code Extension: import an extension file for use in the

templates Error: report an error Let: define a temporary variable Proteced regions: well, you should not use this… Rem: define comments Around: advice other templates (AO)

Page 32: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

It is good practice to keep a generator simple Complex (and/or reused) expression should not be put

into templates

Xpand can delegate these parts to another language Xtend is used for this purpose You have to import the extension files you’d like to use

oAW comes with a set of utility extensions. They can be found in the stdlib

Page 33: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

OCL-like expression language used throughout oAW Can be used in constraint checks, model transformations and

generators Add “methods” to meta types (Java calls are possible if

necessary) path expressions, set operations, (some) higher order

functions Polymorphism (multiple dispatch) Tool support

(syntax highlighting, code completion, debugger)

Page 34: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

AOP is an important mechanism to adapt existing transformations and

generators by “advising” before/after/around existing templates non-invasively

Define variants of generators in the context of PLE.

Aspects can be added to Xtend functions and Xpand templates

Page 35: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Keep generated and non-generated code in separate files.

Never modify generated code. Design an architecture that clearly defines which

artifacts are generated, and which are not. Use suitable design approaches to “join”

generated and non-generated code. Interfaces as well as design patterns such as factory, strategy, bridge, or template method are good starting points.

Connected by Patterns, etc.

GeneratorApplication

ModelGenerated

Source

ManuallyWrittenSource

Compiler/Build Tool

CompleteSystem

Page 36: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

A) Generated code can call non-generated code contained in libraries

B) A non-generated framework can call generated parts.

C) Factories can be used to „plug-in“ the generated building blocks

D) Generated classes can also subclass non-generated classes.

E) The base class can also contain abstract methods that it calls, they are implemented by the generated subclasses (template method pattern)

a)

b)

c) d) e)

generated code non-generated code

Page 37: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Recipes can be arranged hierarchically

This is a failed check

„Green“ ones can also be hidden Here you can see

additional information about the selected recipe

Page 38: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Adding the extends clause makes all of them green

Page 39: MDSD  with Eclipse and oAW

Open Source MDSDOpen Source MDSD

Page 40: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Model M Model M

ModelModfication

Model M Model K

ModelTransformation

Model M

Page 41: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Xtend has some special support for M2M transformations Create-Extensions are used to create a new instance

▪ A new element is created only once for the same set of parameters

Cached Extension can be used for perfomence improvements▪ The same value is returned each time the extension is

called with the same set of parameters

Several utility extensions for naming, tracing, debugging, cloning, …

Page 42: MDSD  with Eclipse and oAW

© Bernd Kolb, Markus Voelter, Peter Friese 2008

Page 43: MDSD  with Eclipse and oAW

Open Source MDSDOpen Source MDSD