This presentation describes Eclipse Modeling Framework – EMF. It has two basic purposes:
Introduce you to the EMF techniques needed in the rest of the course
Introduce you to the architecture and components of the EMF project
This presentation is developed for MDD 2010 course at ITU, Denmark.
No one could accuse the Eclipse Modeling Framework of being immature or unproven technology. In over seven years since EMF's debut, it has been applied in just about every type of application imaginable, from the desktop, to the web, to mobile and embedded. With this growth came great demand for ways to optimize performance or memory footprint, and to integrate EMF with other complementary technologies and frameworks.
One of the big reasons for EMF's success has been its low barriers to entry: with EMF, anyone can quickly and easily generate powerful, high-quality code from just about any form of model. However, many of the framework's most powerful performance and extensibility features hide below the surface, making it difficult for developers to exploit the framework fully.
This tutorial aims to expose EMF developers to these issues. Rather than plain or simple recipes, it will offer in-depth discussion, drawing on the presenters' experience as EMF committers. Hands-on exercises will provide the opportunity for attendees to become familiar with some lesser-known features that can help them squeeze more performance and utility out of their models.
No one could accuse the Eclipse Modeling Framework of being immature or unproven technology. In over seven years since EMF's debut, it has been applied in just about every type of application imaginable, from the desktop, to the web, to mobile and embedded. With this growth came great demand for ways to optimize performance or memory footprint, and to integrate EMF with other complementary technologies and frameworks.
One of the big reasons for EMF's success has been its low barriers to entry: with EMF, anyone can quickly and easily generate powerful, high-quality code from just about any form of model. However, many of the framework's most powerful performance and extensibility features hide below the surface, making it difficult for developers to exploit the framework fully.
This tutorial aims to expose EMF developers to these issues. Rather than plain or simple recipes, it will offer in-depth discussion, drawing on the presenters' experience as EMF committers. Hands-on exercises will provide the opportunity for attendees to become familiar with some lesser-known features that can help them squeeze more performance and utility out of their models.
Java Applet
Applet is a special type of program that is embedded in the webpage to generate the dynamic content. It runs inside the browser and works at client side.
Advantage of Applet
There are many advantages of applet. They are as follows:
It works at client side so less response time.
Secured
It can be executed by browsers running under many plateforms, including Linux, Windows, Mac Os etc.
Drawback of Applet
Plugin is required at client browser to execute applet.
Developing and Visualizing Live Model QueriesZoltán Ujhelyi
1st Analysis of Model Transformations Workshop, 2012
Several important tasks performed by model driven development tools — such as well-formedness constraint validation or model transformations — rely on evaluating model queries. If the model changes rapidly or frequently, it is beneficial to provide live queries that automatically propagate these model changes into the query results. To ease the development and debugging of live queries, the development environment should provide a way to evaluate the query results continuously, helping to understand how the created query works.
This presentation presents a generic live model query visualizer that displays and updates the query results depending on their source models. It has been implemented for the EMF-IncQuery framework and presented here for validating BPMN models.
An overview of the code that makes up the skeleton of a basic RCP application. This includes the basics for advisors and perspectives. This module also describes the basics of how to launch and debug an RCP application.
Remote Method Invocation, Distributed Programming in java, Java Distributed Programming, Network Programming in JAVA, Core Java, Introduction to RMI, Getting Started with RMI, Getting Started with Remote Method Invocation, Distributed Programming, Java, J2SE
Introduction to java beans, java beans, Core java, j2se, getting started with java beans programming, java to standard edition, beans in java, beans programming in java
EclipseCon 2008: Fundamentals of the Eclipse Modeling FrameworkDave Steinberg
EclipseCon 2008 long talk introducing EMF. A slightly different take from the preceding EclipseWorld talk, with a few more details on the EMF core and no discussion of CDO or Teneo.
Eclipse Modeling Framework (EMF) and Graphical Modeling Framework (GMF)Dimitris Kolovos
Lecture slides from the Model-Driven Engineering module of York's MSc in Software Engineering: http://www.cs.york.ac.uk/postgraduate/taught-courses/msc-swe/
Java Applet
Applet is a special type of program that is embedded in the webpage to generate the dynamic content. It runs inside the browser and works at client side.
Advantage of Applet
There are many advantages of applet. They are as follows:
It works at client side so less response time.
Secured
It can be executed by browsers running under many plateforms, including Linux, Windows, Mac Os etc.
Drawback of Applet
Plugin is required at client browser to execute applet.
Developing and Visualizing Live Model QueriesZoltán Ujhelyi
1st Analysis of Model Transformations Workshop, 2012
Several important tasks performed by model driven development tools — such as well-formedness constraint validation or model transformations — rely on evaluating model queries. If the model changes rapidly or frequently, it is beneficial to provide live queries that automatically propagate these model changes into the query results. To ease the development and debugging of live queries, the development environment should provide a way to evaluate the query results continuously, helping to understand how the created query works.
This presentation presents a generic live model query visualizer that displays and updates the query results depending on their source models. It has been implemented for the EMF-IncQuery framework and presented here for validating BPMN models.
An overview of the code that makes up the skeleton of a basic RCP application. This includes the basics for advisors and perspectives. This module also describes the basics of how to launch and debug an RCP application.
Remote Method Invocation, Distributed Programming in java, Java Distributed Programming, Network Programming in JAVA, Core Java, Introduction to RMI, Getting Started with RMI, Getting Started with Remote Method Invocation, Distributed Programming, Java, J2SE
Introduction to java beans, java beans, Core java, j2se, getting started with java beans programming, java to standard edition, beans in java, beans programming in java
EclipseCon 2008: Fundamentals of the Eclipse Modeling FrameworkDave Steinberg
EclipseCon 2008 long talk introducing EMF. A slightly different take from the preceding EclipseWorld talk, with a few more details on the EMF core and no discussion of CDO or Teneo.
Eclipse Modeling Framework (EMF) and Graphical Modeling Framework (GMF)Dimitris Kolovos
Lecture slides from the Model-Driven Engineering module of York's MSc in Software Engineering: http://www.cs.york.ac.uk/postgraduate/taught-courses/msc-swe/
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.
This presentation describes the use of XText.
This presentation assumes a good knowledge of Data Modeling and Grammars as previously presented.
This presentation is developed for MDD 2010 course at ITU, Denmark.
L0043 - Interfacing to Eclipse Standard ViewsTonny Madsen
Eclipse contains a large number of standard views that can be extended to support new languages or data models. This model focus on the interface to the most common Eclipse views: Problems View, Outline View, and the Properties View.
The graphical sub-system of the Eclipse platform is made up of two components: SWT, the Standard Widget Toolkit ;and JFace, an architecture-independent modeling layer. This module describes how JFace extends SWT with viewers, commands, wizards, dialogs, and field assist.
L0018 - SWT - The Standard Widget ToolkitTonny Madsen
The graphical sub-system of the Eclipse platform is made up of two components: SWT, the Standard Widget Toolkit; and JFace, an architecture independent modeling layer. This module describes how to use SWT in views and editors and how different resources must be managed.
L0016 - The Structure of an Eclipse Plug-inTonny Madsen
This is a detailed description of the different parts that makes up an Eclipse plug-in. The module focuses on the purpose of the different files of a plug-in such as plugin.xml and the OSGi manifest file, MANIFEST.MF. The module also describes how plug-ins are developed in Eclipse with PDE, the Plug-in Development Environment
L0001 - The Terminology of the Eclipse PlatformTonny Madsen
This is a basic walk-through of all the central concepts of the Eclipse platform and how these fit together. The primary goal of this module is to establish a common terminology.
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...Tonny Madsen
How do you effectively control commands, menus and handlers in a large pluggable application to get a consistent use of the commands across the complete application? This is definitely one of the areas where the Eclipse IDE is not a good sample application. Just notice how all team providers add commands with the same text and function and how multiple identical menu items some times show up...
Here the Adapter framework of Eclipse can be a big help if used properly.
While the Adapter framework arguably is one of the more difficult to understand and use properly, the is also a framework that will solve many of the problems you might face is larger non-trivial applications. Especially when used in conjunction with the menus extension point and handlers. This presentation will show how to use the adapter framework of the Eclipse framework with special emphasis on the menus and handlers.
For PROSA:
Onsdag 26.1. Introduktion til Eclipse
Eclipse er et fremstormende open source-udviklingsmiljø (Eclipse IDE), der oprindeligt er udviklet med henblik på Java.
Kom og mød Tonny Madsen, formand for Eclipse Danmark, foreningen for både professionelle, virksomheder og brugere.
Tonny er til daglig direktør i RCP Company, der har specialiseret sig i udvikling, uddannelse og konsulentydelser inden for Eclipse.
Han vil give jer et overblik over platformen, både teknisk, projektmæssigt, organisering, muligheder, fremtiden etc.
ITU - MDD – Model-to-Model TransformationsTonny Madsen
This presentation describes the use Model-to-Model transformations (M2M). It focus on the why, what and how.
This presentation is developed for MDD 2010 course at ITU, Denmark.
”Medbring din laptop, netbook, mac el.lign. og få i løbet af denne workshop dine første hands-on erfaringer med Eclipse.”
Arrangement for IDA.
In Danish
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...Tonny Madsen
”Har du tænkt på at skifte til et leverandøruafhængigt udviklingsmiljø? Det er gratis, og du får ét udviklingsmiljø, som du kan programmere alt fra Java, C, C++ og PHP til databaser og webserver i. Vi får dig til at se værdien af værktøjet, og se flere forskellige eksempler på brugen af Eclipse i praksis.
Kom og hør formanden for eclipse.dk, Tonny Madsen, Direktør, RCP Kompaniet fortælle om Eclipse.
Eclipse er component-baseret, og du får indsigt i hvordan du sammensætter Eclipse til netop dine behov.”
In Danish
This presentation shows how Eclipse plug-ins are developed. It has two purposes:
Introduce you to the architecture and techniques of a major component based application
Introduce you to basic Eclipse plug-in development – this will hopefully ease the needed programming in the rest of the course
This presentation is developed for MDD 2010 course at ITU, Denmark.
eclipse.dk - Eclipse RCP Under the HoodTonny Madsen
Denne event er en kombination af en tutorial day og en live demonstration af en "full featured" Eclipse RCP applikation hvor udviklingen kommenteres on-the-fly.
Medbring din laptop og prøv selv hvordan man forholdsvis let kan starte en Eclipse RCP applikation. Det er meget vigtigt at du allerede har Eclipse 3.6 installeret på maskinen.Følgende emner vil blive demonstreret / omtalt
Eclipse RCP Arkitektur
Konfiguration (OSGi console, plugin.xml, manifest.mf...)
Packaging
Extension Points
UI / SWT / JFace
Editors / Views
Building and Testing
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...Tonny Madsen
Eclipse RCP – about of the box – is a fantastic platform for building applications. Especially if these are for engineer-like users
When Eclipse RCP is used for enterprise applications – like for banks – one of major shortcomings is found in the missing ability to control screen flows.
This talk describes how screen flow was implemented in a major banking application where we expect to add 2-300 screen flows, some very simple and some very complex.
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...Tonny Madsen
Imagine you have to develop a larger Eclipse RCP based application with many dozens - maybe hundreds - of views, dialogs and wizards all based on a large common EMF based data model. How do you make sure you get a consistent and modern interface that can be extended in the future without redesigning everything again and again?
javagruppen.dk - e4, the next generation Eclipse platformTonny Madsen
After 13 years, the Eclipse framework gets it second make-over. The new work is termed e4 and will be included in Eclipse 4.0.
In the first make-over the run-time was replaced in Eclipse 3.0 with OSGi to get a better and more stable foundation for plug-ins. This time the user interface and contributions are modernized for use in Eclipse 4.0.
In this session, we will see some of the insides of the new paradigms in e4.
This presentation describes different modeling techniques. It has three basic purposes:
Give you an overview of some of the different types of models
Give you a set of tools to decide how to create a (good) model for a problem
Give you an overview of some of the different modeling techniques
This presentation is developed for MDD 2010 course at ITU, Denmark
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
1. L0079 - 2009-08-27
Redistribution and other use of this material requires written permission from The RCP Company.
ITU - MDD - EMF
This presentation describes Eclipse Modeling Framework – EMF. It has two basic
purposes:
Introduce you to the EMF techniques needed in the rest of the course
Introduce you to the architecture and components of the EMF project
This presentation is developed for MDD 2010 course at ITU, Denmark.
2. L0061 - 2008-04-27
2
What is EMF?
A modeling & data integration framework
Exploits the facilities offered in Eclipse to…
Generate code without losing user customizations (merge)
Automate important tasks (such as registering the runtime information)
Improve extensibility
Provide a UI layer
What is an EMF “model”?
Specification of your application’s data
Object attributes
Relationships (associations) between objects
Operations available on each object
Simple constraints (e.g. cardinality) on objects and relationships
Essentially it represents the class diagram of the application
Based on eMOF
Can be used to represent itself – so it is its own meta model!
3. L0061 - 2008-04-27
3
Creating the Ecore Model
Representing the modeled domain in Ecore is the first step in using EMF
Ecore can be created…
Directly using the EMF editors
Through a graphical UI provided by external contributions
By converting a model specification for which a Model Importer is available
Model Importers available in EMF
Java Interfaces
UML models expressed in Rational Rose® files
XML Schema
Choose the one matching your perspective or skills
4. L0061 - 2008-04-27
4
EMF Tools: Model Import and Generation
Generator Features:
Customizable JSP-like templates
(JET)
JDT-integrated, command-line,
or Ant
Fully supports regeneration and
merge
I
M
P
O
R
T
GENERATE
Ecore
Model
UML
XML
Schema
Java
model
Java
edit
Java
editor*
* Eclipse IDE-integrated
or RCP-based
Java
model
5. L0061 - 2008-04-27
5
Model Importers Available in EMF
Annotated Java Interfaces
/**
* @model
*/
public interface Contact {
/**
* Returns the name of the contact.
*
* @return the name
* @model
*/
public String getName();
/**
* Returns the locations of the contact.
* @return a list of the locations
* @model containment="true" opposite="contact"
*/
public EList<Location> getLocations();
}
6. L0061 - 2008-04-27
6
Kick Start EMF
Create “Empty EMF Project”
Create “Ecore Model”
Add “stuff” to the model
Create EMF Model
Edit genmodel file
Generate Java code
Test new model file
7. L0061 - 2008-04-27
7
Kick Start EMF
Edit Files If Needed
Change values using the Properties view
.ecore
Change Ns Prefix to “cm”
Change Ns URI to “http://rcpcompany.com/training/labs/L0061.ecore”
Change Containment to true for all 1:n references
.genmodel
Change Model Name to “CM”
Change Edit/Children and Edit/Create Child to true for all 1:n references
8. L0061 - 2008-04-27
8
Lab Exercise
Create EMF model and an editor for the following model
Optionally type is an enumeration with the values HOME and WORK
The rest of the attributes are Strings
Check that an editor can be created and write a file…
Check in alternative editor
Contact
Manager
0..n
firstName,
familyName
Location
0..n
type, street,
city, country
9. L0061 - 2008-04-27
9
EMF Files
modelname.ecore
Ecore model file in XMI format
Canonical form of the model
modelname.genmodel
A “generator model” for specifying generator options
Contains decorators for Ecore model elements, providing details that would
otherwise pollute the model (e.g. target directories for code generation)
EMF code generator is an EMF .genmodel editor
Automatically kept in synch with .ecore file
11. L0061 - 2008-04-27
11
Ecore Model Editor
A graphical editor is a better approach
GMF Ecore Diagram Example (http://www.eclipse.org/gmf/)
Omondo EclipseUML (http://www.omondo.com/)
UML2 project (http://www.eclipse.org/modeling/mdt/?project=uml2)
12. L0061 - 2008-04-27
12
EMF Generator
Similar layout to Ecore model editor
Automatically keeps in synch with .ecore
changes
Generate code with pop-up menu actions
Generate Model Code
Generate Edit Code
Generate Editor Code
Generate Test Code
Generate All
Code generation options in Properties
view
Generator > Reload to reload .genmodel
and .ecore files from original model
form
13. L0061 - 2008-04-27
13
The EMF Meta Information Model
0..1
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
attributeType
opposite
superTypes
referenceType
14. L0061 - 2008-04-27
14
The EMF Meta Object Model
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
type
opposite
superTypes
15. L0061 - 2008-04-27
15
Ecore Model for Purchase Orders
PurchaseOrder
shipTo : String
billTo : String
Item
productName : String
quantity : int
price : float0..*
items
0..*
EClass
(name="PurchaseOrder")
EAttribute
(name="shipTo")
EAttribute
(name="billTo")
EReference
(name="items")
EClass
(name="Item")
EAttribute
(name="productName")
. . .
eReferenceType
is represented in Ecore as
16. L0061 - 2008-04-27
16
EModelElement
Represents the base class for all other EMF meta entities
Includes annotations, which can save arbitrary data for all objects
documentation, XSD namespace, etc…
all non-core attributes from @model javadoc declarations are recorded as
annotations
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
typ
e
opposite
superTypes
17. L0061 - 2008-04-27
17
ENamedElement
Represents an element with a name (just about everything)
Includes
name – the name of the element
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
typ
e
opposite
superTypes
18. L0061 - 2008-04-27
18
ETypedElement
Represents an element with a type (attribute, reference, operation, parameter)
Includes
type – the type of the object (either EClass or EDataType)
lowerBound, upperBound, many (t) and required (t) – the cardinality of the
element in respect to the type
ordered – the ordering of elements
unique – for multiplicity-many elements, whether elements are unique in the
container
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
typ
e
opposite
superTypes
19. L0061 - 2008-04-27
19
EClassifier
Represents the common functionality for classes and data types
typeParameters – the generic type parameters for the class
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
typ
e
opposite
superTypes
20. L0061 - 2008-04-27
20
EClass
Represents a class with contained attributes and references
abstract – whether the class can be instantiated
interface – whether the implementation class is generated
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
typ
e
opposite
superTypes
21. L0061 - 2008-04-27
21
EDataType
Represents a primitive data type
Many predefined data types
Enumerations
Ecore Data Type
Java Primitive
Type or Class
EBoolean boolean
EChar Char
EFloat Float
EString java.lang.String
EByteArtray byte[ ]
EBooleanObject java.lang.Boolean
EFloatObjhect java.lang.Float
EJavaObject java.lang.Object
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
typ
e
opposite
superTypes
22. L0061 - 2008-04-27
22
EStructuralFeature
Represents a member of a class (attribute or reference)
Includes
transient – whether the value is stored in any external representations
volatile – whether the value is calculated when needed
changeable – whether the value can be changed via a set-method
unsettable – whether the value can be a special null value
derived – whether the value is derived from other attributes
defaultValue – any default value
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
typ
e
opposite
superTypes
23. L0061 - 2008-04-27
23
EAttribute
Represents an attribute of a class
id – whether the attribute is an ID in the class – the first ID attribute is special
IDs are used for references in external representations – e.g. XML
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
typ
e
opposite
superTypes
24. L0061 - 2008-04-27
24
EReference
Represents a reference to a class
opposite – the opposite relation
resolveProxies – whether references are resolved automatically
containment, container (t) – whether the reference is contained in/a container
for the opposite object
ENamedElement
EModelElement
0..1
ETypedElementEClassifier
EStructuralFeature
EAttribute
EReference
EClass
EDataType
0..*
0..*
0..*
typ
e
opposite
superTypes
25. L0061 - 2008-04-27
25
Generated Code
Code is generated using JET – Java Emitter Templates
Based on PHP-like or JSP-like language (.javajet files)
Consult plug-ins org.eclipse.emf.codegen.*
Many @model attributes change the generated code
Especially on EStructualFeature, EAttribute and EReference
26. L0061 - 2008-04-27
26
Generated Code
Overriding Methods
There are several ways to override generated code
All generated code annotated with @generated javadoc
If code is changed, change the comment to @generated NOT
Add Gen suffix to original method name to original code with custom code
Methods without @generated marker are left alone during regeneration
/**
* @generated NOT
*/
public void setName(String newName) {
assert newName != null;
setNameGen(newName);
}
/**
* @generated
*/
public void setNameGen(String newName) {
…
}
/**
* @generated
*/
public void setName(String newName) {
…
}
27. L0061 - 2008-04-27
27
Generated Code
Simple Attributes
Simple attributes hold no surprises
Notification constructed when needed
Attribute identified by ID
public String getName() {
return name;
}
public void setName(String newName) {
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
ContactPackage.LOCATION__NAME, oldName, name));
}
/**
* @model
*/
public String getName();
28. L0061 - 2008-04-27
28
Generated Code
Multi-Valued Attributes and References
Different than the “normal” Java design pattern
Only one method per attribute or reference
public List<Location> getLocations();
public void addLocation(Location location);
public void removeLocation(Location location);
public void clearLocations();
public EList<Location> getLocations();
contact.addLocation(location); contact.getLocations().add(location);
29. L0061 - 2008-04-27
29
Generated Code
Volatile Attributes and References
Volatile attributes and references get (near-)empty bodies
/**
* @generated
*/
public String getSurname() {
throw new UnsupportedOperationException();
}
30. L0061 - 2008-04-27
30
Lab Exercise
Use previous model
Add new read-only attribute in Contact named fullName:
Returns “<firstName> <familyName>”
Remember to make it transient – why?
Check result in editor: correct and read-only
Extra: make the attribute changeable
31. L0061 - 2008-04-27
31
Model Change Notification
Every EMF object is also a Notifier
Send notification (Notification) whenever an attribute or reference is changed
EMF objects can be “observed” in order to update views and dependent objects
For various reasons a model change listener is also called an adaptor
Adapter poObserver = ...
purchaseOrder.eAdapters().add(poObserver);
adapter.notifyChanged()
setBillTo()
PurchaseOrder
Adapter
32. L0061 - 2008-04-27
32
Persistence and Serialization
Serialized data is referred to as a resource
Data can be spread out among a number
of resources in a resource set
One resource is loaded at a time, even if it
has references to objects in other
resources in the resource set
Proxies exist for objects in other
resources
Lazy or demand loading of other
resources as needed
A resource can be unloaded
Resource 2Resource 1
ResourceSet
Client
load
demand-load
resource 2
resource 1 uri 1 resource 1
uri 2 resource 2
33. L0061 - 2008-04-27
33
Recording Changes
EMF provides facilities for recording the changes made to instances of an Ecore model
Change Model
An EMF model for representing changes to objects
Directly references affected objects
Includes “apply changes” capability
Change Recorder
EMF adapter
Monitors objects to produce a change description (an instance of the change
model)
34. L0061 - 2008-04-27
34
Change Recorder
Can be attached to EObjects, Resources, and ResourceSets
Monitors changes to the objects and their contents trees
Produces a description of the changes needed to return to the original state (a reverse
delta)
Result: a change description with one change, setting billTo to “123 Elm St.”
PurchaseOrder order = ...
order.setBillTo("123 Elm St.");
ChangeRecorder recorder = new ChangeRecorder();
recorder.beginRecording(Collections.singleton(order));
order.setBillTo("456 Cherry St.");
ChangeDescription change = recorder.endRecording();
35. L0061 - 2008-04-27
35
Example: Transaction Capability
If any part of the transaction fails, undo the changes
ChangeRecorder changeRecorder = new ChangeRecorder(resourceSet);
try {
// modifications within resource set
} catch (Exception e) {
changeRecorder.endRecording().apply();
}
36. L0061 - 2008-04-27
36
What does the Transaction API Provide?
A transactional editing environment
Safe read and write access to EMF resources from multiple concurrent threads
Commit protocol providing mechanisms for ensuring model integrity:
Validation of the changes performed during the transaction (constraints) using
the Validation Framework
Pre-commit listeners proactively performing concomitant changes (triggers) to
maintain consistency of dependencies
Automatic rollback of changes on failure to validate or complete triggers
Supports transaction nesting
37. L0061 - 2008-04-27
37
Validation Framework
Model objects validated by external EValidator
Detailed results accumulated as Diagnostics
Essentially a non-Eclipse equivalent to IStatus
Records severity, source plug-in ID, status code, message, other arbitrary data,
and nested children
public interface Evalidator {
Boolean validate(EObject eObject,
DiagnosticChain diagnostics, Map Context);
boolean validate(EClass eClass, EOjbect eObject,
DiagnosticChain, diagnostics, Map context);
boolean validate(EDataType eDataType, Object value,
DiagnosticChain diagnostics, Map context);
...
}
38. L0079 - 2009-08-27
38
Question/Exercise 1
Implement the data model for Noware Travel as an ecore model in EMF
Take care that the model can be validated by the built-in tools of EMF
Which relations are containment relations?
In a real-world scenario, which attributes should be strings, enumerations or relations
to other entities – e.g. Parameter name, Flight destinationTown and Item name.
39. L0079 - 2009-08-27
39
Question/Exercise 2
Generate an EMF editor from the .ecore model
Implement the travel packages from previous lecture
Question 2: Model an “adventure” travel package to Thailand, which includes either
a trekking tour or a parachute tour. Model a “family” travel to Gran Canaria, which
includes renting a car. For each package, also what data is required for ordering
the package
Question 3: The family Hansen wants a Family travel package to Gran Canaria.
Draw the instance of the Family package with data for the Hansen family. For
instance, we need to know how many persons they are to order the right size of a
hotel room. This information is not present in the model from question 2. In the
model, we only described what data was required for model instances. The real
customer must provide the real data.
40. L0079 - 2009-08-27
40
Question/Exercise 3
Given your EMF model, informally describe the types of validation that can/should be
performed on a concrete instance of a family travel in the form “this attribute should
be equal to this attribute” and “this object should only have n children”…
41. L0087 - 2010-09-19
41
Syllabus (”Pensum”)
The reading materials for this lecture is in the form of the following three items:
These slides
"Essential EMF" by Ed Merks and James Sugrue -
http://refcardz.dzone.com/refcardz/essential-emf(direct link) - Very good and
quite essential overview of EMF
"Eclipse Modeling Framework (EMF) - Tutorial" by Lars Vogel - http://
www.vogella.de/articles/EclipseEMF/article.html - as always, a good tutorial by Lars
42. L0061 - 2008-04-27
42
More Information
“EMF – Eclipse Modeling Framework” by Frank Budinsky, David Steinberg, Ed Merks,
and Raymond Ellersick (ISBN 978- 0321331885)
“Eclipse Modeling Framework (EMF) and Java Emitter Template (JET) - Tutorial”
http://www.eclipse.org/resources/resource.php?id=419
Very good introduction JET – as well as a very short introduction to EMF itself.
“EMF – Eclipse Modeling Framework” by Frank Budinsky, David Steinberg, Ed Merks,
and Raymond Ellersick (ISBN 978- 0321331885)
“Eclipse Modeling Framework (EMF) and Java Emitter Template (JET) - Tutorial”
http://www.eclipse.org/resources/resource.php?id=419
Very good introduction JET – as well as a very short introduction to EMF itself.
Editor's Notes
Now it’s time for the lab.
Class models classes themselves. Classes are identified by name and can have a number of attributes and references. To support inheritance, a class can refer to a number of other classes as its supertypes.
Attribute models attributes, the components of an object&apos;s data. They are identified by name, and they have a type.
DataType models the types of attributes, representing primitive and object data types that are defined in Java, but not in EMF. Data types are also identified by name.
Reference is used in modeling associations between classes; it models one end of such an association. Like attributes, references are identified by name and have a type. However, this type must be the Class at the other end of the association. If the association is navigable in the opposite direction, there will be another corresponding reference. A reference specifies lower and upper bounds on its multiplicity. Finally, a reference can be used to represent a stronger type of association, called containment; the reference specifies whether to enforce containment semantics.
The complete EMF data model for a specific domain model (your model!) is normally always presents and can be queried to get relevant meta information.
The model includes the following objects:
EModelElement is the base class for all model classes. Includes support for annotations.
ENamedElement specifies an element with a name – typically unique within the scope (e.g. attributes within a class).
ETypedElement specifies an element with a type (either primitive – see EDataType – or a class – see EClass). Includes cardinality (lowerbound, upperbound), ordering and uniqueness.
EStructuralFeature specifies a member of a class – either an attribute or a reference.
EClassifier represents a type in the model – either a class or a data type