Chetan Kumar K, RBEI jointly with  Annamalai C, ANCiT
In-memory dbase content D-Base UI display What is a model ??? That is a model!
What is model ??? <ul><li>Placeholder of data </li></ul><ul><li>Can “get” and “set” data </li></ul>Get data Set data Get d...
…  and so on Will you spend time writing each class ??  Map design and code (model) PIM PSM Or be smart and generate them ...
Typical code-generation flow PIM Generator Model Code Generation  Engine Code generation  templates PSM PSM
EMF a code generator. <ul><li>EMF is one such code-generator </li></ul><ul><li>Let’s you generate concrete classes based o...
Code generation flow – EMF way PIM (ecore) Generator Model genmodel EMF Code Generation  Engine Code generation  Templates...
First look of EMF as a code-generator… Tap along guys…
The complete Example UML
Properties of (E)Attribute Data type of attribute EType Default value assigned when containing class is instantiated Defau...
M-V-C architecture thru EMF
… EMF first impressions. <ul><li>EMF generates code – will it steal my job! </li></ul><ul><li>EMF generates UI stuff – why...
EMF.Edit Control how model elements are displayed, edited.
EMF.Edit – bird’s eye view. Contains UI Providers for each Model Element. Content Provider Label Provider Property Source ...
EMF.Edit control flow – Content Providers “ +” clicked Item provider code eGet api calls Generated api getter(s)
EMF.Edit control flow – Label Providers Item provider code eGet api calls Generated api getter(s)
EMF.Edit control flow – Property Source Tree item selected Item provider code Individual feature’s property descriptor bui...
EMF.Edit providers – one for all, all for one <ul><li>Content, Label, Image, and Property source providers all through one...
EMF.Edit commands Command based model editing support
EMF.Edit Commands Command based editing of model instances Editing domain UI display “ Set” event as Command Command stack...
EMF.Edit – How do I create/use Commands ? Model object EMF Editing Domain <ul><li>Contains command stack </li></ul><ul><li...
EMF.Edit – commands, a deeper look Command interface Existing Command implementations Do you need to implement this interf...
EMF.Edit – “Change… is here!” Should I have one command per operation ? Can I “record” changes done to a model ? Oooo yess...
Should I always generate EMF.xxx code ? <ul><li>Nope … can work with “Dynamic EMF” </li></ul><ul><li>Ecore – instantiate m...
Model xml / xmi load save UI display What after you edit ?? – can ya persist ?
EMF serialization Model object EMF Resource EMF Resource Set xml / xmi
Load and save flows Model object xml / xmi load save EMF Reosource Typical code snippet:
EMF Serialization – behind the scenes <ul><li>EAnnotations stores mapping b/w XML and Ecore </li></ul><ul><li>Any model el...
Can I directly persist EMF Objects into dbase ? Yes, u can – using EMF Teneo   ( http:// www.eclipse.org/modeling/emf/?pro...
<ul><li>Get all students aged > 5 </li></ul>Model Navigation and search Isn’t there a better way than loops ? Can’t I “Que...
In the end… what is EMF ? <ul><li>Code generator based on a design (UML) </li></ul><ul><li>Means of Java XML binding with ...
EMF Transaction Thread-safe editing of a single Model Instance Transaction style editing of model instances
Model editing through multiple threads Thread 1 Change name : “ Jimmy Bend” Thread 2 Change name “ James Bond” name: Harry...
“ A mind once stretched by a thought never regains its original dimensions”
References <ul><li>EMF newsgroups:  http://www.eclipse.org/newsportal/thread.php?group=eclipse.tools.emf </li></ul><ul><li...
Upcoming SlideShare
Loading in...5
×

EMF - The off beat path

1,859

Published on

This is a presentation of EMF from the ground up during Eclipse India Summit, Bangalore July 2009. This was a joint session from me and Annamalai, ANCiT.

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

No Downloads
Views
Total Views
1,859
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
37
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

EMF - The off beat path

  1. 1. Chetan Kumar K, RBEI jointly with Annamalai C, ANCiT
  2. 2. In-memory dbase content D-Base UI display What is a model ??? That is a model!
  3. 3. What is model ??? <ul><li>Placeholder of data </li></ul><ul><li>Can “get” and “set” data </li></ul>Get data Set data Get data Data In memory representation of data <ul><li>Can be derived from a design </li></ul>
  4. 4. … and so on Will you spend time writing each class ?? Map design and code (model) PIM PSM Or be smart and generate them ?? UML Java
  5. 5. Typical code-generation flow PIM Generator Model Code Generation Engine Code generation templates PSM PSM
  6. 6. EMF a code generator. <ul><li>EMF is one such code-generator </li></ul><ul><li>Let’s you generate concrete classes based on a design (UML) </li></ul><ul><li>Let’s look at an example… </li></ul>
  7. 7. Code generation flow – EMF way PIM (ecore) Generator Model genmodel EMF Code Generation Engine Code generation Templates (JET) PSM (Java)
  8. 8. First look of EMF as a code-generator… Tap along guys…
  9. 9. The complete Example UML
  10. 10. Properties of (E)Attribute Data type of attribute EType Default value assigned when containing class is instantiated Default value Literal Find out if an attribute was touched Unsettable Value can be changed or not Changeable Attribute isn’t persisted Transient No associated storage (value can be calculated) Volatile Meaning Property
  11. 11. M-V-C architecture thru EMF
  12. 12. … EMF first impressions. <ul><li>EMF generates code – will it steal my job! </li></ul><ul><li>EMF generates UI stuff – why pay a UI developer ? </li></ul><ul><li>Oh god! Something new – too much learning curve </li></ul><ul><li>Should I learn “Modeling” or write code now ? </li></ul>Points 3, 4 courtesy Ed Merks It will be great if these points are myths … wat say ?
  13. 13. EMF.Edit Control how model elements are displayed, edited.
  14. 14. EMF.Edit – bird’s eye view. Contains UI Providers for each Model Element. Content Provider Label Provider Property Source Item Provider Generated implementation for different providers
  15. 15. EMF.Edit control flow – Content Providers “ +” clicked Item provider code eGet api calls Generated api getter(s)
  16. 16. EMF.Edit control flow – Label Providers Item provider code eGet api calls Generated api getter(s)
  17. 17. EMF.Edit control flow – Property Source Tree item selected Item provider code Individual feature’s property descriptor built Property descriptors
  18. 18. EMF.Edit providers – one for all, all for one <ul><li>Content, Label, Image, and Property source providers all through one provider instance!! </li></ul><ul><li>Now that’s called … convenience. </li></ul>
  19. 19. EMF.Edit commands Command based model editing support
  20. 20. EMF.Edit Commands Command based editing of model instances Editing domain UI display “ Set” event as Command Command stack setXXX() undoable Model object
  21. 21. EMF.Edit – How do I create/use Commands ? Model object EMF Editing Domain <ul><li>Contains command stack </li></ul><ul><li>Factories to create commands </li></ul>
  22. 22. EMF.Edit – commands, a deeper look Command interface Existing Command implementations Do you need to implement this interface ??
  23. 23. EMF.Edit – “Change… is here!” Should I have one command per operation ? Can I “record” changes done to a model ? Oooo yess!! Works on change notofications given on each operation ChangeRecorder recoreds these notifications from individual setters. Hence, bulk undo is possible  Can I perform many operations in one command ?
  24. 24. Should I always generate EMF.xxx code ? <ul><li>Nope … can work with “Dynamic EMF” </li></ul><ul><li>Ecore – instantiate model (load) – edit – persist … is possible </li></ul>Responsible code: EMF Reflective API, EMF Reflective Item Providers
  25. 25. Model xml / xmi load save UI display What after you edit ?? – can ya persist ?
  26. 26. EMF serialization Model object EMF Resource EMF Resource Set xml / xmi
  27. 27. Load and save flows Model object xml / xmi load save EMF Reosource Typical code snippet:
  28. 28. EMF Serialization – behind the scenes <ul><li>EAnnotations stores mapping b/w XML and Ecore </li></ul><ul><li>Any model element can have EAnnotations </li></ul>
  29. 29. Can I directly persist EMF Objects into dbase ? Yes, u can – using EMF Teneo ( http:// www.eclipse.org/modeling/emf/?project = teneo ) Create HbDataStore Create Hibernate Session, Transaction Begin Transaction Create EMF Model root object, make it persistent Create sub-tree under persistent root Commit Tx
  30. 30. <ul><li>Get all students aged > 5 </li></ul>Model Navigation and search Isn’t there a better way than loops ? Can’t I “Query” an EMF model ?? The cool “Query way”
  31. 31. In the end… what is EMF ? <ul><li>Code generator based on a design (UML) </li></ul><ul><li>Means of Java XML binding with Inbuilt persistence mechanism </li></ul><ul><li>Command based model editing support, with generated item providers </li></ul><ul><li>All in all, a base for applications based on MDA </li></ul>
  32. 32. EMF Transaction Thread-safe editing of a single Model Instance Transaction style editing of model instances
  33. 33. Model editing through multiple threads Thread 1 Change name : “ Jimmy Bend” Thread 2 Change name “ James Bond” name: Harry Potter name: ??? Model object Model object
  34. 34. “ A mind once stretched by a thought never regains its original dimensions”
  35. 35. References <ul><li>EMF newsgroups: http://www.eclipse.org/newsportal/thread.php?group=eclipse.tools.emf </li></ul><ul><li>EMF book: Eclipse Modeling Framework by Ed Merks et.al </li></ul><ul><li>EMF Refcard on DZone: http://refcardz.dzone.com/refcardz/essential-emf </li></ul><ul><li>Articles on Dynamic EMF </li></ul><ul><li>- IBM developerWorks ( http://www.ibm.com/developerworks/library/os-eclipse-dynamicemf/ ) </li></ul><ul><li>- devX.com ( http://www.devx.com/Java/Article/29093/0/page/1 ) </li></ul><ul><li>Blogs: http://tweakeclipse.blogspot.com/ http://eclipseo.blogspot.com/ and many more!! </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×