modeling for fun and profit

66
Modeling for fun and profit © Anyware Technologies-All Right Reserved David Sciamma Eclipse Technical Manager Anyware Technologies May 25 th , 2009

Upload: david-sciamma

Post on 26-Jan-2015

123 views

Category:

Technology


8 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Modeling for Fun and Profit

Modeling for fun and profit

© Anyware Technologies-All Right Reserved

Modeling for fun and profit

David Sciamma

Eclipse Technical Manager

Anyware Technologies

May 25th, 2009

Page 2: Modeling for Fun and Profit

Anyware Technologies

Identity�Founded in 2000�Headquarters: Toulouse (France)�Regional subsidies: Paris (France),

Munich (Germany), RTP (US)�80 people including a team of 65

M2MSolutions� Central management of remote

equipment based on a generic, secure

and distributed Machine-to-Machine

services platform

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

�80 people including a team of 65 experts.

�Became Wavecom subsidiary in Q1 2008 and Sierra Wireless/Wavecom group Subsidiary in March 2009

�Website: www.anyware-tech.comOpen Source Solutions and Services

� Expertise, consulting and numerous

services around open source kernels

(Eclipse, Apache, …), web technologies

and IT integration.

Page 3: Modeling for Fun and Profit

Anyware Technologies OS3

Designer of Software Solutions

► Relevant and customized solutions − which optimizes the performance of business processes

− which benefits of the best of the technologies

− Which are built from open sources kernels and components

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

► Our specificity− An unique expertise around relevant technologies (Java, XML, XSL-T, Ajax,

JavaScript, JCR, RCP, CDO, EMF, GMF, GEF, ...)

− A company deeply involved in the most famous open source communities

− An industrial and agile approach to warranty costs, delays and quality.

► Keeping the experience brought by projects in order to develop products or new open source components

Page 4: Modeling for Fun and Profit

Modeling for fun and profit

Why ? How ?

© Anyware Technologies-All Right Reserved

Why ? How ?

Page 5: Modeling for Fun and Profit

• Small development team

• Fast prototyping

• Recurring kinds of application

Constraints

Issue© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

• Model Driven Approach

• Meta Modeling

• Generation and genericframework

Solution

Page 6: Modeling for Fun and Profit

•Create the same kind of application for differentdomains

•Ex: a graphical editor, a form

Need

Recurring kind of application© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

•Pragmatic Model Driven

•Progressive commoditization

•Progressive improvement of the generator

Solution

Page 7: Modeling for Fun and Profit

Definition of a generator

• Creation of the domain specific language (DSL)

►Ex: UML, Autosar, Petri Net… genealogy

• Definition of the target

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

►Ex: graphical editor framework, web framework

• Creation of a model describing this target

►Ex: graphical editor metamodel, CRUD application metamodel

• Creation of the generator

• Don’t try to generate everything !

Page 8: Modeling for Fun and Profit

Definition of a generator

Ecore

Generationmetamodel

DSL

Generationmodel

instantiate

instantiate

UML, Autosar, PetriNet…

Define the generation parameters

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Generationtemplates

Generationengine

Generatedapplication

Scripts: JET, xPand, Acceleo… implement the generation fromthe generation model

Execute the generation templates

Set of generated files: compose the targeted application

Page 9: Modeling for Fun and Profit

Creation of a generator

Generationmetamodel v1

Generator v1Generated

application v1

Generationmetamodel v2

Generator v2Generated

application v3

Improvements

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

metamodel v2Generator v2

application v3

Generationmetamodel vN

Generator vNGenerated application

vN

Improvements

Page 10: Modeling for Fun and Profit

Modeling for fun and profit

Examples

© Anyware Technologies-All Right Reserved

Examples

Page 11: Modeling for Fun and Profit

• Create a set of tools for a givenmodeling language• Ecore, UML, Autosar…

Need

Complete modeling environment© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

• Generate tools from the metamodel

• Allow to create homogeneous tools

• Speed up integration of a new language

Solution

Page 12: Modeling for Fun and Profit

