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:

    Each man’s private conscience ought to be a nice little self-registering thermometer: he ought to carry his moral code incorruptibly and explicitly within himself, and not care what the world thinks. The mass of human beings, however, are not made that way; and many people have been saved from crime or sin by the simple dislike of doing things they would not like to confess ...
    Katharine Fullerton Gerould (1879–1944)

    Public speaking is done in the public tongue, the national or tribal language; and the language of our tribe is the men’s language. Of course women learn it. We’re not dumb. If you can tell Margaret Thatcher from Ronald Reagan, or Indira Gandhi from General Somoza, by anything they say, tell me how. This is a man’s world, so it talks a man’s language.
    Ursula K. Le Guin (b. 1929)

    The Sage of Toronto ... spent several decades marveling at the numerous freedoms created by a “global village” instantly and effortlessly accessible to all. Villages, unlike towns, have always been ruled by conformism, isolation, petty surveillance, boredom and repetitive malicious gossip about the same families. Which is a precise enough description of the global spectacle’s present vulgarity.
    Guy Debord (b. 1931)