Results 1 to 2 of 2

Thread: intercept embeded service method

  1. #1
    Join Date
    Sep 2005
    Posts
    8

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •