|
Table of Contents
HooksetsHooksets allow us to select _where_ an aspect will apply. In Reflex, Hookset is an interface that defines two highly-related to the Reflex internals methods. This is the reason why two implementations are provided:
Execution PointsHere, we have talked aboud “execution points”. Formalizing what they are, we can say that an execution point is defined as an operation occurring at the application. Operations can be any of the following:
object.hashCode() or string.substring(0, 5);
public int hashCode(){ <all statements> }
new Object(); or new String("hello world!");
public String(){ <all statements> }
System.out.println(this.x) or this.y = 228;
(Object) object; or (Appendable) string.replace(" ", "_");
With this stated, we can review the API of public PrimitiveHookset(Class aOperation, ClassSelector aClassSelector, OperationSelector aOperationSelector)
As you can see, it takes the operation it must match and two additional parameters we have not seen yet: a SelectorsClass Selectors
The existence of class selectors is to avoid examining all the classes of the system: they are asked to know if the class can contain execution points that can be matched by any
The public interface ClassSelector{ public boolean accept(RClass aClass); }
And its unique method Operation SelectorsIf a class selector selects a class, Reflex will analyze that class and will reify all operations on it. Then for each of these operations, the operation selectori will be asked if the operation is of interest. If it returns true, the assosiated hookset is said to match to that operation in particular.
The public interface OperationSelector{ public boolean accept(Operation aOp, RClass aClass); }
Where its unique method As you can see, the hookset matching mechanism in Reflex is pretty powerfull, and, at the same time, performant. One of the things we intentionally skipped is the presence of all those R* classes (that are reifications of the different structures of the application). We will review them later in this {section]. |