Dynamic and Generic Manipulation of Models :  from Introspection to Scripting <ul><li>Christophe Tombelle 1 ,  Gilles Vanw...
Motivation <ul><li>Growing space of models conforming to different metamodels  </li></ul><ul><li>Development of powerful m...
Outline <ul><li>Model Introspection </li></ul><ul><li>Model Scripting </li></ul><ul><li>EMFScript Tool </li></ul>
Model Introspection
Reflective Interfaces <ul><li>Feature of existing modeling Framework  </li></ul><ul><ul><li>MOF, JMI,  EMF </li></ul></ul>...
Example
Architectures Mapping
Multilevel Introspection
Using Reflective Interfaces  1. Assignment a =  factory.createAssignment();  2.  Variable v1 = factory.createVariable() ; ...
Using Reflective Interfaces <ul><li>Sources of complexity </li></ul><ul><ul><li>Instructions inflation </li></ul></ul><ul>...
Using Reflective Interfaces <ul><li>Interesting and powerful capabilities </li></ul><ul><ul><li>Manipulating models dynami...
Model Scripting
Scripting  <ul><li>A general programing technique which exposes the functionality of existing components or applications t...
Model Scripting <ul><li>Apply the idea of scripting to models  </li></ul><ul><li>Dynamically and automatically expose mode...
Model Scripting : Principles <ul><li>Scriptable elements </li></ul>
Model Scripting : Principles <ul><li>Scripting expression </li></ul><ul><ul><li>hide the use and complexity of model intro...
Model Scripting : Principles <ul><li>Scripting translation </li></ul><ul><ul><li>transparent and automatic conversion of e...
Model Scripting : Principles <ul><li>Scripting validation </li></ul><ul><ul><li>Various errors may occur in scripting expr...
EMFScript Tool
EMFScript <ul><li>A concrete model scripting language  </li></ul><ul><ul><li>Exposes the EMF metamodeling architecture as ...
Scripting version <ul><li>Equivalent to the reflective version </li></ul><ul><li>Drawbacks elimination of the reflective v...
Metamodel Manipulation <ul><li>1. cls = miniLangMM.$Program ;  </li></ul><ul><li>2. features = cls.eStructuralFeatures ;  ...
Generic Manipulation 1.  function ensureExistance(elt, linkName) { 2.  metaref =  elt.eClass() [linkName] ;  3.  if (metar...
Conclusion & Future Work <ul><li>Summary </li></ul><ul><ul><li>A general approach adding an abstraction level on top of re...
Availability <ul><li>EMFScript </li></ul><ul><li>http://www.telecom-lille1.fr/people/Vanwormhoudt/modelscripting </li></ul>
Upcoming SlideShare
Loading in …5
×

Dynamic and Generic Manipulation of Models: From Introspection to Scripting

1,277 views

Published on

Talks at Model 2006 conference

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,277
On SlideShare
0
From Embeds
0
Number of Embeds
72
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Dynamic and Generic Manipulation of Models: From Introspection to Scripting

  1. 1. Dynamic and Generic Manipulation of Models : from Introspection to Scripting <ul><li>Christophe Tombelle 1 , Gilles Vanwormhoudt 1,2 </li></ul><ul><li>1 GET/Telecom Lille 1 </li></ul><ul><li>2 LIFL, Université de Lille 1 </li></ul>Models 2006, Genova
  2. 2. Motivation <ul><li>Growing space of models conforming to different metamodels </li></ul><ul><li>Development of powerful modeling environments </li></ul><ul><li>Model introspection </li></ul><ul><ul><li>gives the ability to work with any model by querying its structure dynamically at runtime </li></ul></ul><ul><ul><li>limited support in model manipulation languages </li></ul></ul><ul><ul><li>a powerful but complex technique </li></ul></ul>
  3. 3. Outline <ul><li>Model Introspection </li></ul><ul><li>Model Scripting </li></ul><ul><li>EMFScript Tool </li></ul>
  4. 4. Model Introspection
  5. 5. Reflective Interfaces <ul><li>Feature of existing modeling Framework </li></ul><ul><ul><li>MOF, JMI, EMF </li></ul></ul><ul><ul><li>Inherited by metamodel-specific interfaces </li></ul></ul><ul><li>Structural Introspection </li></ul><ul><ul><li>Operations to access metamodel reification </li></ul></ul><ul><li>Computational Introspection </li></ul><ul><ul><li>Operations to create, inspect and modify model elements using metamodel reification </li></ul></ul>
  6. 6. Example
  7. 7. Architectures Mapping
  8. 8. Multilevel Introspection
  9. 9. Using Reflective Interfaces 1. Assignment a = factory.createAssignment(); 2. Variable v1 = factory.createVariable() ; 3. v1.setIdentifier(&quot;v1&quot;) ; 4. a.setLeft (v1); 1. EClass assignClass = (EClass) pkg.getEClassifier(&quot;Assignment&quot;) ; 2. EObject a = factory.create( assignClass ) ; 3. EClass varClass = (EClass) pkg.getEClassifier(&quot;Variable&quot;) ; 4. EObject v1 = factory.create( varClass ) ; 5. EStructuralFeature metaatt = varClass.getEStructuralFeatur(&quot;identifier&quot;) ; 6. v1.eSet( metaatt , &quot;v1&quot;) ; 7. EStructuralFeature metaref = assignClass.getEStructuralFeature(&quot;left&quot;) ; 8. a.eSet( metaref , v1) ; Reflective version Metamodel-specific version
  10. 10. Using Reflective Interfaces <ul><li>Sources of complexity </li></ul><ul><ul><li>Instructions inflation </li></ul></ul><ul><ul><li>Multilevel knowledge requirement </li></ul></ul><ul><ul><li>Model and Implementation level conflation </li></ul></ul><ul><ul><li>Model manipulation scattering </li></ul></ul>
  11. 11. Using Reflective Interfaces <ul><li>Interesting and powerful capabilities </li></ul><ul><ul><li>Manipulating models dynamically by discovering their metamodel : generic browsing, transf. engine </li></ul></ul><ul><ul><li>Generic manipulations (see example in paper) </li></ul></ul>Model2 Model1 Meta model2 Meta model1 Metamodel-neutral manipulation {XMI serialisation, Model extraction, ...} Multilevel manipulation {model copy, model2text, ...}
  12. 12. Model Scripting
  13. 13. Scripting <ul><li>A general programing technique which exposes the functionality of existing components or applications to program control </li></ul><ul><li>Exposition process is done dynamically using introspection mechanisms </li></ul><ul><li>Scripting language = dynamic language </li></ul><ul><ul><li>systematize the exposition process and made it transparent through a high-level notation </li></ul></ul><ul><ul><li>simplicity of use and improved productivity </li></ul></ul>
  14. 14. Model Scripting <ul><li>Apply the idea of scripting to models </li></ul><ul><li>Dynamically and automatically expose models and their elements to program control </li></ul><ul><li>Systematize models introspection and make it transparent through a scripting language </li></ul><ul><li>Usages of model scripting language </li></ul><ul><ul><li>interactive tasks like model/metamodel prototyping/exploration/testing </li></ul></ul><ul><ul><li>rapid development of program to process models or metamodels </li></ul></ul>
  15. 15. Model Scripting : Principles <ul><li>Scriptable elements </li></ul>
  16. 16. Model Scripting : Principles <ul><li>Scripting expression </li></ul><ul><ul><li>hide the use and complexity of model introspection with a simple and uniform notation </li></ul></ul><ul><ul><li>based on modeling level concepts instead of implementation ones </li></ul></ul><ul><ul><li>keep the capability of dynamic operations </li></ul></ul><ul><ul><li>composable with control instructions </li></ul></ul>
  17. 17. Model Scripting : Principles <ul><li>Scripting translation </li></ul><ul><ul><li>transparent and automatic conversion of expressions into invocations of reflective actions </li></ul></ul><ul><ul><li>A generic two-step process </li></ul></ul><ul><ul><ul><li>Metalevel ascension to retrieve descriptions </li></ul></ul></ul><ul><ul><ul><li>Dynamic access from retrieved descriptions </li></ul></ul></ul>T(“elt.att = value “) => elt.setAttValue( (elt.modelClass()).lookupAtt(att) , value)
  18. 18. Model Scripting : Principles <ul><li>Scripting validation </li></ul><ul><ul><li>Various errors may occur in scripting expressions (typing issues, structural non-conformance, ...) </li></ul></ul><ul><ul><li>Checking the validity of expression before translation </li></ul></ul><ul><ul><ul><ul><li>Robust scripting </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Provide errors in terms of modeling concepts </li></ul></ul></ul></ul><ul><ul><li>Refer to the available metadescription </li></ul></ul>
  19. 19. EMFScript Tool
  20. 20. EMFScript <ul><li>A concrete model scripting language </li></ul><ul><ul><li>Exposes the EMF metamodeling architecture as Javascript objects </li></ul></ul><ul><ul><li>Basic and high-level functionalities for manipulating any EMF models </li></ul></ul><ul><li>Integration into Eclipse environment as shell usable in interactive and batch mode </li></ul><ul><li>Efficient implementation on top of Rhino, a extensible Javascript interpreter </li></ul>
  21. 21. Scripting version <ul><li>Equivalent to the reflective version </li></ul><ul><li>Drawbacks elimination of the reflective version </li></ul><ul><li>More abstract and model-oriented than metamodel-specific version </li></ul>1. assign = miniLangMM.$Assignment.create(); 2. v1 = miniLang.$Variable.create(); 3. v1.identifier = &quot;v1&quot; ; 4. assign.left = v1;
  22. 22. Metamodel Manipulation <ul><li>1. cls = miniLangMM.$Program ; </li></ul><ul><li>2. features = cls.eStructuralFeatures ; </li></ul><ul><li>3. for (i in features) { </li></ul><ul><li>4. f = features[i] ; </li></ul><ul><li>if (f.assignable) </li></ul><ul><li>6. printf(f.name) ; </li></ul><ul><li>7. } </li></ul><ul><li>Simple, uniform manipulation for every modeling level </li></ul><ul><li>Dynamic metamodel access and construction </li></ul>
  23. 23. Generic Manipulation 1. function ensureExistance(elt, linkName) { 2. metaref = elt.eClass() [linkName] ; 3. if (metaref.containment && 4. elt[linkName] == null) { 5. subElt = metaref.eType.create () ; 6. elt[linkName] = subElt ; 7. } 8. } <ul><li>Metalevel access by scripting </li></ul><ul><li>Dynamic expressions </li></ul>
  24. 24. Conclusion & Future Work <ul><li>Summary </li></ul><ul><ul><li>A general approach adding an abstraction level on top of reflective interfaces </li></ul></ul><ul><ul><li>New results to program model manipulation </li></ul></ul><ul><ul><li>A powerful model scripting language </li></ul></ul><ul><li>Future Work </li></ul><ul><ul><li>New model introspection mechanisms </li></ul></ul><ul><ul><li>Methodological study of model introspection </li></ul></ul>
  25. 25. Availability <ul><li>EMFScript </li></ul><ul><li>http://www.telecom-lille1.fr/people/Vanwormhoudt/modelscripting </li></ul>

×