Questions tagged [spring-aop]

Spring AOP is the Spring Framework's version of AOP, implemented in pure Java and using the @AspectJ annotations from the AspectJ project. Spring AOP works through dynamic JDK or CGLib Proxies.

Spring AOP is explained in the

Spring 3.0.x Online Reference > 7. Aspect Oriented Programming with Spring

Note that there is an increasing tendency to replace Spring AOP with static AspectJ compilation. This Approach is explained in Section: 7.8 Using AspectJ with Spring applications

AspectJ in Action is an excellent reference for both Spring AOP and AspectJ

The pre-3.0 XML-based Spring AOP approach is explained in Appendix B. Classic Spring AOP Usage

2584 questions
0
votes
1 answer

how to unit test Aspect annotation

I have defined an Aspect and it will be used when the method is annotated. Please see the sample code below @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface PredefinedCheck { } @Aspect @Component public class…
Laodao
  • 1,547
  • 3
  • 17
  • 39
0
votes
0 answers

Running aspect on an Annotated Class using AspectJ

I have a class annotated with a custom annotation. I want to run an aspect that should trigger before all the method calls and constructor call whenever an object or static method of that class is called. Can we do this in AspectJ? Annotation…
gamelover
  • 15
  • 4
0
votes
2 answers

Can Spring AOP be applied to specific fields when creating DTO?

I want to mask personal information when a Java DTO is created. I created an PersonalInfo annotation and added it to the field I want to mask. However, I don't know how to write an advice in the PersonalInfoAspect class. @Getter @Builder public…
kaven
  • 5
  • 3
0
votes
0 answers

Are Spring AOP proxy classes removed by Garbage collector?

If my project has multiple pointcuts defined for 25 different classes. Suppose a request is processed using all these classes. So as per Spring AOP, proxies will be created for all 25 classes. Since these proxies are stored in memory. If huge number…
0
votes
1 answer

How to pass an object loaded in aspect function to the annotated method

I am using spring aop to create an annotation for some crosscut purpose. Below is the sample: @Aspect @Component @Slf4j public class MyAspect { @Autowired private MyService myService @Before("@annotation(MyAnnotationCheck)") …
Laodao
  • 1,547
  • 3
  • 17
  • 39
0
votes
0 answers

Dynamically add kafka avro serializer properties at runtime in camel application

i am using camel 2.25 , due to some reason i am unable to upgrade to higher version, i need to add avro serialization support, the avro serialization properties can be set in camel 3.x version in additional properties, but in 2.25 support is not…
triples13
  • 206
  • 4
  • 18
0
votes
0 answers

Why can't Spring AOP determine if proxy should be made for @target?

I can understand how @target expression works, but I wonder why applying @target has to be determined after loading Spring applications (after all beans are created). In my thought, right after objects to be registered as a bean are created, when…
davin111
  • 56
  • 5
0
votes
1 answer

How can I find the AOP Advice used for @Transactional?

How can I see the AOP Advice used for @Transactional from Spring framework. I'm using Intellij, and using command Ctrl + click I can go to Transactional interface and here is created the annotation Transactional ant it looks like…
elvis
  • 956
  • 9
  • 33
  • 56
0
votes
0 answers

What are the different ways to check the definition of annotation in any framework using Intellij

I wanted to check the implementation of some annotation in spring, let us say Transactional. Is there any way to find the defining class where what should happen when an annotation is used, is written? Based on some experience and reading docs, I…
royatirek
  • 2,437
  • 2
  • 20
  • 34
0
votes
0 answers

How to add @Priority annotation with different values in aspectJ

I have an interface and a bunch of classes implementing that interface. I want to add @Priority(xxx) annotation to all these classes with changing value as depicted below. public interface IMyInterface{} Before : public classA implements…
0
votes
2 answers

Cannot use @Aspect annotation in Spring 5

I was implementing aspect-oriented programming. But I cannot add @Aspect annotation even though I have added the aspectjweaver dependency in my POM.xml. You can find my code below This is my POM.xml file
0
votes
1 answer
0
votes
1 answer

How to exclude sub package in pointcut expression in spring AOP

I have searched on it but didnt get my required answer about including scan base package and excluding a sub package. eg: project…
Joe
  • 479
  • 3
  • 8
  • 31
0
votes
1 answer

Exception handler is not called when exception is thrown because of Interceptor Around

I have a method handleException that return a ResponseEntity : @ExceptionHandler({Exception.class}) public ResponseEntity handleException(Exception e) { Map data = new HashMap<>( ); List temp; data.put( "message",…
khalid tounoussi
  • 499
  • 5
  • 21
0
votes
1 answer

Possible to use Spring AOP (AspectJ) with Kotlin properties?

Is it possible to use Spring AOP (AspectJ) with Kotlin properties? Specifically due to how Kotlin compiles properties to Java: a getter method, with the name calculated by prepending the get prefix a setter method, with the name calculated by…
Bennett Lynch
  • 554
  • 4
  • 11
1 2 3
99
100