ibm software group © 2005 ibm corporation university of nantes eclipse daymarch 2005 the eclipse...

21
IBM Software Group University of Nantes Eclipse day March 2005 © 2005 IBM Corporation The Eclipse Modeling Framework and the IBM Model Transformation Framework Catherine Griffin IBM Hursley

Upload: homer-pierce

Post on 22-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

University of Nantes Eclipse day March 2005 © 2005 IBM Corporation

The Eclipse Modeling Framework and the IBM Model Transformation Framework

Catherine GriffinIBM Hursley

Page 2: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation2 University of Nantes Eclipse day March 2005

Agenda

Eclipse Modeling Framework

IBM Model Transformation Framework

Demo

Page 3: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

University of Nantes Eclipse day March 2005 © 2005 IBM Corporation

Eclipse Modeling Framework

Page 4: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation4 University of Nantes Eclipse day March 2005

What is the Eclipse Modeling Framework ?

Framework for implementing structured data models

Data:XML

Java objectJava object

Java objectJava object

XML

XMI

Meta-data:

deserialize

serialize

Meta-classXSD

XMI

(Model)

(Meta-model)

Page 5: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation5 University of Nantes Eclipse day March 2005

Models and meta-models

From a definition of the meta-model, EMF generates Java classes

Generated Java classes extend the EMF class EObject

They maintain model consistency:

– Two-way references

– Containment

– Type-checking

They have access to a representation of their

meta-model

Page 6: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation6 University of Nantes Eclipse day March 2005

Ecore

A meta-model is a model; and its meta-model is supplied by EMF and is called Ecore

So a meta-model is an Ecore model

Ecore has concepts like:

– Class – inheritance, have properties

– Property – name, multiplicity, type

Essentially this is a simplified version of class modeling in UML

Page 7: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation7 University of Nantes Eclipse day March 2005

Creating an Ecore model

Various methods of creating an Ecore model are supported:

– Rational Rose models

– Java interfaces with added annotations

– XML Schema

– EMF Java APIs (write a program)

– Eclipse.org UML2 models, IBM Rational Software Modeler

– Other tools – e.g.Omondo (Eclipse UML editor)

Page 8: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation8 University of Nantes Eclipse day March 2005

Code generation Ecore model

(meta-model)

Model implementation

classes Simple Eclipse

editor

Page 9: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation9 University of Nantes Eclipse day March 2005

Customizing generated code

You can edit the generated code, and your changes will be maintained when the code is re-generated

You need to edit the generated code in order to implement any operations defined in your meta-model, or properties that are derived from other properties

You can also use different templates for code generation

– You might want to do this to change the standard file header, or conform to your preferred naming conventions

Page 10: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation10 University of Nantes Eclipse day March 2005

Loading and Saving EMF Models

EMF has built in support for serializing models as XML – either XMI or as defined by an XML schema

XMI is the OMG standard for representing models (and meta-models) in XML

If you need to, you can write your own custom serialization/deserialization code and have whatever data format you like

EMF can manage references within and between files

Page 11: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation11 University of Nantes Eclipse day March 2005

More features..

Reflection APIs

Model change notification support

Reusable parts for building Eclipse tools

Change model - supports recording, applying and undoing changes

Mapping model and support for building mapping tools

SDO implementation (JSR 235)

Page 12: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation12 University of Nantes Eclipse day March 2005

Who is using EMF today?

IBM Rational Software Architect, IBM Rational Application Developer for WebSphere, etc

Eclipse projects

– Hyades Project (testing and logging)

– XSD Project (manipulate XML Schemas)

– UML2 (UML 2.0)

Others

– TogetherSoft (UML editor and code generation)

– Ensemble (support for Weblogic servers)

– Versata (extend J2EE to capture their business rules)

– Omondo (UML editor tightly coupled to EMF tools) More coming aboard

Page 13: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

University of Nantes Eclipse day March 2005 © 2005 IBM Corporation

IBM Model Transformation Framework

Page 14: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation14 University of Nantes Eclipse day March 2005

Model transformation

‘Model’ means – any data format that can be represented as an EMF model

‘Transformation’ means, e.g.

– Generate XML Schema from UML (or vice versa)

– Expand patterns (templates)

– Merge two versions of the same model

A model transformation has built-in support for maintaining model consistency – unlike a text or XML transformation

Page 15: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation15 University of Nantes Eclipse day March 2005

What makes transformations difficult ?

Reverse transformations

Round-tripping

Updating instead of over-writing

Preserving non-conflicting content (merging)

Reconciling changes

What to do when the transformation ‘gets stuck’ – incorporating human decision making

Traceability – what rule was applied to which elements?

Page 16: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation16 University of Nantes Eclipse day March 2005

Model Transformation Framework

Aims to:

– Speed up implementation of transformations on EMF models

– Support for those ‘difficult’ transformation problems (some assembly required)

Based on:

– rules language for defining “consistency rules” (not transformation rules!)

– transformation engine which interprets those rules

Use in Java applications or Eclipse plug-ins

Page 17: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation17 University of Nantes Eclipse day March 2005

Transformation treated as two separate processes:

Rules

Check & Identify constraint violations

Fix violations

Apply changes

Reconciliation:

Constraint checking:

Model(s)

(Java object graph)

Mappings

Page 18: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation18 University of Nantes Eclipse day March 2005

Mappings

The output from constraint checking (and also from reconciliation) is a set of mappings and constraint violations

A mapping records that a rule was applied to one or more model elements

Mappings may be saved to a file and later loaded back into the transformation engine

Page 19: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation19 University of Nantes Eclipse day March 2005

Mappings

Reconcile

Page 20: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation20 University of Nantes Eclipse day March 2005

Rules language

Rules define types of mappings:

relate xyz (X x, Y y, Z z)

Pre-conditions on creation of mappings

relate xyz (X x, Y y, Z z) when equals(x.name, y.name)

Further constraints to apply to the mapping

relate xyz (X x, Y y, Z z) when equals(x.name, y.name){

another_rule(over x.contents, over y.contents),ref yet_another_rule(x.refersTo, z.links)

}

A rule is actually a class

– mappings that are applications of that rule are instances of it

– MTF extends the EMF Ecore meta-model

Page 21: IBM Software Group © 2005 IBM Corporation University of Nantes Eclipse dayMarch 2005 The Eclipse Modeling Framework and the IBM Model Transformation Framework

IBM Software Group

© 2005 IBM Corporation21 University of Nantes Eclipse day March 2005

For more information..

Eclipse Modeling Framework available from www.eclipse.org/emf

– Open source

– There is a book available

– OMG Meta-Object Facility 2.0 (standard for meta-modelling)

IBM Model Transformation Framework available from www.alphaworks.ibm.com/tech/mtf

– Free, 90 day licence

– Alpha – this is a technology to play with