Questions tagged [aspectj]

AspectJ is an aspect-oriented extension to the Java programming language that enables clean modularization of crosscutting concerns such as logging, error handling, standards enforcement and feature variations. Use this tag for questions about the programmatic use of this extension. For downloads, support, IDE integration, & documentation, see the "learn more" for this tag.

AspectJ is an Aspect-Oriented Programming (AOP) extension to Java, created by Xerox, that has as main components aspects (consisting of pointcuts and advices) and join points.

For AspectJ Eclipse integration, also see AspectJ Development Tools (AJDT); for NetBeans integration, see AspectJ in NetBeans; for IntelliJ IDEA integration, see IDEA Web Help.

Books:

Documentation:

3304 questions
19
votes
4 answers

Is it possible to use Android Gradle Plugin 3.0.0 with IntelliJ

I am trying to use plugin com.android.tools.build:gradle:3.0.0-alpha4 in IntelliJ. But I've got the error Error:This Gradle plugin requires Studio 3.0 minimum The android gradle plugin version 2.3.3 supports Intellij. I need IntelliJ due to I want…
Irina
  • 939
  • 1
  • 8
  • 26
19
votes
3 answers

Which maven plugin do I use for AspectJ?

I am trying to add aspectj to a maven project using java 6.0. Browsing around I found 2 maven plugins, none of which works the way I would expect. The first one http://mojo.codehaus.org/aspectj-maven-plugin did not work at first through netbeans…
Kristofer
  • 7,861
  • 6
  • 30
  • 31
19
votes
5 answers

Pass method argument in Aspect of custom annotation

I'm trying to use something similar to org.springframework.cache.annotation.Cacheable : Custom annotation: @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface CheckEntity { String…
Chris
  • 549
  • 1
  • 5
  • 18
18
votes
6 answers

How to test an aspect with SpringBootTest?

I created a simple aspect in Spring using Spring Boot 2.1.6.RELEASE. It basically logs the total time spent on a method. @Aspect @Component public class TimeLoggerAspect { private static final Logger log =…
Natan Cox
  • 1,495
  • 2
  • 15
  • 28
18
votes
4 answers

Exception java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Aspect

I recently started working on AspectJ and wrote a simple Aspect for Logging. I have defined below dependencies into my pom file: org.aspectj aspectjrt
Atul
  • 1,694
  • 4
  • 21
  • 30
18
votes
1 answer

Spring + AspectJ weaving for java 8 using aspectj-maven-plugin

I'm migrating my project from java 7 to java 8 and the problem I have is related to aspectj weaving using aspectj-maven-plugin. I could configure successfuly the weaving using this plugin running on Java 6 and 7 according to Haus documentation. But…
Federico Piazza
  • 30,085
  • 15
  • 87
  • 123
18
votes
2 answers

AspectJ pointcut expression match parameter annotations at any position

I'm trying to define a pointcut expression to match methods which contain a parameter annotated with a specific annotation, regardless of what position the parameter is in. In my case I'm looking for the @Constraint annotation. For example: Matching…
driangle
  • 11,601
  • 5
  • 47
  • 54
17
votes
3 answers

Getting a return value or exception from AspectJ?

I am able to get the signature and arguments from advised method calls, but I cannot figure out how to get the return values or exceptions. I'm kind of assuming that it can be done in some way using around and proceed.
Smern
  • 18,746
  • 21
  • 72
  • 90
17
votes
5 answers

Aspectj doesn't work with kotlin

i want to use aspectj aop in kotlin,here is my code: my annotation in annotation.lazy_list: Kotlin: package anotation @Retention(AnnotationRetention.RUNTIME) @Target(AnnotationTarget.FUNCTION) annotation class lazy_list my aspectj aop…
junk
  • 917
  • 3
  • 11
  • 29
17
votes
1 answer

Pointcut matching methods with annotated parameters

I need to create an aspect with a pointcut matching a method if: Is public Its class is annotated with @Controller (Finally does not) One of its parameters (can have many) is annotated with @MyParamAnnotation. I think the first two conditions are…
sinuhepop
  • 20,010
  • 17
  • 72
  • 107
16
votes
2 answers

WEB-INF/classes/ vs WEB-INF/lib/*.jar in classpath priority?

a war packaged for a tomcat webapp contains WEB-INF/classes and WEB-INF/lib/*.jar which of them has higher priority in the CLASSPATH? the reason I'm asking is, that my application uses A.jar, which contains aspects generated from an aspectj project;…
teddy teddy
  • 3,025
  • 6
  • 31
  • 48
16
votes
5 answers

Spring's LoadTimeWeaver Agent not starting up

I'm attempting to implement Load time weaving using Spring and AspectJ. To the best of my knowledge I have everything configured properly but I keep getting the error when I try to run my integration…
Conner McNamara
  • 365
  • 1
  • 5
  • 15
16
votes
2 answers

How Spring aspects work internally?

Say Service calls Dao class on which logging aspect(annotational) needs to be applied. I am wondering how aspects actually gets applied. As per my understanding at the time of DAO injection under Service object, spring finds out that there is some…
M Sach
  • 33,416
  • 76
  • 221
  • 314
16
votes
5 answers

Adding AspectJ to pom.xml changed Java version with Maven, why?

UPDATE: here is my maven-compiler-plugin configuration: org.apache.maven.plugins maven-compiler-plugin 2.3.2
Sanyifejű
  • 2,610
  • 10
  • 46
  • 73
16
votes
2 answers

Aspectj: intercept method from external jar

I am using a X.jar and adding to my AspectJ project(in eclipse). I have written pointcut and advice for a method myMethod() inside X.jar. But aspectj is not intercepting this method call. How can I tell aspectj to intercept method calls on external…
vishnu viswanath
  • 3,794
  • 2
  • 36
  • 47