Announcement Announcement Module
Collapse
No announcement yet.
method call is not being intercepted ! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • method call is not being intercepted !

    I am trying to cache method result using Ehcache & trying to serve subsequent requests from cache using AOP.

    But I coudn't see the method call being intercepted.Code is working fine otherwise.

    am I missing anything?

    my bean config are as follows

    Code:
    <bean id="ServiceXML" class="test.xyz.NRXMLService"/>
    
    <bean id="Services" class="org.springframework.aop.framework.ProxyFactoryBean">
     <property name="target">
       <ref local="ServiceXML"/>
       </property>
       <property name="proxyTargetClass">
    <value>true</value>
    </property>
      <property name="interceptorNames">
        <list>
          <value>methodCachePointCut</value>
        </list>
      </property>
    </bean>
    trying to intercept executeNR(someuserbean) using

    Code:
    <bean id="methodCachePointCut" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
      <property name="advice">
        <ref local="methodCacheInterceptor"/>
      </property>
      <property name="patterns">
        <list>
          <value>.*executeNR</value>
        </list>
      </property>
    </bean>
    the other following stuff is working fine when used in other prj

    Code:
    <bean id="methodCacheInterceptor" class="test.xyz.MethodCacheInterceptor">
      <property name="cache">
        <ref local="methodCache" />
      </property>
    </bean>
    
    <bean id="methodCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
      <property name="cacheManager">
        <ref local="cacheManager"/>
      </property>
      <property name="cacheName">
        <value>testCache</value>
      </property>
    </bean>
    
    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
      <property name="configLocation">
        <value>/WEB-INF/ehcache.xml</value>
      </property>
    </bean>
    NRXMLService .........

    Code:
    public class NRXMLService implements IService {
    	private static final Log log = LogFactory.getLog(NRXMLService.class);
    	public String executeNR(RequestBean requestBean) {
    		log.debug("in NRXMLService");
    		
    		 blah. blah....
    	}
    	}

    NRXMLService.executeNR(somebean) is made from an action class by getting reference to NRXMLService using ApplicationContext

    Appreciate any inputs!!
    Thanks
    Naren

  • #2
    One thing to check is that you are actually looking up the correct bean e.g. "Services". It's quite a common problem.

    Comment

    Working...
    X