master’s thesis defense: aspectual concepts
Embed Size (px)
DESCRIPTION
Master’s Thesis Defense: Aspectual Concepts. John J. Sung. Outline. Motivation JPM and Demeter Concepts Demeter integrated with AspectJ ( AJ) AJ Semantics/Syntax AJ System Architecture Conclusion. Motivation. Aspect Oriented Software Development Gaining Momentum - PowerPoint PPT PresentationTRANSCRIPT
-
Masters Thesis Defense:Aspectual ConceptsJohn J. Sung
EMETER
OutlineMotivationJPM and Demeter ConceptsDemeter integrated with AspectJ ( AJ) AJ Semantics/Syntax AJ System ArchitectureConclusion
EMETER
MotivationAspect Oriented Software Development Gaining Momentum1st International Conference on AOSDAspectJ, DemeterJ, ConcernJ, HyperJ, etc.AOSD is Relatively YoungDemeter C++ ~1989DemeterJ ~ 1996AspectJ ~1997
EMETER
QuestionsWhat are the fundamental concepts behind AOSD?How are these concepts related?How can these concepts be combined?What are the fundamental problems that software language features attempt to solve?
EMETER
Join Point Model (JPM)Fundamental ConceptsJoin Point, Pointcut, Advice, Aspect, IntroductionConcepts applied to call graph in AspectJIntroduction also applied to class graph
EMETER
AspectJ Abstraction of ProgramsCall GraphPointcuts++Advice=>Program
EMETER
AspectJ Abstraction of Programsfoo(){x = 0;if (x < 0) throw KException;}Class Barint x;b1.foo();Class C1within(Bar)Aspect Abefore() : within(Bar) {}
EMETER
Another ViewJava ProgramAspectJAdvicepointcutadvice bodyjoin point
EMETER
DemeterFundamental ConceptsClass Graph, Strategy, Visitor, AdviceConcepts applied to data structures, i.e. class graphJourney Metaphor
EMETER
Journey MetaphorConcepts in Demeter create an image of a person on a journey
EMETER
Demeter Abstraction of ProgramsClass GraphStrategyGraph++VisitorAdvices=>Program
EMETER
Demeter Abstraction of Programs=>before(..)after(..)before(..)ClassGraphStrategyGraphTraversalGraphVisitorAdvices
EMETER
Combining ConceptsApplication of JPM to DemeterClass graph is built of classes and edgesJoin points become the points along traversalsAdvices are executed at these join points
EMETER
Combining ConceptsApplication of Demeter to JPMCPU executes the traversal through the dynamic call graphCPU manages the dynamic call graphAdvices are for the one visitor: CPU
EMETER
Demeter AspectJ: AJ Extends AspectJ with traversal capabilityDefines a traversal specification languageUses DJ to generate Class Graph, Traversal GraphGenerates the AspectJ implementation of the traversal using AspectJ introductionsImplemented using DemeterJ, DJ, AspectJBlending of JPM and Demeter Concepts
EMETER
Design of AJFirst DesignAdd syntax to AspectJ languageModify the open source ajcUse DJ and AspectJ to modify the behaviorSecond DesignUse ajc as the back endCreate a small language to describe traversalsUse DJ, AspectJ, DemeterJLess coupling with the AspectJ compiler
EMETER
Traversal Specification LanguageDesigned to have similar syntax to DJ and AspectJAllows users to specify Class Graph, Traversal, and VisitorGenerates AspectJ implementation of traversals using introductionsVisitor advices are called by using AspectJ advices
EMETER
Class Graph SpecificationDefault Class Graph
ClassGraph cgvar;
Class Graph Slice
ClassGraph cgvar = new ClassGraph(cg, strategy);
EMETER
Visitor SpecificationUses Java Reflection to obtain method signaturesRecognized Methodsaround, before, after, start, finish, returnValueVisitor DeclarationVisitor visitorClass;
EMETER
Traversal SpecificationDefault Traversal Specification
declare traversal tvar : strategy;
Traversal with Class Graph
declare traversal tvar(cgvar) : strategy;
Traversal with Visitor
declare traversal tvar(cgvar, visitorvar) : strategy;
EMETER
Aspect Specificationaspect aspectName { class graph declarations; traversal declarations; visitor declarations;}
EMETER
What AJ GeneratesFor each default and class graph slice traversalmethod void tvar() for the source node of the traversal strategyFor each traversal with visitormethod void tvar() for the source node of the traversal strategymethod void tvar(visitorClass) for the source node of the traversal strategyAppropriate AspectJ advices for each advice method in visitorClass
EMETER
A Simple Basket Exampleclass Basket { Basket(Fruit _f, Pencil _p) { f = _f; p = _p; } Basket(Fruit _f, Fruit _f2, Pencil _p) { f = _f; f2 = _f2; p = _p; } Fruit f, f2; Pencil p;}class Fruit { Fruit(Weight _w) { w = _w; } Weight w;}class Orange extends Fruit { Orange(Color _c) { super(null); c=_c;} Orange(Color _c, Weight _w) { super(_w); c = _c;} Color c;}class Pencil {}class Color { Color(String _s) { s = _s;} String s;}class Weight{ Weight(int _i) { i = _i;} int i; int get_i() { return i; }}
EMETER
A Simple Basket ExampleBasketFruitPencilpf, f2OrangeWeightColorwcStringsint i
EMETER
BasketVisitorclass BasketVisitor { int total;
public void start() {total = 0; }
public int returnValue() {return total; } void before(Weight w) {total += w.get_i(); }}
EMETER
Basket Traversalaspect BasketTraversal { ClassGraph default; ClassGraph myClassGraph = new ClassGraph(default, "from Basket to *"); Visitor BasketVisitor; declare traversal t1(myClassGraph,BasketVisitor) : "from Basket to Weight"; declare traversal t2(myClassGraph,BasketVisitor) : "from Basket via Orange to Weight";}
EMETER
Basket Main
class BasketMain { static public void main(String args[]) throws Exception {Basket b = new Basket(new Orange(new Color("orange"), new Weight(5)), new Fruit( new Weight(10)), new Pencil() );
BasketVisitor bv = new BasketVisitor();b.t1(bv);int totalWeight = bv.returnValue();System.out.println("Total weight of basket = " + totalWeight);b.t2(bv);
totalWeight = bv.returnValue();System.out.println("Total weight2 of basket = " + totalWeight); }}
EMETER
Generated Code for Visitor static BasketVisitor t1_visitor; public void Basket.t1(BasketVisitor v) { t1_visitor=v; t1_visitor.start(); t1(); } before(Weight host) : call(public void t1*()) && target(host) { t1_visitor.before(host); } void Basket.t1() { t1_copy0(); }
EMETER
Basket Class GraphBasketFruitPencilpf, f2OrangeWeightColorwcStringsint i
EMETER
Generated Code for Traversal // traversal t1 : {source: Basket -> target: Weight} with { } public void Basket.t1_copy0(){ if (f != null) t1_copy0_crossing_f(); if (f2 != null) t1_copy0_crossing_f2(); } public void Basket.t1_copy0_crossing_f() { f.t1_copy0();} public void Basket.t1_copy0_crossing_f2() { f2.t1_copy0();} public void Fruit.t1_copy0(){ if (w != null) t1_copy0_crossing_w(); } public void Fruit.t1_copy0_crossing_w() { w.t1_copy0();} public void Weight.t1_copy0(){ } public void Orange.t1_copy0(){ super.t1_copy0(); } pointcut pointcut_t1() : call(public void t1*()); before () : pointcut_t1 () { System.out.println(thisJoinPoint); }
EMETER
System ArchitectureDAJ MainParses command line argumentsManages the DAJ code generation phasesStub GenerationGenerates stubs for traversal methodsTraversal Generation CompilationCompiles using ajc the stubs, user code, and CreateClassGraph.java
EMETER
System ArchitectureTraversal GenerationUses DJ, Java Reflection, and DemeterJ to generate AspectJ traversal codeTraversal CompilationCompiles the generated traversal code with user code
EMETER
System ArchitectureStub GenerationTraversal Generation CompilationTraversal Generation Traversal Compilation DAJMainmethodcallshellshellshell
EMETER
AJ ProcessStub GenerationTraversal FilesGenerated StubsTraversal Generation CompilationClass FilesClass FilesTraversal Generation Traversal Compilation UserCodeCreateClassGraph.javaTraversalImplementationUser Code to DAJCode Provided by DAJIntermediate FilesFinal Application
EMETER
Traversal GenerationCreateClassGraph.javaintercepts the call to maininstantiates a ClassGraph using DJArguments and ClassGraphUses DJ to generate Traversal GraphTranslates the Traversal Graph to AspectJ introductionsVisitor code generationuses Java Reflection to obtain method signituresgenerates AspectJ advices for each visitor advice
EMETER
Example Run of AJ[denali: ~/demeter/daj/dev/basket2] > java edu.neu.ccs.demeter.daj.DAJ -main BasketMain -dtrv trav -ccg ../ccg/CreateClassGraph.java BasketMain.java BasketTraversal.trv BasketVisitor.java
%I - Generating Stubsprefix for stub: travGenerating Stub file: trav/BasketTraversal.java
%I - traversal generation compilationajc ../ccg/CreateClassGraph.java BasketMain.java BasketVisitor.java trav/BasketTraversal.java
%I - traversal generationjava BasketMain -d trav BasketTraversal.trv
%I - traversal compilationajc BasketMain.java BasketVisitor.java trav/BasketTraversal.java
EMETER
Measuring PerformanceTraversals implemented in DemeterJ, DJ, DAJVary the size of the Object GraphMeasure the elapsed time between start and finishSunBlade 100 running SunOS 5.8
EMETER
Performance Comparison
Chart1
23357732
40790848
551186362
601490570
DemeterJ
DJ
DAJ
Object Graph Size
Elapse Time (ms)
Sheet1
OG SizeDemeterJDJDAJ
500023357732
1000040790848
15000551186362
20000601490570
Sheet1
DemeterJ
DJ
DAJ
Object Graph Size
Elapse Time (ms)
Sheet2
Sheet3
EMETER
DemeterJ and AJ Performance
Chart2
2332
4048
5562
6070
DemeterJ
DAJ
Object Graph Size
Elapsed Time (ms)
Sheet1
OG SizeDemeterJDJDAJ
500023357732
1000040790848
15000551186362
20000601490570
Sheet1
DemeterJ
DJ
DAJ
Object Graph Size
Elapse Time (ms)
Sheet2
DemeterJ
DAJ
Object Graph Size
Elapsed Time (ms)
Sheet3
EMETER
Performance Comparison
Sheet1
OG SizeDemeterJDJDAJ
500023357732
1000040790848
15000551186362
20000601490570
Sheet1
DemeterJ
DJ
DAJ
Object Graph Size
Elapse Time (ms)
Sheet2
Sheet3
EMETER
Future AJ Improvementshttp://www.ccs.neu.edu/research/demeter/DAJTwo syntax supportedDJ/Java like styleAspectJs declare syntaxHandle CollectionsTraversal through Java CollectionsHandle interfacesGenerates Traversals correctly for interfaces
EMETER
QuestionsWhat are the fundamental concepts behind AOSD in Demeter and AspectJ?How are these concepts related?How can these concepts be combined?What are the fundamental problems that software language features attempt to solve?
EMETER
Software Design Concerns Organizational ConcernHow do I organize my code?Factorizational ConcernHow can I factor similar code?Specification ConcernWhat can I specify within the program?Interface ConcernHow can I interface with someone elses code?
EMETER
ConclusionsMetaphors used in Demeter and JPMConstruction and Journey MetaphorsUsage of one or the other depends on the users and applicationCan describe each otherCombinable
EMETER
ConclusionsDAJMixing Demeter with AspectJ conceptsUses DJ, DemeterJ and AspectJExtends AspectJ incrementallyFaster traversals than DJwww.ccs.neu.edu/research/demeter/DAJ
EMETER
ConclusionsSoftware Design ConcernsOrganizational, Factorizational, Specification, and InterfaceHow do programming features address SDC?How do SDCs related to AOP?Further research needed
EMETER
Future DirectionAnalyze the metaphors used in other toolsComposeJ, HyperJ, etc.Try combining these conceptsUse the Software Design Concerns to analyze AOP tools
EMETER
AspectJ from PARCAJEMETERJ(Demeter AspectJ)
EMETER
Referenceswww.ccs.neu.edu/research/demeter/DAJwww.ccs.neu.edu/research/demeter/DemeterJavawww.ccs.neu.edu/research/demeter/DJwww.aspectj.orgwww.aosd.net
EMETER
Static Scattering and Tanglingaspecti is scattered across many classes (i = 1,2,3)class X tangles aspects 1, 2 and 3aspect1aspect2aspect3class A consistingof three aspectsclasses foraspect1classes foraspect2classes foraspect3Class Xclass diagramAdding to classes
EMETER
Dynamic Scattering and Tanglingprogram executioninvolving three aspects (colors r b g)program call tree(objectsexecuting method calls)Each aspect (colors) is scattered across many classes (shapes)Class tangles all three aspects At those calls the aspect enhances the behaviorclassesthis(s)target(t)f(..)Enhancing callst.f(..);
EMETER
subcomputation = join points related to traversing through the objectsguided by traversal specification and class graph.
AspectJ
DJ
Kind
Dynamic
Dynamic
On What
Dynamic call graph of base program
Dynamic call graph of a subcomputation of base program
When
Pointcuts
Signatures of visitor methods
What
Before / around / after advice
Before / around / after visitor method body
EMETER
Pointcutset of execution points of any method, rich set of primitive pointcuts: this, target, call, + set operationswhere to enhanceAdvicehow to enhanceVisitor method sig.set of execution points of traversalsspecialized for traversals (nodes, edges)where to enhanceVisitor method bodieshow to enhanceDJAspectJFrom DJ to AspectJ