Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
research:mao:generic-advice [2011/12/01 22:40] – minostro | research:mao:generic-advice [2011/12/14 12:29] (current) – minostro | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Aspect-Oriented Programming (AOP) is successful to modularize crosscutting concerns such as Logging, Profiling, Security, among others. | ||
+ | |||
+ | <code java> | ||
+ | aspect Profiling{ | ||
+ | |||
+ | Object around(Object thiz) : execution(* *(..)) && this(thiz){ //Generic advice | ||
+ | Object rt; | ||
+ | float start = Utils.datetime.now(); | ||
+ | rt = proceed(thiz); | ||
+ | Utils.out(Utils.getName(thiz), | ||
+ | return rt; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | You might notice that the above advice can work uniformly over whatever type that //thiz// takes. | ||
+ | |||
+ | The usefulness of Generic Advice has been demonstrated and discussed in the AOP community | ||
+ | |||
+ | * **JPI overloading: | ||
+ | |||
+ | * **Parametric polymorphism: | ||
+ | |||
+ | Also, it is important to implement //Invariant pointcuts designators// | ||
+ | |||
+ | * **Invariant PCD:** //args//, //this//, //target// are PCDs that expose the context of the selected join point. | ||
+ | |||
+ | ====== Motivation ====== | ||
+ | |||
+ | In order to validate our first proposal of Join Point Interfaces, we migrate two applications: | ||
+ | |||
+ | Interestingly, | ||
+ | |||
+ | Once the migration was finished, we come up with the conclusion that our proposal is well-behave in presence of specific advices, but it is too verbose in presence of generic advices. | ||
+ | |||
+ | | ^Q. of advice || | ||
+ | | ^Original^ JPI version ^ | ||
+ | ^AJHotDraw| ? | ?| | ||
+ | ^LawOfDemeter| ? | ?| | ||
+ | |||
+ | This table shows the quantity of advice declarations in both scenarios: original and migrated application. | ||
+ | |||
+ | The problem with generic advice is raised due to our semantics. | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | jpi Integer MyJPI(C c); | ||
+ | jpi Float MyJPI2(D d); | ||
+ | |||
+ | class C{ | ||
+ | |||
+ | exhibits Integer MyJPI(C c) : | ||
+ | execution(* *(..)) && this(c); | ||
+ | |||
+ | public Integer doSomething(){...} | ||
+ | } | ||
+ | |||
+ | class D{ | ||
+ | |||
+ | exhibits Float MyJPI2(D d) : | ||
+ | execution(* *(..)) && this(d); | ||
+ | |||
+ | public Float doSomething(int a){...} | ||
+ | } | ||
+ | |||
+ | public class Main{ | ||
+ | |||
+ | | ||
+ | C c = new C(); | ||
+ | D d = new D(); | ||
+ | c.doSomething(); | ||
+ | d.doSomething(5); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | aspect ProfilingJPI{ //JPI syntax | ||
+ | |||
+ | Integer around MyJPI(C thiz){ | ||
+ | Object rt; | ||
+ | float start = Utils.datetime.now(); | ||
+ | rt = proceed(thiz); | ||
+ | Utils.out(Utils.getName(thiz), | ||
+ | return rt; | ||
+ | } | ||
+ | |||
+ | Float around MyJPI2(D thiz){ | ||
+ | Object rt; | ||
+ | float start = Utils.datetime.now(); | ||
+ | rt = proceed(thiz); | ||
+ | Utils.out(Utils.getName(thiz), | ||
+ | return rt; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Consider now, that we add in main method a method invocation belonging to other class named E. To select this join point we need to define an extra advice definition. | ||
+ | * the same body definition of the other pieces of advices, and | ||
+ | * A formal parameter called //thiz// with //E// as its type. | ||
+ | |||
+ | ====== Related Work ====== | ||
+ | |||
+ | * Introduction | ||
+ | |||
+ | |||
+ | * StrongAspectJ | ||
+ | * types variables | ||
+ | * double proceed signature | ||
+ | * modification in PCDs semantics. | ||
+ | * Problems with double proceed signature. | ||
+ | * ClassCastException with interfaces. | ||
+ | |||
+ | |||
+ | * work of Jagadeesan et al. | ||
+ | * generic types | ||
+ | * demonstrate that generic advice is useful | ||
+ | |||
+ | ====== New features ====== | ||
+ | |||
+ | In this section we show in detail how the new features solve our current problems and how we will implement them. | ||
+ | |||
+ | * [[research: | ||
+ | * [[research: | ||
+ | * [[research: | ||
+ | |||
+ | |||
+ | ====== References ====== | ||
+ | |||
+ | [1] R. Jagadeesan, A. Jeffrey, and J. Riely. Typed parametric polymorphism for aspects. | ||
+ | |||
+ | [2] B. De Fraine, M. Südholt, and V. Jonckers. | ||
+ | |||
+ | |||