How to instantiate spring bean without being referenced from aop:aspect
Posted
by
XDeveloper
on Stack Overflow
See other posts from Stack Overflow
or by XDeveloper
Published on 2011-11-29T15:48:56Z
Indexed on
2011/11/30
9:52 UTC
Read the original article
Hit count: 355
Using Spring and Java;
I have a pointcut which works OK. Now I want to remove the pointcut and AOP from the spring and just trigger the event with an event from inside the java code but I want "myAdvice" bean still called via Spring and its properties set.
I want to get ridoff all advice things even in java code, no more advice or any trace of AOP, I already have a nice event system working. I just want to instantiate my bean via Spring.
When I remove the second code block (one starting with "aop:config") then I noticed the bean "myAdvice" is not called and instantiated anymore. How can i stil call it set its properties without referencing it from the "aop:aspect" ?
in my application context ;
<bean id="myAdvice" class="com.myclass">
<property name="name1" ref="ref1" />
<property name="name2" ref="ref2" />
</bean>
<aop:config proxy-target-class="true">
<aop:aspect id="myAspect" ref="myAdvice">
<aop:pointcut id="myPointcut" expression="execution(* com.myexcmethod" />
<aop:around pointcut-ref="myPointcut" method="invoke" />
</aop:aspect>
</aop:config>
© Stack Overflow or respective owner