AspectJ - Simple Language Description

Simple Language Description

All valid Java programs are also valid AspectJ programs, but AspectJ also allows programmers to define special constructs called aspects. Aspects can contain several entities unavailable to standard classes. These are:

  • inter-type declarations—allow a programmer to add methods, fields, or interfaces to existing classes from within the aspect. This example adds an acceptVisitor (see visitor pattern) method to the Point class:
aspect VisitAspect { void Point.acceptVisitor(Visitor v) { v.visit(this); } }
  • pointcuts — allow a programmer to specify join points (well-defined moments in the execution of a program, like method call, object instantiation, or variable access). All pointcuts are expressions (quantifications) that determine whether a given join point matches. For example, this point-cut matches the execution of any instance method in an object of type Point whose name begins with set:
pointcut set : execution(* set*(..) ) && this(Point);
  • advice — allows a programmer to specify code to run at a join point matched by a pointcut. The actions can be performed before, after, or around the specified join point. Here, the advice refreshes the display every time something on Point is set, using the pointcut declared above:
after : set { Display.update; }

AspectJ also supports limited forms of pointcut-based static checking and aspect reuse (by inheritance). See the AspectJ Programming Guide for a more detailed description of the language.

Read more about this topic:  AspectJ

Famous quotes containing the words simple, language and/or description:

    It would not be an easy thing to bring the water all the way to the plain. They would have to organize a great coumbite with all the peasants and the water would unite them once again, its fresh breath would clear away the fetid stink of anger and hatred; the brotherly community would be reborn with new plants, the fields filled with to bursting with fruits and grains, the earth gorged with life, simple and fertile.
    Jacques Roumain (1907–1945)

    As in private life one differentiates between what a man thinks and says of himself and what he really is and does, so in historical struggles one must still more distinguish the language and the imaginary aspirations of parties from their real organism and their real interests, their conception of themselves from their reality.
    Karl Marx (1818–1883)

    An intentional object is given by a word or a phrase which gives a description under which.
    Gertrude Elizabeth Margaret Anscombe (b. 1919)