Announcement Announcement Module
Collapse
No announcement yet.
intercept embeded service method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • intercept embeded service method

    For example, a service class has 2 public method (mA and mB), mA will call mB. in configuration, I surround an interceptor iB on mB. Normally, if call mA, interceptor iB won't be invoked as it is called inside another service bean method. But in my case, I want to interceptor also can be invoke, ie, call mA->interceptor iB-> mB. Is there any solution?

    For code:

    Code:
    public class ServiceBean{
     public void mA(){
        mB();
     }
    
     public void mB(){
       //... do something
     }
    }
    Configuration
    Code:
        <bean id="iB" class="org.springframework.orm.hibernate3.HibernateInterceptor">
        	<property name="sessionFactory" ref="sessionFactory"/>
    	</bean>
    	
    	<aop:config proxy-target-class="true">
    		<aop:advisor advice-ref="iB" pointcut="execution(* *..service.ServiceBean.mB(..))"/>
    	</aop:config>

  • #2
    This cannot be done with Spring AOP. You will need to switch to a full blown AOP solution like AspectJ in combination with loadtime or compile time weaving.

    Comment

    Working...
    X