6
Aspectual Component Implementation Examples

Aspectual Components Implementation: Examples

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Aspectual Components Implementation: Examples

Aspectual Component Implementation

Examples

Page 2: Aspectual Components 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() }

Page 3: Aspectual Components Implementation: Examples

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.

Page 4: Aspectual Components Implementation: Examples

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

Page 5: Aspectual Components Implementation: Examples

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() }

Page 6: Aspectual Components Implementation: Examples

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