[jboss-user] [JBoss AOP Users] - aop.xml to pass parameters to interceptor

nizzy do-not-reply at jboss.com
Thu Nov 19 08:44:19 EST 2009


Hi All,

I'm experiencing behaviour that seems bizarre to me, hoefully someone can explain it to me.

aop.xml


  | <?xml version="1.0" encoding="UTF-8"?>
  | <aop>
  | 	
  | 	<bind pointcut="execution(public CardEmailUtil->new())">
  | 		<interceptor class="GenericInterceptor">
  | 			<attribute name="mockObjectName">MockEmailer</attribute>
  | 		</interceptor>
  | 	</bind>
  | 	
  | 	<bind pointcut="execution(public CardJPAHelper->new(..))">
  | 		<interceptor class="GenericInterceptor">
  | 			<attribute name="mockObjectName">mock-jpa-helper</attribute>
  | 		</interceptor>
  | 	</bind>
  | 	
  | </aop>
  | 

So i'm using AOP to mock out certain calls when unit testing. I thought I could use a GenericInterceptor and pass it different attributes, shown in aop.xml.

However this is not the behaviour I'm experiencing. Although I'm intercepting the CardJPAHelper constructor, the mockObjectName set in the GenericInterceptor is "MockEmailer".

Apparently it is the first entry in aop.xml that sets the mockObjectName, I have verified this by changing the order they appear in the xml.

Have I misunderstood how to define the pointcut in aop.xml?

Any help appreciated.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4266548#4266548

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4266548



More information about the jboss-user mailing list