From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

31
[email protected] Department of Telecooperation Johannes Kepler University Linz Altenberger Straße 69 4040 Linz, Austria From UML Profiles to EMF Profiles and Beyond 49th International Conference on Objects, Models, Components and Patterns Zurich, Switzerland, 29 June 2011 Philip Langer, Konrad Wieland, Manuel Wimmer, and Jordi Cabot Philip Langer

Transcript of From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Page 1: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

[email protected] of TelecooperationJohannes Kepler University LinzAltenberger Straße 694040 Linz, Austria

From UML Profiles to EMF Profiles and Beyond

49th International Conference on Objects, Models, Components and PatternsZurich, Switzerland, 29 June 2011

Philip Langer, Konrad Wieland, Manuel Wimmer, and Jordi Cabot

Philip Langer

Page 2: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Overall Goal of This Work

2

UML Profiles: A Short Introduction Lightweight Language Extension Mechanism of the UML A Profile consists of Stereotypes Stereotypes extend base classes

And may introduce “tagged values”

Profiles are applied to UML models By applying stereotypes to instances of their base classes Specifying concrete values for their defined “tagged values”

“Adopt the notion of UML Profiles to DSMLs residing in EMF”

Page 3: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

UML Profiles: A Short Introduction

3

Profile specification

Profile application

«profile» EJB

«enumeration»StateKind

statelessstateful

UserModel

«apply»

«SessionBean»Customer state=stateless

Component«stereotype»

Bean

«stereotype»EntityBean

«stereotype»SessionBean

state: StateKind

«metaclass»

Page 4: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Motivation

Overall goal “Adopt the notion of UML Profiles to DSMLs residing in EMF”

Is combination of profiles with DSMLs a contradiction? Many debates on Pros and Cons of adopting UML Profiles or DSMLs

4

Page 5: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

UML Profiles vs DSMLs

5

Reuse UML’s language concepts and existing UML editors!

Create a lean language that is straight to the point!

You’ll end up with an overloaded and imprecise language!

You’ll have to create the whole infrastructure by yourself!

Page 6: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

UML Profiles vs DSMLs

6

These debates concern adopting eitherUML Profiles or DSMLs

for creating new languages.

What aboutextending existing languages?

It’s your language…just extend your metamodel.

Page 7: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Motivating Scenario

7

Data Modeling Language

Metamodel

ConcreteSyntax Editor

… generates Ruby on Rails.

… generates JavaServer Faces.

… generates DB Schema.

I want to additionally specify“Finder SQL” statements!

I want to additionally specifythe bean scope!

Leave it as it is!If you introduce every

imaginable feature that I don’t need, I could have used

UML in the first place.

Page 8: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Motivating Scenario

8

Data Modeling Language

Metamodel

ConcreteSyntax Editor

… generates Ruby on Rails.

… generates JavaServer Faces.

… generates DB Schema.

I want to additionally specify“Finder SQL” statements!

I want to additionally specifythe bean scope!

Leave it as it is!If you introduce every

imaginable feature that I don’t need, I could have used

UML in the first place.

You need a lightweightextension mechanism: Profiles!

Other scenarios- No influence on the metamodel- “Concern-specific” annotations

I can’t address all your requirements!

Page 9: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Benefits of Profiles for DSMLs

Lightweight language extension Introduce additional features No need for changing the metamodel and the modeling infrastructure

Dynamic model extension Existing models can be extended; even by multiple profiles and stereotypes Profile applications are separated from the models ( no model pollution)

Preventing metamodel pollution Metamodels represent only information coming from the modeling domain Concern-specific information is defined in a profile

Model-based representation Profile applications are well-defined ( they can be validated) Profile applications are just additional models ( reuse existing frameworks)

9

Page 10: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

The Challenge

10

Okay, so let’s use profiles!

But wait, that’s not so easy with EMF!

M3

UMLCore Profiles

«import»

M2

M1

UML aProfile

«instanceOf» «instanceOf»

«instanceOf» «instanceOf»

aUMLModel

aProfileApplication

«extend»

«extend»

EMF

Ecore

Profile MM

«instanceOf»

aProfile

«instanceOf»

aProfileApplication

«instanceOf»

Page 11: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

A Solution*: Metalevel Lifting by Inheritance

11* In the paper, we discuss an alternative solution as well.

M3

M2

M1

Profile Definition Metalevel Liftingby Inheritance

Ecore

Profile MM

«instanceOf »

aProfile

«instanceOf »

Page 12: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

A Solution*: Metalevel Lifting by Inheritance

12* In the paper, we discuss an alternative solution as well.

M3

M2

M1

Profile Definition Metalevel Liftingby Inheritance

Ecore

Profile MM

«instanceOf »

aProfile

«instanceOf »

«inheritsFrom»

Page 13: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

A Solution*: Metalevel Lifting by Inheritance

13* In the paper, we discuss an alternative solution as well.

M3

M2

M1

Profile Definition Metalevel Liftingby Inheritance

Ecore

Profile MM

«instanceOf »

aProfile

«instanceOf »

