AddClassField Aspect
[Basic Group]

This aspect is defined in file: ../../AspectXLib/base/Base/aspects/AddClassField.ax

Aspect Description

Sample aspect program to add a field to a target class. The aspect program adds the declaration of a dummy variable to a target class. The target class identified by name and is class DC_DummyPunctualAction. This aspect program shows how aspect transformations can be used to extend the internal state of a base class.
Author:
A. Pasetti

Pointcuts

classtargetClass
 Points to the target class where the new field should be added

Advices

addaddVariableDeclaration
 Add the declaration of the dummy variable in the target class

Pointcut Documentation

class targetClass (source)
Points to the target class where the new field should be added. The target class is identified through its name.

Advice Documentation

add addVariableDeclaration (source)

Triplet: class add declaration

Add the declaration of the dummy variable in the target class. The name of the dummy variable is dummyVariable. The dummy variable is declared to be private. This is expressed through the use of the "accessModifier" element. This element must always be present in code modifiers that add a declaration (either of a variable or of a method) to a class. Note that the text that is added to the target class includes a line comment. This can be done because XWeaver treats the text in the code modifier as a code fragment that is inserted in the place identified by the pointcut but it does not attempt to parse or interpret it. The text in the code modifier does not specify any indentation. The XWeaver will automatically indent the text it inserts in the base code.

Refers to global pointcut: class targetClass