- Spring AOP/@AspectJ
- AspectJ Support
On this page:
In this section:
- Enabling AspectJ Support Plugins
- Creating a Library for aspectjrt.jar
- Creating Aspects
- Using the Push ITDs In Refactoring
- Using the AspectJ Compiler (ajc)
Overview of AspectJ support
AspectJ support in IntelliJ IDEA includes:
Ability to create aspects in two forms: as
.javafiles containing classes annotated with
- Coding assistance (including code completion) when writing aspect code. For annotation-style aspects, the coding assistance is provided in full; for code-style aspects, the assistance is limited to inter-type declarations.
- Ability to perform basic aspect refactorings such as Rename and Move, and also the Push ITDs In refactoring for inter-type declarations.
Integration with the AcpectJ compiler
ajcwhich you can run from within the IDE. (This compiler is part of the AspectJ distribution which you can download from the AspectJ website.)
Ability to flexibly configure
ajcat the project level with an option of fine-tuning its use at the module level.
Overview of using AspectJ support
- Make sure that the Spring AOP/@AspectJ and the AspectJ Support plugins are enabled (see Enabling AspectJ Support Plugins).
- Download and install AspectJ.
Create a library containing
aspectjrt.jarand add this library to dependencies of the modules in which you are going to develop your aspects. After the installation of AspectJ,
aspectjrt.jarcan be found in
<AspectJ installation directory>\lib. See Creating a Library for aspectjrt.jar.
- Create aspect files and develop the code. Note that code- and annotation-style aspects are supported.
- If necessary, refactor the aspect code.
To use the AspectJ compiler,
configure the compiler settings.
The compiler (
ajc) is in
aspectjtools.jarwhich is located in
<AspectJ installation directory>\lib.
To fine-tune the use of
ajcat the level of individual modules, add AspectJ facets to corresponding modules and adjust the facet settings accordingly.
Last modified: 12 November 2014