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
13
votes
5 answers

Understanding Spring AOP

I am working with Spring 3.0 framework and still a novice. Can anyone explain me in layman terms what is AOP programming? (a short example will definitely help) How does Spring incorporate/enhance/support it?
aces.
  • 3,902
  • 10
  • 38
  • 48
13
votes
1 answer

Spring @EnableRetry throws InternalAutoProxyCreator

I created sample Spring-boot application and it works fine without any error, now I want to practice spring-retry to retry some of the methods. If i don't use @EnableRetry my application starts without any errors but retry is not working. If I use…
Ryuzaki L
  • 37,302
  • 12
  • 68
  • 98
13
votes
3 answers

How to create an aspect on an Interface Method that extends from A "Super" Interface

I have a service-layer Interface that extends from a base Interface; I would like to create a Pointcut around my service-layer Interface, but on one of the methods defined in the base Interface. For instance.... I have a method in my base Interface…
El Guapo
  • 5,581
  • 7
  • 54
  • 82
13
votes
2 answers

Dropwizard Metric Annotations @Timed not working

I'm trying to automatically publish metrics to my MetricRegistry using annotations like @Timed (http://metrics.dropwizard.io/3.1.0/apidocs/com/codahale/metrics/annotation/package-summary.html). This doesn't work out of the box. On searching for…
user2158382
  • 4,430
  • 12
  • 55
  • 97
13
votes
2 answers

Add AspectJ in Webservice

i have a Java EE Webservice (REST) and would now like to use AspectJ, to create a rule that will print-out every incoming service call and their params. I just read this tutorial and implemented the following code: POM.XML
goblingift
  • 409
  • 4
  • 19
13
votes
1 answer

AspectJ weaving maven modules

I have a project that has multiple maven modules, one of which, contains my aspects. How can I take the aspects and weave multiple maven modules? The documentation for the AspectJ Maven plugin is a little sparse and haven't been able to find many…
Mark
  • 837
  • 2
  • 9
  • 19
13
votes
3 answers

AspectJ Load time weaver doesn't detect all classes

I am using Spring's declarative transactions (the @Transactional annotation) in "aspectj" mode. It works in most cases exactly like it should, but for one it doesn't. We can call it Lang (because that's what it's actually called). I have been able…
waxwing
  • 18,547
  • 8
  • 66
  • 82
13
votes
1 answer

How to configure spring boot application to use aspectj transactions?

I would like to use transactions done by aspects in spring-boot aplication, but so far I mostly found help for more "ordinary" setups... What I've managed to set up so far? I've got those annotations on main…
korda
  • 804
  • 7
  • 18
13
votes
6 answers

AspectJ + Gradle configuration

I'd like to use AspectJ in Gradle project (it's not an Android project - just a simple Java app). Here is how my build.gradle looks like: apply plugin: 'java' buildscript { repositories { maven { url…
Kao
  • 7,225
  • 9
  • 41
  • 65
13
votes
5 answers

How to instrument / advice a Spring Data (JPA) repository?

I'm failing in my effort to advice a spring data jpa repository. The goal is to instrument (around) all non-void public methods in a particular repository annotated with a custom annotation (ResourceNotFound in this example) and throw an exception…
epdittmer
  • 488
  • 2
  • 4
  • 15
12
votes
3 answers

Can't get Intellij to use the AspectJ compiler

Everything I see online just says to select the "ajc" compiler from the list of compilers, but that's not an option for me. I've got javac, jikes, eclipse, and javac-in-process, but that's it. As it is my project compiles from the command line with…
Phil Kulak
  • 6,960
  • 8
  • 45
  • 50
12
votes
2 answers

Is there a Java decompiler (be it standalone or an Eclipse plugin) that is able to decompile code woven by AspectJ?

I have scanned the various related questions on the Internet (like http://www.java-decompiler.com/) and SO in particular. So far, I could only find two Java decompilers - JD-GUI and DJ Java Decompiler that claim to be up-to-date. All the rest are…
mark
  • 59,016
  • 79
  • 296
  • 580
12
votes
3 answers

@Timed not working despite registering TimedAspect explicitly - spring boot 2.1

I need to measure method-metrics using micrometer @Timed annotation. As it doesn't work on arbitrary methods; i added the configuration of @TimedAspect explicitly in my spring config. Have referred to this post for exact config Note: have tried…
Rahul
  • 131
  • 1
  • 1
  • 5
12
votes
3 answers

Relocating AspectJ packages in a Java agent

I'm using AspectJ to monitor field access and field modify. I have a gradle project that compiles the two aspects and package that jar together with the aspectjrt and aspectjweaver in a shaded jar using gradle shadow plugin. the agent is still…
Shalom938
  • 909
  • 2
  • 10
  • 24
12
votes
1 answer

AspectJ - change value of method parameter

I would like to have something like this: public void doSomething(@ReplaceFooBar String myString) { //... } ReplaceFooBar is my custom annotation which should take the value of myString and do a replaceAll of "foo" with "bar" on it before the…
morgoth84
  • 1,070
  • 2
  • 11
  • 25