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, simple, language and/or description:

    I reside at Table Mountain, and my name is Truthful James;
    I am not up to small deceit, or any sinful games;
    And I’ll tell in simple language what I know about the row
    That broke up our society upon the Stanislow.
    But first I would remark, that it is not a proper plan
    For any scientific man to whale his fellow-man,
    Bret Harte (1836–1902)

    Meantime the education of the general mind never stops. The reveries of the true and simple are prophetic. What the tender poetic youth dreams, and prays, and paints today, but shuns the ridicule of saying aloud, shall presently be the resolutions of public bodies, then shall be carried as grievance and bill of rights through conflict and war, and then shall be triumphant law and establishment for a hundred years, until it gives place, in turn, to new prayers and pictures.
    Ralph Waldo Emerson (1803–1882)

    This Light inspires, and plays upon
    The nose of Saint like Bag-pipe drone,
    And speaks through hollow empty Soul,
    As through a Trunk, or whisp’ring hole,
    Such language as no mortal Ear
    But spiritual Eve-droppers can hear.
    Samuel Butler (1612–1680)

    I fancy it must be the quantity of animal food eaten by the English which renders their character insusceptible of civilisation. I suspect it is in their kitchens and not in their churches that their reformation must be worked, and that Missionaries of that description from [France] would avail more than those who should endeavor to tame them by precepts of religion or philosophy.
    Thomas Jefferson (1743–1826)