model driven code development using emf and jet

30
© 2012 IBM Corporation Michail Matjuchin IBM Software Group, Rational Austria Model-Driven Code Development using EMF and JET IBM Software Group /

Upload: kowost

Post on 21-Nov-2014

878 views

Category:

Documents


1 download

DESCRIPTION

Vortrag von Michal Matjuchin beim Eclipse DemoCamp November 2012/Vienna

TRANSCRIPT

Page 1: Model driven code development using emf and jet

© 2012 IBM Corporation

Michail Matjuchin

IBM Software Group, Rational

Austria

Model-Driven Code Development using EMF and JET

IBM Software Group /

Page 2: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation 2

Page 3: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

A little bit about JET History

3

Page 4: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation 4

Agenda

Short JET Overview

JET Demo

How IBM extends EMF with UML Front-End

Standard Transformation in Rational Software Architect (RSA)

How to use JET in order to extend standard RSA behavior

Page 5: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

What you will see in the Demo

5

Simplest Way to use JET from Java Code

Develop and Run JET Transformation (using Authoring Tool in RSA)

Create UML Model as Front-End for EMF Model

Create UML-to-EMF Transformation

Page 6: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

JET Installation on Eclipse

6

Page 7: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

How Does JET work ?

7

Originally built from the source code of Tomcat’s JSP compiler

JET works similar to JSP – Templates are to JET what JSP’s are to J2EE

– Generators are to JET what JSP-generated Servlets are to J2EE

– Generated source code is to JET what HTML output is to J2EE

Page 8: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Simplest Way to use JET

8

Page 9: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

JET Installation on Eclipse

9

Page 10: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

JET Installation on Eclipse

10

Page 11: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

What are JET, JET2, EMFT JET, …

11

JET 1 = Java Emitter Templates. – Started out as separate component of the Eclipse Modeling Project

(EMF) - 2004

JET 2 – An initiative to unify Design Pattern Toolkit (DPTK) and the JET

component of EMF

– Lives in EMF Technology (EMFT) project, hence the name EMFT JET

– JET 2 = EMFT JET

Page 12: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Simplest Way to use JET

12

Page 13: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Simplest Way to use JET

13

Out-of-the-Box Loaders:

EMF based: org.eclipse.jet.emf

XML: org.eclipse.jet.emfxml

Page 14: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Simplest Way to use JET

14

Page 15: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

You need a little bit more in “real life”

15

Page 16: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

JET Authoring Theory

16

Normal

development Pattern Recognized

Build a Reference Solution Build a JET Transformation

Page 17: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

JET Transformation using Authoring Tool in RSA

17

Page 18: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Model-to-Text Transformation / Steps

18

„Backward“ move from the

Reference Solution to a JET

Transformation that can

produce it

Reference

Solution

Actions and

Templates

Generated

Solution Input Model

Page 19: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Important Caveats

19

JET does not help you recognize a pattern. Possible clues you have: – “I keep doing the same thing over and over again.”

– You find yourself copying code.

JET does not help you build a reference solution. This is the job of

the ADC tooling. A good reference solution: – Reflects domain knowledge.

– Employs best practices.

– Identifies and (as much as possible) separates areas where the solution

is incomplete (and would require user customization).

– Works

Page 20: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Steps to a complete solution

20

Reference

Solution

JET Transformation Input

Model

User

Model Front-end

1. Jet Authoring

2. Model-to-model authoring

Page 21: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Model-to-Text Transformation / Steps

21

Create a Reference Solution (Exemplar)

Identify Patterns in your Reference Implementation

Use JET Tooling to produce „Code Generator“ – Create EMF Model of your Reference Solution

– Create JET Templates

If graphic front-end is needed

Identify the graphical model (UML + Profiles) or UML-based DSL

Build a Model-to-Model Transformation using Mapping Editor

Invoke JET Transformation

Page 22: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

“Out-of-the-Box” JET Functionality

22

Page 23: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

JET & UML

23

Page 24: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

What about Code-Merge

24

Page 25: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

What about Code-Merge

25

Page 26: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation 26

Page 27: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Transformations in MDD

27

Source Model (UML)

Target Source Code

Transformations

JET & UML API

Intermediate

ECORE Model

Model-to-Model

Transformations

Mapping Editor

JET

Transformations

Page 28: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

Standard Transformations provided by RSA

28

UML-to-EJB 3

UML-to-JPA (Java Persistence API)

UML-to-WSDL (Web Services)

UML-to-SCA (Service Component Arcitecture)

UML-to-SOA (WSDL, XSD, BPEL)

UML-to-XSD (XML Schema Definition)

UML-to-REST (JSON)

C#, C++ und VB

Page 29: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation

RSA provides “Transformation Authoring Framework” to change/modify existing Transformations

29

Model-to-Text Transformations

Model-to-Model Transformations

Transformations – Extensions

Page 30: Model driven code development using emf and jet

© 2010 IBM Corporation

IBM Software Group /

Michail Matjuchin © 2012 IBM Corporation 30