Upload
mukhtarhudaya
View
270
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
Aspectual Component Implementation
Examples
ComponentPackage
Component
Participant expectedOp() Op(){expectedOp(); getHost()} getHost()
ConnectorPackage
HostPackage
Host // to play role of participant toModify(){} // to be mapped to Op()
Johan’s solution 1 based on Mira’s inner class solution.Modification interfaceis represented also byabstract class, not byMethod argument asproposed by Mira.
“outer.super.toModify()” simulatedwith aux() is not elegant
MyHost toModify(){part.Op();}// override aux(){super.toModify()} part
ParticipantAnonymousExtended expectedOp(){aux()} getHost(){MyHost.this} main(){new MyHost().toModify() }
ComponentPackage
Component
Participant expectedOp() Op(){expectedOp(); getHost()} getHost()
ConnectorPackage
MyHost toModify(){part.Op();} aux(){super.toModify()} part
HostPackage
ParticipantAnonymousExtended expectedOp(){aux()} getHost(){MyHost.this} main(){new MyHost().toModify() }
Host toModify(){}
Does it work with multipleparticipants? With multiple hosts?Looks like.
Problem: when we have a Host-object and want to getmodified behavior, need to create a MyHost object.
ComponentPackage
Component
Participant expectedOp() Op(){expectedOp???(); getHost()} getHost()
ConnectorPackage
More complex connector:one host but multiple methodsare modified. Which expectedOpshould be called in the participant?Is this why Mira’s implementationis more complex?
part2ParticipantAnonymousExtended expectedOp2(){aux2()} getHost(){MyHost.this} main(){new MyHost().toModify2()}
toModify2(){part2.Op();}//overrideaux2(){super.toModify2()}
ParticipantAnonymousExtended expectedOp1(){aux1()} getHost(){MyHost.this} main(){new MyHost().toModify1()}
MyHost toModify1(){part1.Op();}//overrride aux1(){super.toModify1()} part1
ComponentPackage
Component
Participant rOp(Method expOp) {expOp.invoke(); getHost();} getHost();
ConnectorPackage
HostPackage
Host // to play role of participant toModify(){} // to be mapped to rOp()
Mira’s modified inner class solution.
MyHost toModify(){part.rOp(“toModify”);} part
ParticipantAnonymousExtended getHost(){MyHost.this} main(){new MyHost().toModify() }
Implementations
• Implement Datastructure/Counter/Lock example
– without reflection
– with reflection
– apply to both Queue and Stack
• Implement ShowRWAccess example: simulate inheritance between components and connectors in Java
– without reflection
– with reflection
• map readOp to two methods of two different application classes