aProfileApplication

«inheritsFrom»

«instanceOf »

Page 14: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

EMF Profile Metamodel

14

Prof ile

iconPath : EStringStereotype

Prof ile

Ecore

abstract: EBooleaneSuperTypes : EClass…

EClassnsURI : EStringeClassif iers : EClassif ier…

EPackage

base

1

base

0..*

Standard EMF Profile

Prof ileApplication

Prof ileApplication

0..*

appliedTo : EObjectStereotypeApplication

stereotypeApplications

«import»

Page 15: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

EMF Profile Metamodel and its Instantiation

15

Prof ile

iconPath : EStringStereotype

Prof ile

Ecore

abstract: EBooleaneSuperTypes : EClass…

EClassnsURI : EStringeClassif iers : EClassif ier…

EPackage

base

1

base

0..*

Standard EMF Profile

Prof ileApplication

Prof ileApplication

0..*

appliedTo : EObjectStereotypeApplication

: Stereotype : EAttribute

name=“isStateful”

eAttributes

A Profile Specification

: Profile eClassifiers

: EClassbase

name=“Entity”

stereotypeApplications

name=“SessionBean”

«import»

Page 16: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

EMF Profile Metamodel and its Instantiation

16

Prof ile

iconPath : EStringStereotype

Prof ile

Ecore

abstract: EBooleaneSuperTypes : EClass…

EClassnsURI : EStringeClassif iers : EClassif ier…

EPackage

base

1

base

0..*

Standard EMF Profile

Prof ileApplication

Prof ileApplication

0..*

appliedTo : EObjectStereotypeApplication

: Stereotype : EAttribute

name=“isStateful”

eAttributes

A Profile Specification eSuperTypes

name=“SessionBean”

«onSave»

: Profile eClassifiers

: EClassbase

name=“Entity”

stereotypeApplications

«import»

Page 17: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

17

EMF Profile Metamodel and its Instantiation

Prof ile

iconPath : EStringStereotype

Prof ile

Ecore

abstract: EBooleaneSuperTypes : EClass…

EClassnsURI : EStringeClassif iers : EClassif ier…

EPackage

base

1

base

0..*

Standard EMF Profile

Prof ileApplication

Prof ileApplication

0..*

appliedTo : EObjectStereotypeApplication

: Profile: Stereotype : EAttribute

name=“isStateful”

eClassifierseAttributes

A Profile Specification eSuperTypes

name=“SessionBean”: EClassbase

A Profile Application: ProfileApplication: SessionBean

name=“Entity”

: EntityappliedTo

stereotypeApplications

stereotypeApplicationsisStateful=true

«instanceOf» «instanceOf»

«instanceOf»

«import»

«instanceOf» «instanceOf»

«instanceOf»

Page 18: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

18

EMF Profile Metamodel and its Instantiation

Prof ile

iconPath : EStringStereotype

Prof ile

Ecore

abstract: EBooleaneSuperTypes : EClass…

EClassnsURI : EStringeClassif iers : EClassif ier…

EPackage

base

1

base

0..*

Standard EMF Profile

Prof ileApplication

Prof ileApplication

0..*

appliedTo : EObjectStereotypeApplication

: Profile: Stereotype : EAttribute

name=“isStateful”

eClassifierseAttributes

A Profile Specification eSuperTypes

name=“SessionBean”: EClassbase

A Profile Application: ProfileApplication: SessionBean

name=“Entity”

: EntityappliedTo

stereotypeApplications

stereotypeApplicationsisStateful=true

«instanceOf» «instanceOf»

«instanceOf»

«import»

«instanceOf»

M3 M3 M2

M2

M2

M1 M1

«instanceOf»

«instanceOf»

M1

Page 19: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

19

EMF Profile Metamodel and its Instantiation

Prof ile

iconPath : EStringStereotype

Prof ile

Ecore

abstract: EBooleaneSuperTypes : EClass…

EClassnsURI : EStringeClassif iers : EClassif ier…

EPackage

base

1

base

0..*

Standard EMF Profile

Prof ileApplication

Prof ileApplication

0..*

appliedTo : EObjectStereotypeApplication

: Profile: Stereotype : EAttribute

name=“isStateful”

eClassifierseAttributes

A Profile Specification eSuperTypes

name=“SessionBean”: EClassbase

A Profile Application: ProfileApplication: SessionBean

name=“Entity”

: EntityappliedTo

stereotypeApplications

stereotypeApplicationsisStateful=true

«instanceOf» «instanceOf»

«instanceOf»

«import»

«instanceOf»

M3 M3 M2

M2

M2

M1 M1

M1/2

M2/3

«instanceOf»

«instanceOf»

M1

Page 20: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Example: EJB Profile Specification

20

Page 21: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Example: EJB Profile Application

21

Page 22: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

From UML Profiles to EMF Profiles and Beyond

UML Profiles can be specified for UML only No need for further reuse of profiles for other languages

EMF Profiles can be specified for every Ecore-based language Reuse a profile for more than one language