Concrete implementations

• TOPCASED

►UML, AADL, SAM, SysML…

• Autosar

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

• CoFluent Studio

• Ecore Tools

Page 13: Modeling for Fun and Profit

TOPCASED

DSL

Tabbed Properties Diagram Model navigator Context menu

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 14: Modeling for Fun and Profit

Medany

• Mobile application

• Disconnected mode

• Synchronization with a server

• Administration

• …

Need

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

• Modeling environment to define yourmobile application

• Generation of applications using a common core

Solution

Page 15: Modeling for Fun and Profit

Medany© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 16: Modeling for Fun and Profit

Medany

Medany metamodel

Medany model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Android eRCP

RCP

Struts GWT

Web Admin SynchroMobile App Web App

OR OR

Page 17: Modeling for Fun and Profit

Concrete implementations

• VNF

• ONSil

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 18: Modeling for Fun and Profit

• Ease embedded development(Machine-to-Machine)

• Define a structure for embeddedapplications

• Accelerate creation fo M2M Solutions

Need

M2M Developer Suite© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

• Modeling environment

• Component-oriented approach

• Code generation

• Round tripping

Solution

Page 19: Modeling for Fun and Profit

Concrete implementations

• Home automation

• Fleet Tracking

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 20: Modeling for Fun and Profit

Modeling for fun and profit

Eclipse Modeling Project

© Anyware Technologies-All Right Reserved

Eclipse Modeling Project

Page 21: Modeling for Fun and Profit

Eclipse Modeling project

• Created in March 2006

• Provides a complete open source tool stack

• Leader: IBM

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

• Active members:►Anyware Technologies

► Itemis

►Obeo

►Borland

►Embarcadero Technologies

►Lots of individuals

►…

Page 22: Modeling for Fun and Profit

Modeling Projects

EMF

EMF

Model Validation

EMFT

Ecore Tools

EMF Compare

GMF M2M

ATL

ProceduralQVT

M2T

xPand

Acceleo

TMF

xText

MDT

UML

OCL

GMT

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Validation

Model Transaction

Model Query

CDO

Teneo

Compare

EMF Search

QVT

DeclarativeQVT

Acceleo

JET

OCL

Page 23: Modeling for Fun and Profit

Modeling Projects

EMF

EMF

Model Validation

EMFT

Ecore Tools

EMF Compare

GMF M2M

ATL

ProceduralQVT

M2T

xPand

Acceleo

TMF

xText

MDT

UML

OCL

GMT

Framework to use models

incubation

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Validation

Model Transaction

Model Query

CDO

Teneo

Compare

EMF Search

QVT

DeclarativeQVT

Acceleo

JET

OCL

Page 24: Modeling for Fun and Profit

Modeling Projects

EMF

EMF

Model Validation

EMFT

Ecore Tools

EMF Compare

GMF M2M

ATL

ProceduralQVT

M2T

xPand

Acceleo

TMF

xText

MDT

UML

OCL

GMT

Framework to create graphical editors

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Validation

Model Transaction

Model Query

CDO

Teneo

Compare

EMF Search

QVT

DeclarativeQVT

Acceleo

JET

OCL

Page 25: Modeling for Fun and Profit

Modeling Projects

EMF

EMF

Model Validation

EMFT

Ecore Tools

EMF Compare

GMF M2M

ATL

ProceduralQVT

M2T

xPand

Acceleo

TMF

xText

MDT

UML

OCL

GMT

Framework to create transformations between models

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Validation

Model Transaction

Model Query

CDO

Teneo

Compare

EMF Search

QVT

DeclarativeQVT

Acceleo

JET

OCL

Page 26: Modeling for Fun and Profit

Modeling Projects

EMF

EMF

Model Validation

EMFT

Ecore Tools

EMF Compare

GMF M2M

ATL

ProceduralQVT

M2T

xPand

Acceleo

TMF

xText

MDT

UML

OCL

GMT

Framework to generate text from models

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Validation

Model Transaction

Model Query

CDO

