modeling for fun and profit
DESCRIPTION
TRANSCRIPT
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
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.
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
• 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
•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
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 !
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
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
• 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
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
TOPCASED
DSL
Tabbed Properties Diagram Model navigator Context menu
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
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
Medany© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
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
Concrete implementations
• VNF
• ONSil
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
• 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
Concrete implementations
• Home automation
• Fleet Tracking
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
Modeling for fun and profit
Eclipse Modeling Project
© Anyware Technologies-All Right Reserved
Eclipse Modeling Project
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
►…
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
…
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
…
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
…
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
…
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
…
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
…
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
…
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
…
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
…
Modeling for fun and profit
Eclipse Modeling Framework - EMF
© Anyware Technologies-All Right Reserved
Eclipse Modeling Framework - EMF
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.
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)
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
Modeling for fun and profit
Graphical Modeling Framework - GMF
© Anyware Technologies-All Right Reserved
Graphical Modeling Framework - GMF
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
GMF© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
GMF© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
Modeling for fun and profit
Model to Text - xPand
© Anyware Technologies-All Right Reserved
Model to Text - xPand
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
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»
How to integrate all the components ?
The M2M Developer Suite Use case
© Anyware Technologies-All Right Reserved
The M2M Developer Suite Use case
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.
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
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
Features
Model
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
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…)
Modeling
Model
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
Features
Navigator
Model
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
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
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
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
Features
Editors
Navigator
Model
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
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);
}
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
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
Model edition
• Graphical Editor: GMF
►Result
Editors
Model
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
Features
Validation
Editors
Navigator
Model
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
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);
}
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
Features
Validation
Editors
Navigator
Model
© Anyware Technologies-All Right Reserved
Pragmatic MDA – May 25h, 2009 – David Sciamma – Anyware Technologies
Code
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»
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());
}
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
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