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
33
votes
7 answers

Lombok and AspectJ

I'm trying to use Lombok in combination with AspectJ and Maven. So, what's the problem? When I use the AspectJ Maven Plugin (www.mojohaus.org/aspectj-maven-plugin/), it takes the sources and compiles them and ignores changes made by Lombok. I…
NyxCode
  • 584
  • 1
  • 4
  • 13
33
votes
3 answers

@AspectJ pointcut for all methods inside package

I have this working code for a specific package, but i want to configure it for all controllers, service and dao…
Mohan Seth
  • 761
  • 2
  • 11
  • 20
33
votes
2 answers

Get value of a parameter of an annotation in Java

So I've got a code: @Path("/foo") public class Hello { @GET @Produces("text/html") public String getHtml(@Context Request request, @Context HttpServletRequest requestss){ ... } I am using AspectJ to catch all calls to getHtml method. I would…
Darek
  • 2,861
  • 4
  • 29
  • 52
33
votes
2 answers

AspectJ "around" and "proceed" with "before / after"

Let's say you have three advices: around, before and after. 1) Are before/after called when proceed is called in the around advice, or are they called before/after the around advice as a whole? 2) If my around advice does not call proceed, will the…
Gérald Croës
  • 3,799
  • 2
  • 18
  • 20
32
votes
1 answer

Spring AOP works without @EnableAspectJAutoProxy?

I am learning Spring (currently its AOP framework). Even though all sources I've read say that to enable AOP one needs to use @EnableAspectJAutoProxy annotation (or its XML counterpart) my code seems to work with annotation commented out. Is that…
lukeg
  • 4,189
  • 3
  • 19
  • 40
31
votes
2 answers

Spring AOP pointcut that matches annotation on interface

I have a service class implemented in Java 6 / Spring 3 that needs an annotation to restrict access by role. I have defined an annotation called RequiredPermission that has as its value attribute one or more values from an enum called…
Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
30
votes
2 answers

Get annotated parameters inside a pointcut

I have two annotation @LookAtThisMethod and @LookAtThisParameter, if I have a pointcut around the methods with @LookAtThisMethod how could I extract the parameters of said method which are annotated with @LookAtThisParameter? For…
Bobby
  • 18,217
  • 15
  • 74
  • 89
30
votes
8 answers

How can I make external methods interruptable?

The Problem I'm running multiple invocations of some external method via an ExecutorService. I would like to be able to interrupt these methods, but unfortunately they do not check the interrupt flag by themselves. Is there any way I can force an…
Oak
  • 26,231
  • 8
  • 93
  • 152
28
votes
17 answers

Maven project not being treated as Java in Eclipse

I'm working on a project that has lots of different Maven projects. I've been doing a bunch of JUnit testing on these projects, and usually this goes well. I open up Eclipse, right click in package explorer->Import... Existing Maven Projects and…
FuriousGeorge
  • 4,561
  • 5
  • 29
  • 52
28
votes
3 answers

How to make Lombok and AspectJ work together?

I just finished posting this issue on SO about Lombok not generating my getters/setters. It turns out that it is conflicting with AspectJ. If I disable AspectJ, then the getters/setters are appropriately generated. My guess is that the ajc compiler…
Eric B.
  • 23,425
  • 50
  • 169
  • 316
28
votes
2 answers

execution Vs. call Join point

I have two different aspect classes to count the number of non-static method calls for an execution of a test program. The first aspect counts methods on "call" join points: pointcut methodCalls() : call (!static * test..*(..)); before():…
user1843337
  • 283
  • 1
  • 3
  • 5
26
votes
1 answer

JUnit tests for AspectJ

I am trying to write Junit tests for Custom Aspect. Here is the Aspect Class Snippet: @Aspect @Component public class SampleAspect { private static Logger log = LoggerFactory.getLogger(SampleAspect.class); @Around("execution(*…
karthik
  • 773
  • 2
  • 11
  • 19
25
votes
4 answers

Use of proxies in Spring AOP

I am reading a book, which talks about enabling AspectJ support in Spring AOP. Given below is a paragraph taken from the book: To enable AspectJ annotation support in the Spring IoC container, you only have to define an empty XML element…
user2434
  • 6,339
  • 18
  • 63
  • 87
25
votes
3 answers

What does aspectj-weaver.jar do?

What does aspectj-weaver.jar do? What are its common uses?
Nook
  • 534
  • 2
  • 7
  • 14
25
votes
2 answers

AspectJ pointcuts - get a reference to the joinpoint class and name

I am using the @AspectJ style for writing aspects, to handle logging in our application. Basically I have a pointcut set up like so: @Pointcut("call(public * com.example..*(..))") public void logging() {} and then a before and after advice like…
smauel
  • 665
  • 1
  • 8
  • 14