Teneo

Compare

EMF Search

QVT

DeclarativeQVT

Acceleo

JET

OCL

Page 27: Modeling for Fun and Profit

Modeling Projects

EMF

EMF

Model Validation

EMFT

Ecore Tools

EMF Compare

GMF M2M

ATL

ProceduralQVT

M2T

xPand

Acceleo

TMF

xText

MDT

UML

OCL

GMT

Framework to generate model from text

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Validation

Model Transaction

Model Query

CDO

Teneo

Compare

EMF Search

QVT

DeclarativeQVT

Acceleo

JET

OCL

Page 28: Modeling for Fun and Profit

Modeling Projects

EMF

EMF

Model Validation

EMFT

Ecore Tools

EMF Compare

GMF M2M

ATL

ProceduralQVT

M2T

xPand

Acceleo

TMF

xText

MDT

UML

OCL

GMT

Reference implementations of OMG standards

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Validation

Model Transaction

Model Query

CDO

Teneo

Compare

EMF Search

QVT

DeclarativeQVT

Acceleo

JET

OCL

Page 29: Modeling for Fun and Profit

Modeling Projects

EMF

EMF

Model Validation

EMFT

Ecore Tools

EMF Compare

GMF M2M

ATL

ProceduralQVT

M2T

xPand

Acceleo

TMF

xText

MDT

UML

OCL

GMT

Research projects

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Validation

Model Transaction

Model Query

CDO

Teneo

Compare

EMF Search

QVT

DeclarativeQVT

Acceleo

JET

OCL

Page 30: Modeling for Fun and Profit

Modeling Projects (Focus)

EMF

EMF

Model Validation

EMFT

Ecore Tools

EMF Compare

GMF M2M

ATL

ProceduralQVT

M2T

xPand

Acceleo

TMF

xText

MDT

UML

OCL

GMT

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Validation

Model Transaction

Model Query

CDO

Teneo

Compare

EMF Search

QVT

DeclarativeQVT

Acceleo

JET

OCL

Page 31: Modeling for Fun and Profit

Modeling for fun and profit

Eclipse Modeling Framework - EMF

© Anyware Technologies-All Right Reserved

Eclipse Modeling Framework - EMF

Page 32: Modeling for Fun and Profit

EMF

• Framework used to create tools based on a model

• Ecore is used to create meta models.

• Ecore provides :

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

►Simple and reverse references

►Composition

►Types

• Close to UML class diagram.

Page 33: Modeling for Fun and Profit

EMF

• EMF bounds the modeling and development worlds :

► It transforms models into java

►Allows to use the model in your application

►Gives tools to increase development productivity

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

►Gives tools to increase development productivity

• Open-source

• Strong and tested technology (used since 2002)

Page 34: Modeling for Fun and Profit

EMF Generation

Ecore Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

GenModel

Java ModelDisplay and edit basic functions

Model treeeditor

Tests code

Page 35: Modeling for Fun and Profit

Modeling for fun and profit

Graphical Modeling Framework - GMF

© Anyware Technologies-All Right Reserved

Graphical Modeling Framework - GMF

Page 36: Modeling for Fun and Profit

GMF

• Ease the development of graphical editor for models

• Runtime

►Framework with a lot of common features for graphical model

editors

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

editors

• Generator

►Tool to generate a graphical editor from a model and the editor

definition

Page 37: Modeling for Fun and Profit

GMF© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 38: Modeling for Fun and Profit

GMF© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 39: Modeling for Fun and Profit

Modeling for fun and profit

Model to Text - xPand

© Anyware Technologies-All Right Reserved

Model to Text - xPand

Page 40: Modeling for Fun and Profit

xPand

• Designed specifically for text generation

►OO template engine supporting template polymorphism

►Template Varibility using AOP

►Editor with Code Completion and Syntax

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

►Editor with Code Completion and Syntax

►Highlighting

• Debugger

Page 41: Modeling for Fun and Profit

xPand

• Example of template:

