ibm software group © 2005 ibm corporation university of nantes eclipse daymarch 2005 the eclipse...
TRANSCRIPT
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
IBM Software Group
© 2005 IBM Corporation2 University of Nantes Eclipse day March 2005
Agenda
Eclipse Modeling Framework
IBM Model Transformation Framework
Demo
IBM Software Group
University of Nantes Eclipse day March 2005 © 2005 IBM Corporation
Eclipse Modeling 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)
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
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
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)
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
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
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
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)
…
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
IBM Software Group
University of Nantes Eclipse day March 2005 © 2005 IBM Corporation
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
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?
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
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
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
IBM Software Group
© 2005 IBM Corporation19 University of Nantes Eclipse day March 2005
Mappings
Reconcile
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
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