Notes
Slide Show
Outline
1
Eclipse UML2 Project
  • Technology Exchange


  • EMF Technology in Practice
2
Contents
  • What is UML2?


  • EMF Customizations


  • Element Identification


  • Element Creation


  • Element Destruction


  • Element Retrieval


  • Element Validation
3
What is UML2?
  • An Eclipse Modeling Development Tools subcomponent at http://www.eclipse.org/modeling/mdt/?project=uml2#uml2


  • An EMF-based implementation of the UML™ 2.0 metamodel for the Eclipse platform


  • Objectives are to provide…
    • a useable implementation of the metamodel to support the development of modeling tools
    • a common XMI schema to facilitate interchange of semantic models
    • test cases as a means of validating the specification
    • validation rules as a means of defining and enforcing levels of compliance
4
EMF Customizations
  • XMI resource to support identification of elements using Universally Unique Identifiers (UUIDs)


  • JET templates to generate methods that facilitate element creation, destruction, and retrieval


  • Switch classes to perform element validation operations
5
Element Identification
  • Needed a way to uniquely identify elements across resources


  • Wanted to minimize the impact on disk and memory footprint


  • Implemented a custom XMI resource (Uml2ResourceImpl) to assign and manage UUIDs generated in base 64 format…
    • overrode ResourceImpl#getEObjectByID(String) to retrieve objects from idToEObectMap
    • overrode XMLResourceImpl#getID(EObject) to assign (and reassign) automatically generated UUIDs
    • overrode ResourceImpl#detached(EObject) to preserve IDs when objects (and their children) are detached from resources
6
Overriding ResourceImpl#getEObjectByID(String)
7
Overriding XMLResourceImpl#getID(EObject)
8
Overriding ResourceImpl#detached(EObject)
9
Element Identification Example
10
Element Creation
  • Wanted to simplify the process of creating an element and adding/setting it to a containment feature


  • Customized JET templates to generate convenient factory methods
    • customized Interface.javajet to generate method declaration
    • customized Class.javajet to generate method implementation
11
Customizing Interface.javajet (Lists)
12
Customizing Interface.javajet (non-Lists)
13
Customizing Class.javajet (Lists)
14
Customizing Class.javajet (non-Lists)
15
Element Creation Example
16
Element Destruction
  • Wanted a way to delete an element, including all of its children and all cross references to it


  • Customized JET templates to generate destroy() method for top-level types
    • customized Interface.javajet to generate method declaration
    • customized Class.javajet to generate method implementation
17
Customizing Interface.javajet
18
Customizing Class.javajet
19
Implementing destroyHelper(...)
20
Element Destruction Example
21
Element Retrieval
  • Wanted to simplify the process of retrieving named elements from lists


  • Customized JET templates to generate convenient factory methods
    • customized Interface.javajet to generate method declaration
    • customized Class.javajet to generate method implementation
22
Customizing Interface.javajet
23
Customizing Class.javajet
24
Element Retrieval Example
25
Element Validation
  • Wanted a way to perform validation operations on elements


  • Wanted to be able to evaluate different sets of constraints


  • Implemented custom Switch subclasses to execute validation rules
    • implemented validate(EObject, IProgressMonitor) to invoke the switch and return an outcome in the form of a status object
    • overrode Uml2Switch#defaultCase(EObject) to recursively invoke the switch on the object’s contents
    • overrode Uml2Switch#doSwitch(EObject) to inform the progress monitor of progress
    • overrode Uml2Switch#case*(*) for each type of element to which constraints apply
26
Implementing validate(...)
27
Overriding Uml2Switch#defaultCase(EObject)
28
Overriding Uml2Switch#doSwitch(EObject)
29
Overriding Uml2Switch#caseElement(Element)
30
Element Validation - Example