«IMPORT model»«DEFINE file FOR SourceComponentClass»«FILE project.name.toLowerCase() + "/" + name + ".java"-»package «project.name.toLowerCase()»;

public class «name» extends ComponentClass {

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

public class «name» extends ComponentClass {

«IF methods.select(m | m.kind.toString() == "EVENT").size > 0»public void receiveEvent(int inputEventMethod, Object value) {

«FOREACH methods.select(m | m.kind.toString() == "EVENT") AS m-»// TODO handle Event: " + «m.name.toUpperCase()»:

«ENDFOREACH-»}

«ENDIF»}«ENDFILE»«ENDDEFINE»

Page 42: Modeling for Fun and Profit

How to integrate all the components ?

The M2M Developer Suite Use case

© Anyware Technologies-All Right Reserved

The M2M Developer Suite Use case

Page 43: Modeling for Fun and Profit

Requirements

• Embedded development (Machine-to-Machine)

• Modeling environment

• Component-oriented approach

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Model Code Binary Target Execution Debug

What is Machine-to-Machine (M2M)

M2M refers to data communication between machines.

Page 44: Modeling for Fun and Profit

Requirements

• Users profiles

►Newbies

►Solution providers

• Multiple targets

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

• Multiple targets

►Wavecom devices

►Embedded Linux

►…

►Lego Mindstorms

Page 45: Modeling for Fun and Profit

Features

Validation

Editors

Navigator

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Target

Code

Editor

Navigator

Compilation

NavigatorCommunication

Page 46: Modeling for Fun and Profit

Features

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 47: Modeling for Fun and Profit

Modeling

• EMF - Eclipse Modeling Framework

►The model is the pillar of the tool

►Used to model what is an embedded project

►Benefits from EMF

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

►Benefits from EMF

− Notifications

− Serialization

− Reflective API

− … all the incredible EMF tools (GMF, Validation, xPand…)

Page 48: Modeling for Fun and Profit

Modeling

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 49: Modeling for Fun and Profit

Features

Navigator

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 50: Modeling for Fun and Profit

Navigator

• Objectives

►1:1 Mapping between Project and Model

►Display informations in the model as project’s artefacts

Navigator

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

• Workspace integration

►EMF Transaction

− Global model repository

− Transactional Editing Domain

Page 51: Modeling for Fun and Profit

Navigator

• Project Explorer

►Displays model objects as the Project structure

►Based on Common Navigator Framework

− Extensible tree view

Navigator

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

− Extensible tree view

− Rather complex API

− But really powerful

►We use an internal model to define the structure (nodes only

used to group or display informations)

Extension Points: org.eclipse.ui.navigator.*Excellent tutorial: Building a Common Navigator based viewer

Page 52: Modeling for Fun and Profit

Navigator

• Project Explorer

►Result

Navigator

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Model contribution

CDT contribution

Default display (resources)

Navigation nodes

EMF Objects

Page 53: Modeling for Fun and Profit

Features

Editors

Navigator

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 54: Modeling for Fun and Profit

Model edition

• Forms editors►Forms + EMF + databinding

− Create UI

Editors

Model

private void createContent(FormToolkit toolkit, Composite parent) {Composite composite = toolkit.createComposite(parent, SWT.NONE);GridDataFactory.fillDefaults().grab(true, false).applyTo(composite);GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

− Bind UI to model

GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);

toolkit.createLabel(composite, "Name:", SWT.NONE);_textName = toolkit.createText(composite, "", SWT.BORDER);GridDataFactory.fillDefaults().grab(true, false).applyTo(_textName);

}

private void bind() {DataBindingContext bindingContext = new EMFDataBindingContext();// -- Bind the NamebindingContext.bindValue(SWTObservables.observeText(_textName, SWT.FocusOut),

EMFEditObservables.observeDetailValue(Realm.getDefault(), getEditingDomain(),_myEObject, M2MPackage.eINSTANCE.getINamedElement_Name()), null, null);

}

Page 55: Modeling for Fun and Profit

Model edition

• Forms editors

►Result

