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
24
votes
1 answer

Aspectj with android library

I have a lib that use aspects and is available via maven, now I'm trying to use that lib in an android application. If I include this plug-in in the app gradle file, everything works fine, but my goal is to extract the classpath…
letz
  • 1,762
  • 1
  • 20
  • 40
23
votes
2 answers

Spring: Standard Logging aspect (interceptor)

I've found a lot of examples on how to create a custom aspect for logging using the Spring framework like this or this but did not find standard/common Spring implementation for this situation and question. Are there any standard implementations of…
Sergii Zagriichuk
  • 5,389
  • 5
  • 28
  • 45
23
votes
4 answers

Joinpoint VS ProceedingJoinPoint in AOP using aspectJ?

Can any one tell me what is the difference between Joinpoint and Proceedingjoinpoint? When to use Joinpoint and Proceedingjoinpoint in the method of aspect class? I used the JoinPoint in my AspectJ class like: @Pointcut("execution(*…
Human Being
  • 8,269
  • 28
  • 93
  • 136
23
votes
2 answers

Error when using AspectJ AOP with Java 7

I've updated Java to version "1.7.0_09-icedtea" (previously it was 1.6) and get the following message: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate be an class…
Mikhail.Mamaev
  • 7,879
  • 5
  • 24
  • 28
22
votes
4 answers

Spring Optimistic Locking:How to retry transactional method till commit is successful

I use Spring 2.5 and Hibernate JPA implementation with Java and "container" managed Transactions. I have a "after user commit" method that updates data in background and need to be committed regardless of ConcurrencyFailureException or…
knarf1983
  • 313
  • 1
  • 2
  • 9
22
votes
4 answers

Maven: compile aspectj project containing Java 1.6 source

Primary Question What I want to do is fairly easy. Or so you would think. However, nothing is working properly. Requirement: Using maven, compile Java 1.6 project using AspectJ compiler. Note: Our code cannot compile with javac. That is, it fails…
gMale
  • 17,147
  • 17
  • 91
  • 116
21
votes
1 answer

How to enable aspectj compile time weaving with Java 7 and maven

I have a project which currently works with java 6 and compile time weaving. We use the following pom to enable spring aspects and our own ones: org.codehaus.mojo aspectj-maven-plugin
Avner Levy
  • 6,601
  • 9
  • 53
  • 92
21
votes
5 answers

AspectJ Maven Plugin cannot compile my project

I try to use aspectj maven plugin for compile project with aspectj compiler and then I try to package classes into "war" file. Unfortunately, it doesn't work with following configuration (pom.xml):
dmitrievanthony
  • 1,501
  • 1
  • 15
  • 41
20
votes
4 answers

Disabling certain aspects during unit test runs

I have integration tests (load context) and unit tests running together. My code does aspectj compile time weaving using spring. My problem is that my declared advises also run during some of my unit tests. This kills the notion of a unit test,…
netta
  • 508
  • 6
  • 16
20
votes
3 answers

@AspectJ pointcut for methods that override an interface method with an annotation

How can I write an aspectj pointcut that applies to method executions which override an interface method with an annotation? For example: interface A { @MyAnnotation void method(); } class B implements A { void method(); } The pointcut…
Dr. Hans-Peter Störr
  • 25,298
  • 30
  • 102
  • 139
20
votes
9 answers

Aspect does not work with Spring boot application with external jar

I am trying to create a timer aspect for measuring methods run time. I created an annotation named @Timer: @Retention(RetentionPolicy.RUNTIME) @Target(value = {ElementType.METHOD, ElementType.TYPE}) public @interface Timer { String…
Avi
  • 21,182
  • 26
  • 82
  • 121
20
votes
4 answers

Spring AOP Advice on Annotated Controllers

I am trying to use AOP to do some processing after an annotated controller. Everything is running with no errors, but the advice is not being executed. Here is the controller code: @Controller public class HomeController { …
jdana
  • 201
  • 1
  • 2
  • 5
20
votes
2 answers

logging with AOP in spring?

I am new to spring in my office . So there is no guidance for me. I need to implement the logging with the AOP using the log4j. I have implemented the logging without AOP in basic spring MVC example ? Also did the small sample in AOP using the…
Human Being
  • 8,269
  • 28
  • 93
  • 136
20
votes
3 answers

Java Spring AOP: Using CustomizableTraceInterceptor with JavaConfig @EnableAspectJAutoProxy, not XML

Spring AOP has a method-level tracer called CustomizableTraceInterceptor. Using Spring's XML configuration approach, one would set up this tracer like so:
Abdull
  • 26,371
  • 26
  • 130
  • 172
19
votes
6 answers

Maven/AJDT project in Eclipse

I need to use aspectj in a maven project. I installed the maven plugin for eclipse (m2e), the maven aspectj plugin, and also AJDT for Eclipse. So now, when i open a new project i have "Maven Project" and "AspectJ Project". how can i make a new…
Magen
  • 191
  • 1
  • 1
  • 3