Spring and aspectj, a non-proxy object interception method

I want to intercept a method from an uncropped object.

I have an instance of a class MyClass myClassInstance=new MyClass()and I want to intercept the method call myClassInstance.

I know that everything works well with proxies, but I need an aspect on non-proxies.

Is it possible?

Thank.

+3
source share
3 answers

Perhaps, but it is undesirable.

You can use @Configurable, and AspectJ will intercept calls. Read the 7.8.1 Using AspectJ for Dependencies by introducing domain objects with Spring in the documentation section on this.

- AspectJ "" , ( ), , Spring.

, , - , . - , , . , 6 . , , . . , - .

+5

Spring, (, , ), AspectJ , , AspectJ. .

+1

You can enable re-checking boot time in Spring. Then the class loader will weave all the aspects that you define into your classes when they are loaded - regardless of whether they are created using Spring.

You need to enable LTW by adding this line to your context file:

See: http://static.springsource.org/spring/docs/3.0.0.M4/spring-framework-reference/html/ch07s08.html#aop-aj-ltw

0
source

Source: https://habr.com/ru/post/1775584/


All Articles