Title: An Approach for Supporting AspectOriented Domain Modeling
1An Approach for Supporting Aspect-Oriented
Domain Modeling
University of Alabama at Birmingham
Vanderbilt University
- GPCE 2003 Erfurt, GermanySeptember 24, 2003
- Jeff Gray, Ted Bapty, Sandeep Neema, Doug
Schmidt, Andy Gokhale and Bala Natarajan - gray (at) cis.uab.eduhttp//www.gray-area.org
This research is funded by DARPA/IXO, under the
PCES program.
2Motivating Problem Crossccuting Constraints in
Real-Time/Embedded Models
Changeability???
- Base models become constrained to capture a
particular design
A
B
F
c
d
e
B
B
c
d
e
c
d
e
3Importance of Changeability in Modeling
-
- Modelings key advantage
- Ability to rapidly explore what-if design
alternatives - Changeability a metric for modularity
- The way to evaluate a modular decompositionis
to ask what changes it accommodates. David
Weiss, chapter preface in Software Fundamentals - Ensure benefit of model-driven approach
- Small changes in requirements entail large
changes in the structure and configuration -
Gerald Jay Sussman, Robust Design through
Diversity, DARPA Amorphous Computing Workshop,
1999.
4Motivation Summary
- Key Problems
- Difficult to specify and manage cross-cutting
concerns (e.g., constraints) in model-based
systems - Lack of tool support for automatically weaving
concerns into models
- Our Solution
- A meta framework that assists in the construction
of model weavers, capable of rapidly dispersing
global concerns across a design space not just
notational
5Modeling Context MIC/GME
- Key focus of this paper
- Weaving of high-level concerns into domain model
- Framework for creating new weavers for each
meta-model
6Process of Using a Model Weaver
7Quantification Over Base Code
Advice
after(Object o) throwing (Error e) pubIntf(o)
log.write(o, e)
pointcut pubIntf(Object o) call(public
com.borland..(..)) target(o)
Pointcut
8Quantification Over a Domain Model
- Apply AO Weaving concepts to Model-based systems
- Weavers Decorate Models with attributes
constraints - Weavers compose new model constructs
Model
Domain-specific Strategies
Strategy1 Strategy2 Strategy3 StrategyN
select(p p.name() Model
p.kind() StateFlow)-gtStrategy3()
Modeling Pointcut
9Constructing Model Weavers
10Domain-Specific Weavers
General Motors Factory
DuPont Chemical Factory
Boeing Bold Stroke
GM specific weaver
DuPont specific weaver
Bold Stroke specific weaver
Example Evidence of meta in the corresponding
XML of each of the above models
11The Metaweaver Framework
ModelingPointcuts
XML Parser
Strategies (C)
Aspect Parser
XML (Model Hierarchy)
Strategies
Strategy Code Generator
strategy ApplyConstraint(constraintName string,
expression string) addAtom("OCLConstraint",
"Constraint", constraintName).addAttribute("Expres
sion", expression) Â strategy
RemoveConstraint(constraintName string)
findAtom(constraintName).removeChild() Â strate
gy ReplaceConstraint(constraintName string,
expression string) RemoveConstraint(constrai
ntName) ApplyConstraint(constraintName,
expression)
12Embedded Constraint Language
Included OCL Operators
13Embedded Constraint Language
- Traditional OCL has been strictly a declarative
query language - New uses require an imperative procedural style
- Addition of side effects into model
- Examples
- addAtom(), findAtom()
- addAttribute(), findAttribute()
- removeNode()
- Support for recursion
- Chaining of strategies (procedure calls)
- Inlined C code
14List of ECL Operators
15Example Processor Assignment
16Processor AssignmentComponent Interaction Model
17Processor AssignmentComponent Internals
18Processor AssignmentModeling Pointcut
- aspect ProcessorAssignment
-
- models("")-gtselect(m m.kind()
Comp")-gtAssign(10)
19Processor Assignment Strategy
- strategy Assign(limit integer)
- declare static accumulateWCET, processNum
integer - declare currentWCET integer
-
- self.compute.WCET.getInt(currentWCET)
- accumulateWCET accumulateWCET currentWCET
- if (limit lt accumulateWCET) then
- accumulateWCET currentWCET
- processNum processNum 1
- endif
- ltltCComBSTR aConstraint "self.assignTo()proces
sor" - XMLParseritos(processN
um) gtgt - AddConstraint("ProcessConstraint",
aConstraint)
20Processor AssignmentWeaved Constraint
strategy Assign(limit integer) declare
static accumulateWCET, processNum integer
declare currentWCET integer
self.compute.WCET.getInt(currentWCET)
accumulateWCET accumulateWCET currentWCET
if (limit lt accumulateWCET) then
accumulateWCET currentWCET processNum
processNum 1 endif ltltCComBSTR
aConstraint "self.assignTo()processor"
XMLParseritos(processNum)
gtgt AddConstraint("ProcessConstraint",
aConstraint)
21Code Generation Example
- Consider the following, which appears in an
EagerLazy strategy -
- components.models()-gtselect(c
- c.id()
refID)-gteagerLazy() -
22Code Generation Example
CComPtrltIXMLDOMNodeListgt models0
XMLParsermodels(components, "")
nodeTypeVector selectVec1 XMLParserConvertDomL
ist(models0) nodeTypeVector selectVecTrue1
new stdvectorltnodeTypegt vectorltnodeTypegtit
erator itrSelect1 for(itrSelect1
selectVec1-gtbegin() itrSelect1 !
selectVec1-gtend() itrSelect1)
nodeType selectNode1 (itrSelect1)
nodeType c c selectNode1 CComBSTR
id0 XMLParserid(c) ClData
varforward1(id0) ClData varforward2(referred
ID) bool varforward3 varforward1
varforward2 if(varforward3)
selectVecTrue1-gtpush_back(itrSelect1)
vectorltnodeTypegtiterator itrCollCall1
for(itrCollCall1 selectVecTrue1-gtbegin()
itrCollCall1 ! selectVecTrue1-gtend()
itrCollCall1) eagerLazyapply()
23Sample XMLParser Methods
nodeType XMLParseraddAtom(nodeType self,
CComBSTR kind, CComBSTR role, CComBSTR name)
return addNode(self, "atom", kind, role,
name) nodeType XMLParserfindModel(nodeType
aNode, CComBSTR name) CComBSTR
bstrFind(L"./modelname\"") bstrFind.Append(name
) bstrFind.Append("\"") return
submitXPath(aNode, bstrFind) CComBSTR
XMLParserid(nodeType aNode) CComBSTR
res CComPtrltIXMLDOMNodegt attr
XMLParserfindAttribute (aNode, "id")
XMLParsergetStr(attr, res) return res
24Summary
25Summary Benefits of this Approach
- The modeler can now perform various what-if
scenarios using modeling constraints - Impossible in previous approach
- Constraints can be plugged/unplugged in model
- Because much of the redundancy of constraint
application is removed, the effect of each
constraint on the global system can be better
understood. This localization of constraints
improves modular reasoning. - Allows for the rapid construction of new
domain-specific weavers - Strategies are specified using a DSL
- Generated code is at a much lower level
26For more information
- Please give us another week to upgrade site
- gray (at) cis.uab.edu
- http//www.gray-area.org/Research/C-SAW
- GME (freely available)
- http//www.isis.vanderbilt.edu/Projects/gme/
-
- OMG MIC PSIG
- http//mic.omg.org
27A Concluding Quote
-
- Even for this let us divided liveThat by this
separation I may give that due to thee which thou
deservest alone. - William Shakespeare, Sonnet XXXIX
28Extra slides
29Tool Independence
- Requires an exposed API for accessing internal
model data structures - Tool-specific adapters written for each new
supported tool
Rose
GME
Cadena
MetaEdit
30Adaptive Core Weaving Engine
31Not unlike AspectJ AJDT
AJDT