Generic Profiles Reuse a profile for several “user-selected” DSMLs

Meta Profiles Reuse a profile for all DSMLs

22

Page 23: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Generic Profiles

Reuse a profile for several “user-selected” DSMLs Extend generic types instead of concrete types Bind generic types to concrete types to apply a profile Use OCL to further restrict valid bindings

23

name : EString

«generictype»Container

«stereotype»EntityBean

isUserManaged : EBoolean

«stereotype»IDAttribute

«stereotype»SessionBean

isStateful : EBoolean

«generictype»Property

<<prof ile>> EJBContainer, Property

ER

«bind» <Container->Entity, Property->Attribute> Entity Attribute0..*

name : String name : String

ER

Entity Attribute0..*

name : String name : String

ER

Entity Attribute0..*

name : String name : String

Page 24: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Meta Profiles

24

Reuse a profile for all DSMLs (at once) Each “Meta Stereotype” may be applied to every base type Useful for general annotations

E.g., Model Review Profile

«meta-stereotype»ReviewDecision

reviewer: EStringreviewDate. EDate

Met

apro

file

«meta-prof ile» ModelReview

«meta-metaclass»EClass

«meta-stereotype»Declined

reason: EString

«meta-stereotype»Approved

«meta-stereotype» Rework

assignedTo: EStringreason: EString

Page 25: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Meta Profiles

25

Reuse a profile for all DSMLs (at once) Each “Meta Stereotype” may be applied to every base type Useful for general annotations

E.g., Model Review Profile

Application to a simplified Event-driven Process Chain Model

: Approvedreviewer : "Homer"reviewDate : 23/06

: Eventname : "order received"

: Functionname : "check order"

: LogicalConnectortype : OR

: Reworkreviewer : "Homer" assignedTo: "Bart"reason : "Change to XOR"

appliedToappliedTo

BaseModel

«meta-stereotype»ReviewDecision

reviewer: EStringreviewDate. EDate

Met

apro

file

«meta-prof ile» ModelReview

«meta-metaclass»EClass

«meta-stereotype»Declined

reason: EString

«meta-stereotype»Approved

«meta-stereotype» Rework

assignedTo: EStringreason: EString

Application to a simplified Use Case Diagram

: Approvedreviewer : "Homer"reviewDate : 23/06

: UseCasename : "Order Goods"

: Include : UseCasename : "Cancel Order"

: Declinedreviewer : "Homer"reason : "Dough! Every order gets canceled?"

appliedTo appliedTo

BaseModel

Page 26: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Implementation

Based on the Eclipse Modeling Framework Supports extending every Ecore-based DSML Uses the Decoration Service to show icons in GMF editors

Open Source (EPL 1.0) http://code.google.com/a/eclipselabs.org/p/emf-profiles/

Try EMF Profiles! Eclipse Update Site

http://www.modelversioning.org/emf-profiles-updatesite/

Contact us and get involved! http://groups.google.com/group/emf-profiles

26

Page 27: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Thank Your for Your Attention!

END

Thanks for listening!

Have you any questions?

Aw, these kids nowadays…

All graphics of characters of “The Simpsons” are downloaded from http://www.simpsoncrazy.com

Page 28: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Backup Slides

28

Page 29: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Related Work

Weaving Models Powerful mechanism for annotating models However, they are counter-intuitive and not intended to be used by “users” Not possible to annotate models in concrete syntax

Kolovos et al.: Model Decorations Additional information is saved in GMF’s notes (text fragments) Transformations to inject and extract models from these text notes Only supports annotating GMF Forces users to create hand-crafted transformations Users have no feedback whether the text in notes is valid

Bruneliere et al: EMF Facet Allows to define additional derived classes and features Derived information is transient Complementary to EMF Profiles we plan to integrate EMF Profiles to EMF Facet

Clark et al: Meta packages Allows to extend the language XCore EMF Profiles is more generic because any Ecore-based language can be extended

29

Page 30: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Design Alternatives

30

M3

M2

M1

(a) Metalevel Liftingby Transformation

aProfile as MM

Profile Definition (b) Metalevel Liftingby Inheritance

Ecore«instanceOf»

«instanceOf»

Profile MM

«instanceOf»

aProfile

«transformedTo»

«instanceOf»

aProfileApplication

aProfileApplication

«inheritsFrom»

«instanceOf»

Page 31: From UML Profiles to EMF Profiles and Beyond (TOOLS'11)

Complete Profile Metamodel

31

Prof ile

iconPath : EStringStereotype

Prof ile

Ecore

abstract: EBooleaneSuperTypes : EClass…

EClassnsURI : EStringeClassif iers : EClassif ier…

EPackage

base

1

base

0..*

Standard EMF Profile

Generic Profile Meta Profile

isMeta : EBooleanStereotype

EClass

GenericType

<<merge>> <<merge>>

Complete EMF Profile <<merge>><<merge>>

expr : OCLExpressionCondition

0..*isMeta : EBoolean

Prof ile

Prof ileApplication

Prof ileApplication

0..*

appliedTo : EObjectStereotypeApplication