60 likes | 71 Views
Aspectual Component Implementation. Examples. ConnectorPackage. ComponentPackage. MyHost toModify(){part.Op();}// override aux(){super.toModify()} part. Component. Participant expectedOp() Op(){expectedOp(); getHost()} getHost(). ParticipantAnonymousExtended
E N D
Aspectual Component Implementation Examples
ConnectorPackage ComponentPackage MyHost toModify(){part.Op();}// override aux(){super.toModify()} part Component Participant expectedOp() Op(){expectedOp(); getHost()} getHost() ParticipantAnonymousExtended expectedOp(){aux()} getHost(){MyHost.this} main(){new MyHost().toModify() } “outer.super.toModify()” simulated with aux() is not elegant Johan’s solution 1 based on Mira’s inner class solution. Modification interface is represented also by abstract class, not by Method argument as proposed by Mira. HostPackage Host // to play role of participant toModify(){} // to be mapped to Op()
ConnectorPackage ComponentPackage MyHost toModify(){part.Op();} aux(){super.toModify()} part Component Participant expectedOp() Op(){expectedOp(); getHost()} getHost() ParticipantAnonymousExtended expectedOp(){aux()} getHost(){MyHost.this} main(){new MyHost().toModify() } Problem: when we have a Host-object and want to get modified behavior, need to create a MyHost object. Does it work with multiple participants? With multiple hosts? Looks like. HostPackage Host toModify(){}
ConnectorPackage ComponentPackage MyHost toModify1(){part1.Op();}//overrride aux1(){super.toModify1()} part1 Component Participant expectedOp() Op(){expectedOp???(); getHost()} getHost() ParticipantAnonymousExtended expectedOp1(){aux1()} getHost(){MyHost.this} main(){new MyHost().toModify1()} part2 ParticipantAnonymousExtended expectedOp2(){aux2()} getHost(){MyHost.this} main(){new MyHost().toModify2()} More complex connector: one host but multiple methods are modified. Which expectedOp should be called in the participant? Is this why Mira’s implementation is more complex? toModify2(){part2.Op();}//override aux2(){super.toModify2()}
ConnectorPackage ComponentPackage MyHost toModify(){part.rOp(“toModify”);} part Component Participant rOp(Method expOp) {expOp.invoke(); getHost();} getHost(); ParticipantAnonymousExtended getHost(){MyHost.this} main(){new MyHost().toModify() } HostPackage Host // to play role of participant toModify(){} // to be mapped to rOp() Mira’s modified inner class solution.
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