67,517
社区成员
发帖
与我相关
我的任务
分享
public class MethodAfterInterceptor implements AfterReturningAdvice
{
public void afterReturning(Object value, Method method, Object[] arg2,
Object instance) throws Throwable
{
//请问下,这里为什么会打印三次??
System.out.println("方法名: " + method.getName() + "返回值为:" + ((CMSServiceResp)value).getResult());
}
}
<!-- 拦截 delContent(),modifyContent() -->
<bean id="aopMethodAfterInterceptor"
class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor">
<property name="advice">
<bean
class="com.XXX.imp.sv.business.content.service.MethodAfterInterceptor" />
</property>
<property name="mappedNames">
<value>delContent,modifyContent</value>
</property>
</bean>
<!-- Service对象,安装到ProxyFactoryBean对象中 -->
<bean id="aopService"
class="org.springframework.aop.framework.ProxyFactoryBean">
<!-- 拦截器 -->
<property name="interceptorNames">
<list>
<value>aopMethodAfterInterceptor</value>
</list>
</property>
<!-- 被拦截的对象 -->
<property name="target">
<bean class="com.XXX.imp.sv.business.content.service.impl.ContentManageServiceImpl">
</bean>
</property>
</bean>
ApplicationContext applicationContext = WebApplicationContextManager.getApplicationContext();
ContentManageService contentManageService= (ContentManageService)applicationContext.getBean("aopService");
contentManageService.delContent("123", "1","cpid=123");