/ Published in: Java
URL: SpringAOP /AspectJExpressionPointcut
Expand |
Embed | Plain Text
package com.jal; import org.aopalliance.intercept.*; public class AudienceAroundAdvice implements MethodInterceptor{ public Audience audience; public void setAudience(Audience audience){ this.audience = audience; } public Audience getAudience(){ return audience; } public AudienceAroundAdvice(){ } @Override try{ this.audience.takeSeats(); this.audience.turnOffCellPhones(); obj = invocation.proceed(); this.audience.applause(); this.audience.demandRefund(); throw exception; } return obj; } } <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <bean id="performer-inj" class="com.jal.Performer" scope="prototype" /> <bean id="audience-inj" class="com.jal.Audience" scope="prototype" /> <bean id="audienceAroundAdvice-inj" class="com.jal.AudienceAroundAdvice" scope="prototype"> <property name="audience" ref="audience-inj" /> </bean> <bean id="performance-pointcut-inj" class="org.springframework.aop.aspectj.AspectJExpressionPointcut" scope="prototype"> <property name="expression" value="execution(* com.jal.Performer+.perform(..))" /> </bean> <bean id="audienceAdvisor-inj-1" class="org.springframework.aop.support.DefaultPointcutAdvisor" scope="prototype"> <property name="pointcut" ref="performance-pointcut-inj" /> <property name="advice" ref="audienceAroundAdvice-inj" /> </bean> <bean id="aa-inj" class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" scope="singleton"> <property name="advisorBeanNamePrefix" value="audienceAdvice-inj-1" /> </bean> </beans>
You need to login to post a comment.
