Post on 19-Jan-2016
description
transcript
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
1
Model-Driven Development for Pluggable Collaborations
Iris Groher, Stephan Bleicher, Christa Schwanninger
SIEMENS
CT SE 2
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
2
Contents
• Aspectual Collaborations
• UML for Aspects (UFA)
• Standard UML for Aspects (sUFA)
• Model-Driven Development Framework• openArchitectureWare
• Binding Generation Process
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
3
Aspectual Collaborations
• New programming model that supports the encapsulation of crosscutting concerns
• Modular implementation of multiple collaborating types independent of the system they will be applied to
• A collaboration interface specifies the abstractions (types) that together form the component• Serves as the interface between its implementation and its mapping to a
base application• Interface states which properties and services are provided by the
component and which ones are expected from the system (base application) it will be applied to
• Can have several distinct implementations
• The mapping to a base application is specified in a so-called binding• Composition of binding and implementation using mixin-composition• Explicit deployment
• Supported by the aspect-oriented programming languages CaesarJ and ObjectTeams
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
4
Aspectual Collaborations (2)
Component A
A B
C D
Component B
E F
G
… modularization of „crosscutting concerns“ and beyond that …
… focus on component integration by means of aspect-oriented concepts.
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
5
ObserverProtocolImpl
Observer
Subject
CompositionObserverProtocol
add (Observer)remove(Observer)
Subject
notify()
start(Subject)stop(Subject)
Observer
update(Subject)
collaboration interface
refinement & bindings with mixin-in inheritance
generic component
component binding
concrete componentLibraryObserver
BookCopy
BookManager
ObserveLibrary
BookCopySubject
BookManagerObserver
Subject
Observer
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
6
UML for Aspects (UFA)
• Modeling language for aspect-oriented design that strongly supports the concept of Aspectual Collaborations
• The notation extends UML packages to encapsulate complex structures (either component or base application)
• Three kinds of packages• Base package for base application• Abstract package for Aspectual Collaboration• Connector package for binding
• The classes inside the connector package are enhanced UML classes and support the adaptation of the abstract collaboration to a certain application
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
7
UML for Aspects (2)
Aspectual Collaboration needing refinement before use
Ordinary package (base application)
Package refinement/specialization
Directed adaptation relation: Observer may use and influence Library
Package connecting the independent packages Observer and Library
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
8
Connector Package
notify ← after {borrowCopy, returnCopy}
Subject = BookCopy
update → updateStatus start ← after buy stop ← after drop
Observer = BookManager
Mapping of role Subject to class BookCopy
Callin: After methods borrowCopy() and returnCopy() of class BookCopy, the method notify() of class Subject is called
Mapping of role Observer to class BookManager
Callout: The abstract method update() of class Observer delegates to method updateStatus() of class BookManager
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
9
Standard UML for Aspects
• Standard UML compliant using stereotypes
• Supports all UFA concepts
• Models can be developed using commercial UML modeling tools
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
10
CaesarJ Binding Codeabstract public cclass ObserveLibrary extends ObserverProtocol {
public cclass Subject wraps BookCopy { public BookCopy getWrappee() { return wrappee; }}
public cclass Observer wraps BookManager { public void update(SubjectRole s) { wrappee.updateStatus(s.getWrappee()); }}
after(BookCopy bc):(call(public void borrowCopy()) || call(public void returnCopy())) && target(bc) { Subject(bc).notify();}
after(BookManager bm, BookCopy bc): (call(public void buy(BookCopy)) && target(bm) && args(bc) { Observer(bm).start(Subject(bc));}
after(BookManager bm, BookCopy bc): (call(public void drop(BookCopy)) && target(bm) && args(bc) { Observer(bm).stop(Subject(bc));}
}
• Implementation of binding code straightforward all necessary information already contained in model
• Error prone• Necessary for the component composer to
be familiar with CaesarJ / ObjectTeams
Generate code automatically from model
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
11
openArchitectureWare
• Open source MDD generator framework integrated into eclipse• Supports arbitrary input formats and output formats• Own metamodels can be implemented in Java
ParserMetamodelInstantiator
CodeGenerator
MetamodelInstances
Generator Framework
GeneratedCode
TemplatesInputModel
MetamodelClasses
• A metamodel of the domain has to be defined and implemented as Java classes• Templates specify the output (e.g. code)• A model has to be created (an instance of the metamodel) which can be done using for
example UML tools, textual languages or XML• The generator parses the respective model and builds a syntax tree in memory by
instantiating the metaclasses• The generator then navigates through the syntax tree and performs the actions described in
the templates
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
12
Binding Generation Process
XMI-Model
Source Code
XML-Model
Transformation
oAWGenerator
Code Generation
sUFAModel
Modeling
ModelingTool
XMI-Export
Validation
1. Modeling with standard UML tool using the sUFA notation
2. XMI export of the model (input to the generator tool chain)
3. Automatic transformation of the XMI model to a defined XML format
4. Validation of the model
5. Generation of CaesarJ / ObjectTeams binding code
1
2
3
4
5
© Siemens AG, CT SE 2
C O
R P
O R
A T
E
T E
C H
N O
L O
G Y
13
Thanks for your attention!