SlideShare ist ein Scribd-Unternehmen logo
1 von 58
Fundamentals of the Eclipse Modeling Framework Dave Steinberg IBM Rational Software Toronto, Canada EMF Committer
Goal ,[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Model Driven Architecture (MDA) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
MDA – Are We There Yet? ,[object Object],[object Object],[object Object],[object Object]
Enter EMF! ,[object Object],[object Object],[object Object],[object Object]
Model Driven Development with EMF ,[object Object],[object Object],[object Object],[object Object],[object Object]
EMF at Eclipse.org ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is an EMF “Model”? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Model Sources ,[object Object],[object Object],[object Object],[object Object],[object Object]
Java Interfaces ,[object Object],public interface  PurchaseOrder { String  getShipTo (); void setShipTo(String value); String  getBillTo (); void setBillTo(String value); List<Item>  getItems ();  // containment } public interface  Item { String  getProductName (); void setProductName(String value); int  getQuantity (); void setQuantity(int value) float  getPrice (); void setPrice(float value); }
UML Class Diagram ,[object Object],[object Object]
XML Schema <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; targetNamespace=&quot;http://www.example.com/SimplePO&quot; xmlns:po=&quot;http://www.example.com/SimplePO&quot;> <xsd:complexType name=&quot; PurchaseOrder &quot;> <xsd:sequence> <xsd:element name=&quot; shipTo &quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot; billTo &quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot; items &quot;  type=“po:Item&quot;  minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;/> </xsd:sequence> </xsd:complexType> <xsd:complexType name=&quot; Item &quot;> <xsd:sequence> <xsd:element name=&quot; productName &quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot; quantity &quot; type=&quot;xsd:int&quot;/> <xsd:element name=&quot; price &quot; type=&quot;xsd:float&quot;/> </xsd:sequence> </xsd:complexType> </xsd:schema>
Unifying UML, XML and Java ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
EMF Architecture EMF Runtime EMF Tools Core Edit Codegen Model Editor Application Generates Eclipse Platform
EMF Components ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ecore ,[object Object]
Ecore ,[object Object],EClass (name=&quot;PurchaseOrder&quot;) EClass (name=&quot;Item&quot;) EAttribute (name=&quot;shipTo&quot;) EAttribute (name=&quot;billTo&quot;) EReference (name=&quot;items&quot;) eReferenceType EAttribute (name=“productName&quot;)
Ecore ,[object Object],[object Object],<eClassifiers xsi:type=&quot;ecore:EClass&quot; name=&quot; PurchaseOrder &quot;> <eStructuralFeatures xsi:type=&quot;ecore:EReference&quot; name=&quot; items &quot; eType=&quot;#//Item&quot;  upperBound=&quot;-1&quot; containment=&quot;true&quot;/> <eStructuralFeatures xsi:type=&quot;ecore:EAttribute&quot; name=&quot; shipTo &quot;  eType=&quot;ecore:EDataType http:...Ecore#//EString&quot;/> ... </eClassifiers>
Model Import and Generation Ecore Model UML XML  Schema Java Model ,[object Object],[object Object],[object Object],[object Object],I M P O R T Java Edit Java Editor GENERATE
Direct Ecore Modeling ,[object Object],[object Object],[object Object]
EMF and Java 5.0 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Generated Model Code ,[object Object],[object Object],public interface  PurchaseOrder  extends EObject { String getShipTo(); void setShipTo(String value); String getBillTo(); void setBillTo(String value); EList<Item> getItems(); } public class  PurchaseOrderImpl  extends EObjectImpl implements PurchaseOrder { ... }
Change Notification ,[object Object],[object Object],[object Object],[object Object],Adapter adapter = ... purchaseOrder.eAdapters().add(adapter);
Change Notification: Feature Accessors ,[object Object],public String getBillTo() { return billTo; } public void setBillTo(String newBillTo) { String oldBillTo = BillTo; billTo = newBillTo; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, ... , oldBillTo, billTo); }
Bidirectional References public interface  PurchaseOrder { ... PurchaseOrder  getNext (); void  setNext (PurchaseOrder value); PurchaseOrder  getPrevious (); void  setPrevious (PurchaseOrder value); } Bidirectional reference imposes invariant:  po.getNext().getPrevious() == po
Bidirectional Reference Handshaking ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Bidirectional Reference Handshaking p1.setNext(p3); p2 p1 p2 p3 change notification  next previous previous next next previous next previous
Reflective EObject API ,[object Object],[object Object],[object Object],[object Object],public interface  EObject { EClass eClass(); Object  eGet (EStructuralFeature sf); void  eSet (EStructuralFeature sf, Object val); ... }
Reflective EObject API ,[object Object],public Object eGet(int featureID, ...) { switch  (featureID) { case POPackage.PURCHASE_ORDER__ITEMS: return  getItems (); case POPackage.PURCHASE_ORDER__SHIP_TO: return  getShipTo (); case POPackage.PURCHASE_ORDER__BILL_TO: return  getBillTo (); ... } ... }
Typesafe Enums ,[object Object],public  enum  Status implements Enumerator { PENDING(0, &quot;Pending&quot;, &quot;Pending&quot;), BACK_ORDER(1, &quot;BackOrder&quot;, &quot;BackOrder&quot;), COMPLETE(2, &quot;Complete&quot;, &quot;Complete&quot;); public static final int PENDING_VALUE = 0; public static final int BACK_ORDER_VALUE = 1; public static final int COMPLETE_VALUE = 2; private final int value; private final String name; private final String literal; private Status(int value, String name, String literal) { ... } ... }
Factories and Packages ,[object Object],[object Object],POFactory factory =  POFactory.eINSTANCE ; PurchaseOrder order = factory. createPurchaseOrder (); POPackage poPackage =  POPackage.eINSTANCE ; EClass itemClass =  POPackage.Literals.ITEM ; //or poPackage. getItem () EAttribute priceAttr =  POPackage.Literals.ITEM__PRICE ; //or poPackage. getItem_Price () //or itemClass.getEStructuralFeature( POPackage.ITEM__PRICE )
Summary of Generated Artifacts ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Regeneration and Merge ,[object Object],[object Object],[object Object],/** * <!-- begin-user-doc --> * <!-- end-user-doc --> *  @generated */ public String getName() { return name; }
Regeneration and Merge ,[object Object],public String  getName () { return format(getNameGen()); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> *  @generated */ public String  getNameGen () { return name; }
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Persistence ,[object Object],[object Object],[object Object]
Resource Set ,[object Object],[object Object],[object Object],[object Object],ResourceSet  rs = new  ResourceSetImpl (); URI uri = URI.createFileURI(&quot;C:/data/po.xml&quot;); Resource resource = rs. createResource (uri);
Registries ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Resource ,[object Object],[object Object],[object Object],[object Object],[object Object],URI uri = URI.createFileURI(&quot;C:/data/po.xml&quot;); Resource resource = rs.createResource(uri); resource. getContents ().add(p1); resource. save (null); <PurchaseOrder> <shipTo> John Doe </shipTo> <next> p2.xml#p2 </next> </PurchaseOrder>
Proxy Resolution and Demand Load proxyURI=&quot;p2.xml#p2&quot; proxyURI=&quot; p2.xml #p2&quot; p1 p1.xml PurchaseOrder p2 = p1.getNext(); next p2 next p2.xml
XML Schema-Conformant Serialization ,[object Object],[object Object],<xsd:schema ... > <xsd:element name=&quot; order &quot; type=&quot;po:PurchaseOrder&quot;> <xsd:element name=&quot; item &quot; type=&quot;po:Item&quot;> ... </xsd:schema>
XML Schema-Conformant Serialization ,[object Object],[object Object],[object Object],[object Object],PurchaseOrder p1 = ... URI uri = URI.createFileURI(&quot;C:/data/order.po&quot;); resource resource = rs.createResource(uri); DocumentRoot root = POFactory.eINSTANCE.createDocumentRoot(); resource. getContents ().add( root ); root. setOrder ( p1 ); resource.save(null);
Reflection ,[object Object],[object Object],PurchaseOrder po = ... po. setBillTo (&quot;123 Elm St.&quot;); EObject po = ...  EClass poClass = po.eClass(); po. eSet (poClass.getEStructuralFeature(&quot;billTo&quot;), &quot;123 Elm St.&quot;);
Dynamic EMF ,[object Object],[object Object],[object Object],[object Object],[object Object]
Change Recording ,[object Object]
Change Recording ,[object Object],[object Object],[object Object],ChangeRecorder changeRecorder = new ChangeRecorder(resourceSet); try { // modifications within resource set } catch (Exception e) { changeRecorder.endRecording().apply(); }
Validation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Automatically Implemented Constraints ,[object Object],[object Object],[object Object],[object Object],<xsd:simpleType name=&quot;SKU&quot;> <xsd:restriction base=&quot;xsd:string&quot;> <xsd:pattern value=&quot;{3}-[A-Z]{2}&quot;/> </xsd:restriction> </xsd:simpleType>
Diagnostician ,[object Object],[object Object],[object Object],Diagnostician validator =  Diagnostician.INSTANCE ; Diagnostic diagnostic = validator. validate (order); if (diagnostic.getSeverity() == Diagnostic.ERROR) { // handle error } for (Diagnostic child : diagnostic.getChildren()) { // handle child diagnostic }
EMF Utilities ,[object Object],[object Object],[object Object],[object Object],EObject copy = EcoreUtil.copy(original); boolean equal = EcoreUtil.equals(eObject1, eObject2);
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Legal Notices ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

Modelling and Programming: Isn&rsquo;t it all the same?
Modelling and Programming: Isn&rsquo;t it all the same?Modelling and Programming: Isn&rsquo;t it all the same?
Modelling and Programming: Isn&rsquo;t it all the same?CHOOSE
 
Eqela Core API and Utilities
Eqela Core API and UtilitiesEqela Core API and Utilities
Eqela Core API and Utilitiesjobandesther
 
Graphical User Interface Development with Eqela
Graphical User Interface Development with EqelaGraphical User Interface Development with Eqela
Graphical User Interface Development with Eqelajobandesther
 
Introduction to Eqela development
Introduction to Eqela developmentIntroduction to Eqela development
Introduction to Eqela developmentjobandesther
 
Executable UML and SysML Workshop
Executable UML and SysML WorkshopExecutable UML and SysML Workshop
Executable UML and SysML WorkshopEd Seidewitz
 
UML as a Programming Language
UML as a Programming LanguageUML as a Programming Language
UML as a Programming LanguageEd Seidewitz
 
UML: Once More with Meaning
UML: Once More with MeaningUML: Once More with Meaning
UML: Once More with MeaningEd Seidewitz
 
Programming in UML: An Introduction to fUML and Alf
Programming in UML: An Introduction to fUML and AlfProgramming in UML: An Introduction to fUML and Alf
Programming in UML: An Introduction to fUML and AlfEd Seidewitz
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Akhil Mittal
 
Application package
Application packageApplication package
Application packageJAYAARC
 

Was ist angesagt? (10)

Modelling and Programming: Isn&rsquo;t it all the same?
Modelling and Programming: Isn&rsquo;t it all the same?Modelling and Programming: Isn&rsquo;t it all the same?
Modelling and Programming: Isn&rsquo;t it all the same?
 
Eqela Core API and Utilities
Eqela Core API and UtilitiesEqela Core API and Utilities
Eqela Core API and Utilities
 
Graphical User Interface Development with Eqela
Graphical User Interface Development with EqelaGraphical User Interface Development with Eqela
Graphical User Interface Development with Eqela
 
Introduction to Eqela development
Introduction to Eqela developmentIntroduction to Eqela development
Introduction to Eqela development
 
Executable UML and SysML Workshop
Executable UML and SysML WorkshopExecutable UML and SysML Workshop
Executable UML and SysML Workshop
 
UML as a Programming Language
UML as a Programming LanguageUML as a Programming Language
UML as a Programming Language
 
UML: Once More with Meaning
UML: Once More with MeaningUML: Once More with Meaning
UML: Once More with Meaning
 
Programming in UML: An Introduction to fUML and Alf
Programming in UML: An Introduction to fUML and AlfProgramming in UML: An Introduction to fUML and Alf
Programming in UML: An Introduction to fUML and Alf
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
 
Application package
Application packageApplication package
Application package
 

Ähnlich wie EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework

EclipseCon 2007: Effective Use of the Eclipse Modeling Framework
EclipseCon 2007: Effective Use of the Eclipse Modeling FrameworkEclipseCon 2007: Effective Use of the Eclipse Modeling Framework
EclipseCon 2007: Effective Use of the Eclipse Modeling FrameworkDave Steinberg
 
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...Dave Steinberg
 
닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기YoungSu Son
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSFSoftServe
 
EMF - The off beat path
EMF - The off beat pathEMF - The off beat path
EMF - The off beat path17thcamel
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Pythongturnquist
 
NEOOUG 2010 Oracle Data Integrator Presentation
NEOOUG 2010 Oracle Data Integrator PresentationNEOOUG 2010 Oracle Data Integrator Presentation
NEOOUG 2010 Oracle Data Integrator Presentationaskankit
 
Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And TricksJulie Lerman
 
Programming in UML: Why and How
Programming in UML: Why and HowProgramming in UML: Why and How
Programming in UML: Why and HowEd Seidewitz
 
EGL Conference 2011 - EGL Open
EGL Conference 2011 - EGL OpenEGL Conference 2011 - EGL Open
EGL Conference 2011 - EGL OpenWill Smythe
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++ppd1961
 
Entity Framework V1 and V2
Entity Framework V1 and V2Entity Framework V1 and V2
Entity Framework V1 and V2ukdpe
 
Implementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoCImplementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoCjimfuller2009
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best PracticesAndri Yadi
 
Editing XML data with XForms
Editing XML data with XFormsEditing XML data with XForms
Editing XML data with XFormsstsire
 
RomaFramework Tutorial Basics
RomaFramework Tutorial BasicsRomaFramework Tutorial Basics
RomaFramework Tutorial BasicsLuca Garulli
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 

Ähnlich wie EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework (20)

EclipseCon 2007: Effective Use of the Eclipse Modeling Framework
EclipseCon 2007: Effective Use of the Eclipse Modeling FrameworkEclipseCon 2007: Effective Use of the Eclipse Modeling Framework
EclipseCon 2007: Effective Use of the Eclipse Modeling Framework
 
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
 
Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기닷넷 개발자를 위한 패턴이야기
닷넷 개발자를 위한 패턴이야기
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
 
EMF - The off beat path
EMF - The off beat pathEMF - The off beat path
EMF - The off beat path
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
NEOOUG 2010 Oracle Data Integrator Presentation
NEOOUG 2010 Oracle Data Integrator PresentationNEOOUG 2010 Oracle Data Integrator Presentation
NEOOUG 2010 Oracle Data Integrator Presentation
 
Lerman Vvs14 Ef Tips And Tricks
Lerman Vvs14  Ef Tips And TricksLerman Vvs14  Ef Tips And Tricks
Lerman Vvs14 Ef Tips And Tricks
 
Programming in UML: Why and How
Programming in UML: Why and HowProgramming in UML: Why and How
Programming in UML: Why and How
 
Why hibernater1
Why hibernater1Why hibernater1
Why hibernater1
 
EGL Conference 2011 - EGL Open
EGL Conference 2011 - EGL OpenEGL Conference 2011 - EGL Open
EGL Conference 2011 - EGL Open
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++
 
Entity Framework V1 and V2
Entity Framework V1 and V2Entity Framework V1 and V2
Entity Framework V1 and V2
 
Implementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoCImplementing the Genetic Algorithm in XSLT: PoC
Implementing the Genetic Algorithm in XSLT: PoC
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best Practices
 
Editing XML data with XForms
Editing XML data with XFormsEditing XML data with XForms
Editing XML data with XForms
 
RomaFramework Tutorial Basics
RomaFramework Tutorial BasicsRomaFramework Tutorial Basics
RomaFramework Tutorial Basics
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 

Kürzlich hochgeladen

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Kürzlich hochgeladen (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework

  • 1. Fundamentals of the Eclipse Modeling Framework Dave Steinberg IBM Rational Software Toronto, Canada EMF Committer
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14. XML Schema <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; targetNamespace=&quot;http://www.example.com/SimplePO&quot; xmlns:po=&quot;http://www.example.com/SimplePO&quot;> <xsd:complexType name=&quot; PurchaseOrder &quot;> <xsd:sequence> <xsd:element name=&quot; shipTo &quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot; billTo &quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot; items &quot; type=“po:Item&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;/> </xsd:sequence> </xsd:complexType> <xsd:complexType name=&quot; Item &quot;> <xsd:sequence> <xsd:element name=&quot; productName &quot; type=&quot;xsd:string&quot;/> <xsd:element name=&quot; quantity &quot; type=&quot;xsd:int&quot;/> <xsd:element name=&quot; price &quot; type=&quot;xsd:float&quot;/> </xsd:sequence> </xsd:complexType> </xsd:schema>
  • 15.
  • 16.
  • 17. EMF Architecture EMF Runtime EMF Tools Core Edit Codegen Model Editor Application Generates Eclipse Platform
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. Bidirectional References public interface PurchaseOrder { ... PurchaseOrder getNext (); void setNext (PurchaseOrder value); PurchaseOrder getPrevious (); void setPrevious (PurchaseOrder value); } Bidirectional reference imposes invariant: po.getNext().getPrevious() == po
  • 30.
  • 31. Bidirectional Reference Handshaking p1.setNext(p3); p2 p1 p2 p3 change notification next previous previous next next previous next previous
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. Proxy Resolution and Demand Load proxyURI=&quot;p2.xml#p2&quot; proxyURI=&quot; p2.xml #p2&quot; p1 p1.xml PurchaseOrder p2 = p1.getNext(); next p2 next p2.xml
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.

Hinweis der Redaktion

  1. Welcome…
  2. I hope to help you learn about modeling and convince you that EMF can help you write just about any application in significantly less time, simply by leveraging the data model you’ve probably already defined (even though you might not know it yet).
  3. Here’s our agenda. We’ll also be doing a couple of exercises… I’ll start with some philosophy.
  4. What is modeling? The Object Management Group, an industry consortium, has tried to answer that question by proposing MDA – Model Driven Architecture…
  5. MDA initiative began in 2001. Some people are wondering not just “are we there yet?” but “are we ever going to get there?”…
  6. This is the environment in which EMF was introduced and took hold…
  7. EMF’s take is that models are everywhere, and we just need to find them, extract them, and leverage them…
  8. Where does EMF fit into the Eclipse “big picture”? EMF was one of the first projects at Eclipse outside of the Eclipse Project itself, starting in 2002 as part of the Tools project. Since then, the modeling project has formed around it…
  9. Now, let’s talk some more about models in EMF: what they consist of and where they come from.
  10. I’ve mentioned that EMF’s view of modeling favours simplicity over expressiveness. But, to be more concrete, here’s what we mean by a “model” in EMF…
  11. EMF is very much intended to be a unifying technology. It expects models to be expressed in any number of different ways, and aims to extract its core view of the model from those different representations. Out of the box, it supports what we consider to be the most important ones…  To dwell for a moment on the notion of equivalence of different model representations, let’s consider a simple, familiar example. Imagine we wanted to represent the data in a purchase order. The non-modeler would probably start by writing some Java interfaces…
  12. An interface for each type, accessors for each attribute or association (reference). This really is a definition of the model. But, it’s not quite expressive enough that we could generate a complete implementation from it…
  13. A graphical representation of the model is more concise. Here, we’re using UML notation…
  14. There’s another important way of coming at this: by asking “how do we want to instances of the model to look when they’re serialized?” That’s what XML Schema is all about… Notice that there’s additional information in this one…
  15. To reiterate, these different forms all provide the same core information about the model, or structure, of the application’s data. EMF allows you to capture this information and use it to, among other things, generate code.
  16. Now that I’ve hopefully motivated and introduced EMF, I’ll talk a bit about EMF’s architecture.
  17. I guess we need to start with a block diagram. EMF includes a runtime… The last thing to note is that the EMF core runtime’s dependency on the platform is optional…
  18. If we were to zoom in on those blocks, we’d see that EMF includes these components… The component I’ll focus on most is Ecore. If EMF’s purpose is to capture the core information about an application’s data model, the big question is how…
  19. Not surprisingly, it uses a model. Because it’s a model for models… Here is a simplified picture…
  20. The way EMF defines your application model, such as the purchase order we discussed previously, is by instantiating Ecore. So, when the purchase order application is running, there will actually be an instance of EClass present representing class PurchaseOrder…
  21. Ecore is persisted as XML, using the OMG’s standard for metadata serialization, XML Metadata Interchange… EMOF is the OMG’s equivalent to Ecore. Based on experience with EMF, MOF, the Meta-Object Facility, was split into to two layers, where EMOF is the minimal core. Because of their similarity, EMF also supports saving Ecore directly as EMOF XMI and loading EMOF XMI into Ecore.
  22. Here’s another pretty block diagram that will hopefully tie everything together…
  23. Another option is to model directly using Ecore. EMF provides…
  24. One last architectural note: as of last summer’s Europa release, EMF provides support for Java 5… Generics support includes the ability to model generic types within Ecore.
  25. I’ve mentioned more than once that EMF lets you generate code from a model. But what does that code look like?
  26. First off, for each modeled class, an interface/implementation pair is generated. Notice that the interface looks like the Java model representation. Using interfaces allows us to support multiple inheritance. Interfaces extend EObject, the EMF equivalent of java.lang.Object. Getter/setter pairs are included for single-valued attribute and references. Multiplicity-many features are manipulated directly through a list API, so there’s just a getter.
  27. Change notification is built right into EMF. Every EObject is also a Notifier… To attach an observer, which we call an adapter, to a notifier, we’d do this…
  28. Looking in the implementation class at the accessors, we can see how that’s done. It’s still a very simple implementation…
  29. Things get a bit more complicated if you model bidirectional associations, in order to ensure that referential integrity is maintained. To illustrate…
  30. EMF implements this using a handshaking pattern… It’s not possible to turn off this handshaking bahavior or stop it part-way, without significantly altering generated code.
  31. Now, looking at the example, let’s follow the whole handshaking process. If we have three purchase orders arranged like this…
  32. Earlier, I mentioned the EObject interface. Primarily, it provides an API for manipulating objects reflectively…
  33. These generic accessor methods are implemented using an efficient switch, so as to only impose a small constant-time overhead… Metadata in EMF is represented in two ways…
  34. Ecore includes enumerated types, which are realized with Java 5 enums. Previously, a class-based type-safe enum pattern was used.
  35. A couple of really important interfaces and classes are generated for each modeled package…
  36. Obviously, there’s not enough time to talk about every artifact that EMF generates, so here’s a quick list. Notice that the code is divided into four projects…
  37. As I mentioned in the intro, Ecore is simple by design. Instead of trying to provide a modeling vocabulary that’s as expressive as Java…
  38. The generator also supports a pattern for extending generated methods, analogous to overriding a method in a subclass…
  39. [8:35] Let’s get into the exercises… [8:55] I’d like to talk a bit about how you can use all this code you generated, and then I’ll let you do the second exercise.
  40. We’ll start with EMF’s resource-based persistence framework. A resource in EMF is just a container for a bunch of objects that will be persisted together. Objects can be spread out among a number of different resources, and demand-loading is used for cross-resource references. That allows…
  41. A resource set provides a context for multiple resources that may have references among them. You’ll use the resource set to create and manage those resources…
  42. There are a couple of registries you’ll need to know about… A resource factory registry is used by a resource set to decide what type of resource to create, so it determines the persistence format… A package registry is used to locate metadata during loading. Persisted data specifies a namespace URI…
  43. As I mentioned earlier, a resource is just a container for objects that are persisted together… Out of the box, EMF provides a generic XML resource and a number of different specializations of it…
  44. To expand on EMF’s demand-load model for cross-resource references, let’s look at another simple example…
  45. When you’re working with a model created from XML Schema, there are a couple of extra details you’ll need to worry about. In the first exercise, we saw that the model included…
  46. To serialize an instance document that conforms to the schema, you’ll need to use an instance of… Also, you’ll need to ensure that…
  47. The reflective EObject interface is a powerful mechanism for data integration, as it allows your application to discover the model for objects at runtime and modify them accordingly. If you know the model ahead of time…
  48. Built on the reflective API is dynamic EMF. Rather than generating code, you can define an Ecore model at runtime and instantiate it immediately, using a generic implementation. All of the behaviours of the generated code are emulated by this implementation. You can define the model…
  49. EMF provides a facility for representing and recording changes to data. As we’re big believers in eating our own dog food…
  50. A change recorder is a special adapter that attaches to an entire content tree and, based on the change notifications it receives…
  51. The EMF core also has a built-in framework for validation of invariants and constraints…
  52. There are a couple of cases where constraints will actually be implemented automatically… For example, in our purchase order schema, there is a SKU type that’s a restriction of string. It specifies a regular expression that any valid value must match…h
  53. The API for invoking validation is the Diagnostician class…
  54. Finally, the runtime provides a whole bunch of convenience utilities, mostly in the class EcoreUtil. There you’ll find…
  55. [9:15] I’ll stop talking again now and let you work on the second exercise. I’ll stop you a few minutes before the session ends to sum things up. [9:55] Let’s sum up…