1 / 43

MDSD with Eclipse and oAW

Open Source Modeling. MDSD with Eclipse and oAW. Markus Voelter voelter@acm.org www.voelter.de. Bernd Kolb b.kolb@kolbware.de www.kolbware.de. Peter Friese peter.friese@itemis.de oaw.itemis.eu. Open Source MDSD. Overview. MDSD with Eclipse and oAW. Eclipse Modeling in a Nutshell.

amma
Download Presentation

MDSD with Eclipse and oAW

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Open Source Modeling MDSD withEclipseandoAW Markus Voeltervoelter@acm.org www.voelter.de Bernd Kolbb.kolb@kolbware.dewww.kolbware.de Peter Friese peter.friese@itemis.de oaw.itemis.eu

  2. Open Source MDSD Overview MDSD withEclipseandoAW

  3. Eclipse Modeling in a Nutshell • 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

  4. EMP Core: EMF • 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)

  5. EMP Concrete Syntax: GMF and TMF • 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.

  6. EMP Concrete Syntax: Model Development Tools • 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.

  7. EMP Concrete Syntax: Model Transformation Tools • 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

  8. openArchitectureWare:An integrated toolkit for MDSD • 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

  9. openArchitectureWare 5 • 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

  10. EMP GMT openArchitectureWare II:Overview on a Slide

  11. Open Source MDSD Abstract Syntax/ Metamodeling MDSD withEclipseandoAW

  12. Creating the metamodel • 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

  13. Creating the metamodel II • 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

  14. Open Source MDSD Concrete Syntax MDSD withEclipseandoAW

  15. Default EMF Editor • 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

  16. GMF – Graphical Editors • GMF – The Graphical Modeling Framework • Define customgraphical editorsfor your metamodel • Use the editor to“draw” instancesof the meta model

  17. GMF – Graphical Editors (II)

  18. TMF / Xtext • 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

  19. TMF / Xtext (II)

  20. TMF / Xtext (III)

  21. Defining The Grammar • 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 ;

  22. The derived EMF meta model • 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

  23. Open Source MDSD Validation MDSD withEclipseandoAW

  24. Validation • 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

  25. Constraint Checks • 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, …)

  26. Real Time Constraint Validation • 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.

  27. Sidebar: Xtend • 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)

  28. Open Source MDSD Code Generation MDSD withEclipseandoAW

  29. Xpand Template Language • oAW’sXpand 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)

  30. Xpand (II) • 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

  31. Xpand (III) • 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)

  32. Extensions • 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

  33. Sidebar: Xtend • 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)

  34. Aspect-Orientation (AOP) • 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

  35. Separate Generated and Non-Generated Code • 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.

  36. Separate Generatedand Non-Generated Code II • 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)

  37. Recipe Framework Recipes can be arranged hierarchically „Green“ ones can also be hidden This is a failed check Here you can see additional information about the selected recipe

  38. Recipe Framework (II) Adding the extends clause makes all of them green

  39. Open Source MDSD Model-2-Model MDSD withEclipseandoAW

  40. TransformationsandModifications

  41. Xtendfor M2M • 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, …

  42. M2M Example

  43. Open Source MDSD The End. Thanks. MDSD withEclipseandoAW

More Related