Title: Model Compiler Construction Based on Aspectoriented Mechanisms
1Model Compiler Construction Based on
Aspect-oriented Mechanisms
GPCE 2005Generative Programming and Component
Engineering
- Naoyasu Ubayashi (Kyushu Institute of
Technology) - Tetsuo Tamai (University of Tokyo)
- Shinji Sano, Yusaku Maeno, Satoshi Murakami
(Kyushu Institute of Technology) - 29 September 2005
2Overview
- Motivation
- AspectM
- Model compiler construction using AspectM
- Discussion
- Related work
- Conclusion
31. Motivation
4Issues to be tackled
- Model-based development is a software development
method in which models are created before source
code is written. - Although the method is effective, we have to
modify models when we face evolution such as
change of platforms. - These modifications crosscut over many places in
the models, and tend to cause unexpected errors.
New platforms
New requirements
Optimization
Multiple concerns!
5How does MDA deal with this problem ?
OOSD
MDA
CIM
Analysis
PIM
Design
model compiler
PSM
We can regard PIMs as new kinds of reusable
software components because they can be reused
even if a platform is changed.
Coding
Source code
MDA Model-Driven Architecture PIM Platform
Independent Model CIM Computation Independent
Model PSM Platform Specific Model
6But,
Multiple concerns
- Although MDA is effective for software
development, it mainly focuses on
platform-specific concerns. - We have to modify models when we face evolution
related to other kinds of concerns including
application-specific optimization, security
policies, and deployment. - It is necessary to allow a modeler to customize
transformation rules because model modifications
for dealing with these concerns may be specific
to an application.
Extensibility
7Motivating example -- A simple bulletin board
system
8Example
application-specific
Platform Concern
Optimization Concern
Logging Concern
Original
logging
delete
modifications crosscut over many places
logging
make a product that is executable on the Struts
platform
optimize memory usage
add a logging function for debugging
9Our Approach
- We propose a method for constructing an
extensible model compiler based on
aspect-orientation. - Aspect-orientation is useful for platform
descriptions because they crosscut over many
model elements. - A modeler can extend model transformation rules
by defining new aspects in the process of
modeling.
Aspect
AspectM
Aspect
weave
UML model
UML model
UML model
UML model
PIM
PSM
Extensible model compiler
102. AspectM
11Aspect orientation
AOP is based on the JPM (Join Point Model).
Join point
program execution points including method
invocations and field access points
Pointcut
a means of extracting a set of join points
related to a specific crosscutting concern from
all join points
Advice
a means of raising effects at the join points
12Aspect orientationat the modeling-level (example)
join point (class)
pointcut
advice
classA
classA classB (extract join point whose name
is classA or classB)
add new attributes add new operations
attributes new attributes
classA
attributes
operations new operations
operations
classB
classB
attributes
join point (class)
attributes new attributes
operations
operations new operations
classC
join point (class)
attributes
operations
Extension of JPMs (Join Point Models) in AOP
13JPMs for model transformations
PA(pointcut advice),CM(composition),NE(new
element),OC(open class),RN(rename),RL(relation)
14AspectM
- AspectM is an aspect-oriented modeling language
that supports six kinds of JPMs. - In AspectM, an aspect can be described in either
a diagram or an XML format. - AspectM provides the two kinds of aspects
ordinary aspect and component aspect. A component
aspect is a special aspect for composing aspects. - An aspect can have parameters for supporting
generic facilities. By filling parameters, an
aspect for a specific purpose is generated.
15Example of AspectM descriptions
pointcut classA classB
aspect
advice
ltlt OC gtgt addAttributeX
classA
classA
add new attributes
new attributes
classB
classeAandB class pointcut-bodycname(cla
ssA) cname(classB)
classC
classB
new attributes
merge classAandB add-attribute
advice-bodyattributeX
ltaspect nameaddAttributeX typeordinary
jpmOC" gt ltpointcut nameclasseAandB
typeclassgt ltpointcut-bodygt cname(classA)
cname(classB) lt/pointcut-bodygt lt/pointcutgt
ltadvice nameadd-attributeX typeadd-attribute
ref-pointcutclassAandBgt ltadvice-bodygt
attributeX lt/advice-bodygt lt/advicegt lt/aspectgt
16AspectM Tools
Model Editor (Eclipse UML)
Model Compiler
UML diagrams
XMI (PIM)
Aspect diagrams
XMI
XSLT style sheet
XMI (PSM)
AspectM metamodel
XSLT style sheet
(EMF)
Java code
17AspectM metamodel
18Implementation of model compiler
Aspect diagram (XML)
Model Compiler
XSLT style sheet for converting aspect (XML) to
XSLT style sheet
XSLT processor
The first transformation phase
XSLT style sheet for converting UML (XML)
to UML (XML)
XSLT processor (Weaver)
The second transformation phase
UML diagram (XML)
UML diagram (XML)
193. Model compiler construction using AspectM
20Application-specific model compiler
UML model
UML model
Aspect
Aspect
Aspect
Aspect
Aspect
Aspect
Weaver (XSLT processor)
UML model
Extended application-specific model compiler
UML model
21Example
application-specific
Platform Concern
Optimization Concern
Logging Concern
Original
logging
delete
logging
make a product that is executable on the Struts
platform
optimize memory usage
add a logging function for debugging
22Aspect for platform concern
Platform Struts
Step1 merge PIMs
aspect
1) merge PIM classes
ltlt CM gtgt MergeClasses
Step 2 transform the merged class to an action
form bean class
inputClasses class pointcut-bodycname(Me
ssage) cname(MessageProfile)
2) change the name of merged class 3)
inherit ActionForm 4) add setter/getter
merge inputClasses merge-by-name
advice-bodyPostMessage
23Component, Generics
component
ltaspect name"Generic-Classes2ActionFormBean"
type"component"gt ltparamsgt ltparamgt
_at_input-classes_at_ lt/paramgt ltparamgt
_at_merged-class_at_ lt/paramgt lt/paramsgt ltaspect
name"MergeClasses" template"Generic-MergeClasses
"gt ltset-param name"_at_input-classes_at_"gt
_at_input-classes_at_ lt/set-paramgt ltset-param
name"_at_merged-class_at_"gt _at_merged-class_at_
lt/set-paramgt lt/aspectgt ltaspect
name"SetActionFormBeanName" template"Generic-Set
ActionFormBeanName"gt ltset-param
name"_at_class_at_"gt _at_merged-class_at_ lt/set-paramgt
lt/aspectgt ltaspect name"InheritActionForm"
template"Generic-InheritActionForm"gt
ltset-param name"_at_sub-class_at_"gtconcat(
_at_merged-class_at_ ,"Form")lt/set-paramgt lt/aspectgt
ltaspect name"AddAccessors" template"Generic-Add
Accessors"gt ltset-param name"_at_class_at_"gtconcat(
_at_merged-class_at_ ,"Form")lt/set-paramgt
lt/aspectgt lt/aspectgt
generics
Step1
Step2
24Aspect for optimization concern
aspect
ltaspect name"DeleteAttribute"
type"ordinary" jpm"OC"gt ltpointcut
name"postMessageClass"
type"class"gt ltpointcut-bodygt
cname(PostMessage) lt/pointcut-bodygt
lt/pointcutgt ltadvice name"deleteDate"
adviceType"delete-attribute"
ref-pointcut"postMessageClass"gt
ltadvice-bodygt date lt/advice-bodygt
lt/advicegt lt/aspectgt
ltlt OC gtgt DeleteAttribute
postMessageClasse class
pointcut-bodycname(PostMessage)
merge postMessageClasse delete-attribute
advice-bodydate
25Aspect for logging concern
ltaspect name"LoggingSetter"
type"ordinary" jpm"PA"gt ltpointcut
name"allSetter" type"method"gt
ltpointcut-bodygt oname(set)lt/pointcut-bodygt
lt/pointcutgt ltadvice name"logSetter"
adviceType"before"
ref-pointcut"allSetter"gt ltadvice-bodygt
Log.write() lt/advice-bodygt
lt/advicegt lt/aspectgt
aspect
ltlt PA gtgt LoggingSetter
allSetter method pointcut-bodyoname(set
)
merge allSetter before
advice-bodyLog.write()
26Towards product-line engineering
defined by modelers
Aspect library for other platforms
Product X
Application-specific aspects
Aspect library for .NET
weave
Aspect library for J2EE
UML diagrams
Aspect library for other product-lines
Product Y
Application-specific aspects
Aspect library for product-line B
weave
Aspect library for product-line A
UML diagrams
Aspects are useful for product-line engineering
in which a variety of PSMs are generated from a
single set of PIMs.
274. Discussion
28Scalability ?
It is not realistic for a modeler to define all
of the aspects needed to construct a model
compiler from scratch.
- Aspect libraries that support de facto standard
platforms such as J2EE and .NET. - Aspect libraries that support platform-independent
model transformations commonly applied to many
applications.
- fusion of classes having certain kinds of
patterns - generation of setter/getter methods
- change of naming conventions
29Are six JPMs enough ?
It is still not clear whether all kinds of model
transformations can be described by the six JPMs.
- We think that there are situations for which new
kinds of JPMs must be introduced. - It would be better if a modeler can modify the
AspectM metamodel using the model editor. - This function can be considered as a
modeling-level reflection, a kind of compile-time
reflection.
30Is AspectM really AOP language ?
Someone might claim that AspectM is not an
aspect-oriented language but a meta language for
model transformations.
- AspectM can describe not only model
transformation concerns but also ordinary
crosscutting concerns such as logging. - AspectM unifies (lightweight) meta-programming
with ordinary aspect-orientation by extending the
idea of JPMs.
lightweight meta-programming
aspect-orientation
JPMs
315. Related work
32Related work
Aspect-oriented domain modeling (AODM) J.Gray
et. al. 2003
AODM introduced a language called ECL that
provides facilities for adding model elements
such as attributes and relations.
Persistence as an Aspect A.Rashid and
R.Chitchyan 2003
Aspect-oriented mechanisms ( reflection) for
describing database concerns are proposed.
QVT OMG
QVT (Queries, Views, and Transformations) is a
model transformation language.
Draco J. Neighbors 1984
In Draco, software development processes were
considered as a series of transformations.
336. Conclusion
34Conclusion
- We proposed a method for constructing an
extensible model compiler that can deal with
application-specific model transformations. - A modeler can extend model transformation rules
by defining new aspects in the process of
modeling.