Editors

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Available in PDE Incubator:Forms EMF editor will be used to implement new PDE editors

Page 56: Modeling for Fun and Profit

Model edition

• Graphical Editor: GMF

►Uses GMF generator to bootstrap

Editors

Model

ModelGenerated

GMF generation

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

►Heavy use of GMF Runtime

Generatededitor

Modifiededitor

Customization

Page 57: Modeling for Fun and Profit

Model edition

• Graphical Editor: GMF

►Result

Editors

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 58: Modeling for Fun and Profit

Features

Validation

Editors

Navigator

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Page 59: Modeling for Fun and Profit

Model validation

• EMF Validation

►Extensible (needed for specific-target constraints)

►Constraints are registered using an extension point

Validation

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

►We use only the batch mode

Extension points: org.eclipse.emf.validation.*

public IStatus validate (EObject model, IProgressMonitor monitor) {IBatchValidator batchValidator = ModelValidationService.getInstance()

.newValidator(EvaluationMode.BATCH);batchValidator.setIncludeLiveConstraints(true);batchValidator.setReportSuccesses(false);return batchValidator.validate(model, monitor);

}

Page 60: Modeling for Fun and Profit

Model validation

► Integrated in a builder

− Transparent and automatic (on save)

− Uses Problem Markers

− Coupled with quick fixes for a better user experience

Validation

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

− Coupled with quick fixes for a better user experience

Validation decorators are based on

markers generated by the Validation builder

Page 61: Modeling for Fun and Profit

Features

Validation

Editors

Navigator

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Code

Page 62: Modeling for Fun and Profit

Code generation

• xPand

►Example of template

Code

Model

«IMPORT model»«DEFINE file FOR SourceComponentClass»«FILE project.name.toLowerCase() + "/" + name + ".java"-»

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

«FILE project.name.toLowerCase() + "/" + name + ".java"-»package «project.name.toLowerCase()»;

public class «name» extends ComponentClass {

«IF methods.select(m | m.kind.toString() == "EVENT").size > 0»public void receiveEvent(int inputEventMethod, Object value) {

«FOREACH methods.select(m | m.kind.toString() == "EVENT") AS m-»// TODO handle Event: " + «m.name.toUpperCase()»:

«ENDFOREACH-»}

«ENDIF»}«ENDFILE»«ENDDEFINE»

Page 63: Modeling for Fun and Profit

Code generation

• xPand

►Call the xPand generator programmatically

Code

Model

public void generate(final EObject object, IProgressMonitor monitor) throws CoreException {Generator generator = new Generator();

// define the metamodel used in the template

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

// define the metamodel used in the templateMetaModel m2mMetamodel = new EmfMetaModel(M2MPackage.eINSTANCE);generator.addMetaModel(m2mMetamodel);// define the templategenerator.setExpand("templates::SourceComponentClass::file FOR component");// define the output folderOutlet outlet = new Outlet("C:/myOutput/src");generator.addOutlet(outlet);// configure protected regionsgenerator.setPrSrcPaths("C:/myOutput/src");generator.setPrDefaultExcludes(true);// define the EObject inputWorkflowContextDefaultImpl ctx = new WorkflowContextDefaultImpl();ctx.set("component", object);// run the generatorgenerator.invoke(ctx, new ProgressMonitorAdapter(monitor), new IssuesImpl());

}

Page 64: Modeling for Fun and Profit

Code generation

• Integrated in a builder

►Transparent and automatic (on save)

►Synchronization between model and code

► Incremental generation

Code

Model

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

► Incremental generation

Page 65: Modeling for Fun and Profit

Features

Validation

Editors

Navigator

Model

Project Explorer + CNF

Forms

GMFEMF Validation

© Anyware Technologies-All Right Reserved

Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies

Target

Code

Editor

Navigator

Compilation

NavigatorCommunication

xPand AST

CDT + DLTKCDT

TCF RSE

Page 66: Modeling for Fun and Profit

Questions?David Sciamma

[email protected]

© Anyware Technologies-All Right Reserved