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 thePoint
class:
- 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 withset
:
- 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:
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:
“The Americans never use the word peasant, because they have no idea of the class which that term denotes; the ignorance of more remote ages, the simplicity of rural life, and the rusticity of the villager have not been preserved among them; and they are alike unacquainted with the virtues, the vices, the coarse habits, and the simple graces of an early stage of civilization.”
—Alexis de Tocqueville (18051859)
“Any language is necessarily a finite system applied with different degrees of creativity to an infinite variety of situations, and most of the words and phrases we use are prefabricated in the sense that we dont coin new ones every time we speak.”
—David Lodge (b. 1935)
“To give an accurate description of what has never occurred is not merely the proper occupation of the historian, but the inalienable privilege of any man of parts and culture.”
—Oscar Wilde (18541900)