You need to use "around" advice. You define the advice around the ClassA.getByName() and take a PreceedingJoinPoint.
Something like the following (no guarantee to work or compile, just thinking aloud):
Code:
<aop:config>
<aop:aspect id="classAInterceptor" ref="adviceBean">
<aop:pointcut id="classAGetByNameMethod" expression="execution(* ClassA+.getByName(*))"/>
<aop:advisor pointcut-ref="classAGetByNameMethod" method="interceptMethod"/>
</aop:aspect>
</aop:config>
<bean id="adviceBean" class="com.you.YourAdvice">
<constructor arg>
<bean class="com.you.ClassB"/>
</constructor-arg>
</bean>
and the code:
Code:
public class YourAdvice {
private ClassB classB;
public YourAdvice(ClassB classB) {
this.classB = classB;
}
public void interceptMethod(ProceedingJoinPoint p) {
Object o = getArgs()[0];// the string argument
String arg = (String)o;
return this.classB.getByName(arg);
}
}
The horrible type cast can be avoided by using the pointcut to pick out the string argument etc.
For more info, please read http://static.springframework.org/sp...rence/aop.html and if you are new to 2.5; http://static.springframework.org/sp...l#new-in-2-aop