Creating a nested aspect
You can create aspects that are enclosed in other types (that is, nested aspects).
-
Open the New Aspect wizard.
-
Edit the Source Folder field to indicate in which folder you want the new aspect to reside. You can either type a path or
click Browse to find the folder. If a folder is found for the current selection, that folder appears in
the Source Folder field as the container for the new aspect.
-
Select the Enclosing Type check box and type the name of the enclosing type in the Enclosing Type field. You can
also click Browse to select the enclosing type for the new aspect.
-
In the Name field, type a name for the new aspect.
-
Select the desired modifiers by using the Modifiers radio buttons and check boxes.
Note that static should not be de-selected because nested aspects must be static.
-
In the Supertype field, type or click Browse to select a superclass/aspect for the new aspect.
-
Click the Add button to add interfaces for the new aspect to implement.
-
Select the public static void main(String[] args) check box if you want the wizard to add the main method to the new aspect, thus
making it a starting point of an application.
-
Select the Inherited abstract pointcuts box if you have overridden an abstract aspect
and want the wizard to generate stubs for the abstract pointcuts.
-
Select the Generate comments box if you want the wizard to generate comments, as configured in the properties
for the project.
-
Click Finish when you are done.
-
If the enclosing type is a class, you may wish to change the file extension in order to avoid
errors in the editor and to have the AspectJ content correctly displayed in views such as the Outline view and the
Package Explorer. Right click on the file in the package explorer then select
Convert file extension to .aj.
Note: The new aspect is created in the same compilation unit as its enclosing type.
AspectJ projects
Aspects
Creating a new aspect
Creating a top-level aspect
Converting file extensions