AspectJ
This feature is supported in the Ultimate edition only.
In this section:
- AspectJ
- Enabling AspectJ Support Plugins
- Creating a Library for aspectjrt.jar
- Creating Aspects
- Using the Push ITDs In Refactoring
- Using the AspectJ Compiler (ajc)
Introduction
AspectJ support in IntelliJ IDEA Ultimate is based on the following plugins that are bundled with the IDE:
An AspectJ facet which you can add to your Java modules lets you fine-tune the use of the AspectJ compiler at a module level.
Overview of AspectJ support
AspectJ support in IntelliJ IDEA Ultimate includes:
- Ability to create aspects in two forms: as
.aj
files and.java
files containing classes annotated with@Aspect
. - 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
ajc
which you can run right from the IDE. (This compiler is part of the AspectJ distribution which you can download from the AspectJ website.) - Ability to configure
ajc
at the project level with an option of fine-tuning its use at the level of individual modules.
Overview of using AspectJ support
The tasks that are specific to AspectJ are outlined below. For general instructions, see How-to.
- Make sure that:
- You are using the Ultimate Edition of IntelliJ IDEA. AspectJ is not supported in the Community Edition.
- 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.jar
and add this library to dependencies of the modules in which you are going to develop your aspects. Once you have installed AspectJ, you can findaspectjrt.jar
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 inaspectjtools.jar
which is located in<AspectJ installation directory>\lib
. - To fine-tune the use of
ajc
at the level of individual modules, add AspectJ facets to corresponding modules and adjust the facet settings accordingly.
See Also
External Links:
Last modified: 18 July 2017