Results 1 to 4 of 4

Thread: Simple Regular expression problem

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Posts
    17

    Default Simple Regular expression problem

    hello,

    I've written an interceptor for caching,
    and try to assigned it to some of my service methods,
    I want to do that with the least xml in applicationContext.xml
    I want to use RegexpMethodPointcutAdvisor, and give the full name of the method like:
    mypackage.MyClass.myMethod

    and it doesn't work if I don't specify both Interface and Implementation class.

    see my xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans default-autowire="byName">

    <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy .DefaultAdvisorAutoProxyCreator"/>

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="location">
    <value>classpath:/jdbc.properties</value>
    </property>
    </bean>


    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName">
    <value>${jdbc.driverClassName}</value>
    </property>
    <property name="url">
    <value>${jdbc.url}</value>
    </property>
    <property name="username">
    <value>${jdbc.username}</value>
    </property>
    <property name="password">
    <value>${jdbc.password}</value>
    </property>
    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource">
    <ref local="dataSource"/>
    </property>
    <property name="mappingResources">
    <list>
    <value>test/User.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
    <prop key="hibernate.cache.provider_class">net.sf.hibern ate.cache.EhCacheProvider</prop>
    <prop key="hibernate.cache.use_query_cache">true</prop>
    </props>
    </property>
    </bean>

    <bean id="userDao" class="test.UserDaoImpl"/>
    <bean id="userService" class="test.UserServiceImpl"/>


    <bean id="cachePointCutAdvisor" class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">
    <property name="advice">
    <bean class="org.springframework.aop.interceptor.cache.M emoryCacheInterceptor"/>
    </property>
    <property name="patterns">
    <list>
    <value>test.UserService.getUsers</value>
    <value>test.UserServiceImpl.getUsers</value>
    </list>
    </property>
    </bean>
    </beans>

    Write both interface and implementation class doesn't seem good practice...
    Has anyone experience such thing?

    thanks.

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Take a look at Caching the result of methods using Spring and EHCache. This does not answer your question, but it may help.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Jan 2005
    Location
    Sydney, Australia
    Posts
    32

    Default

    I'm having this problem as well. I want to intercept calls on a particular implementation of a method that is defined in an interface. However unless I specify both the interface and the implementing class in the pointcut regexp. It doesn't work. Is this intentional?

    Here is the my basic configuration:
    Code:
    <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" />
    
    <bean id="connectionAdvice" class="foo.ConnectionAdvice"/>
    
    <bean id="connectionAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
        <property name="advice">
            <ref bean="connectionAdvice" />
        </property>
        <property name="patterns">
            <list>
                <!-- see details below -->
                ...
            </list>
        </property>
    </bean>
    Now lets say I have an interface "foo.Something" that defines a method "doSomething". Now I implement "foo.SomethingImpl which implements this interface. I want to intercept calls to SomethingImpl.doSomething. Specifying the implementation class method in the RegexpMethodPointcutAdvisor patterns does not work:
    Code:
    <value>foo\.SomethingImpl\.doSomething</value>
    Neither does specifying the interface class method:
    Code:
    <value>foo\.Something\.doSomething</value>
    However if I specify both, it works:
    Code:
    <value>foo\.Something\.doSomething</value>
    <value>foo\.SomethingImpl\.doSomething</value>
    Am I missing something here?

  4. #4
    Join Date
    Jan 2005
    Posts
    17

    Default

    I have reported this bug and it has been fixed on version 1.1.4.

Similar Threads

  1. Problem with Simple RMI Sample
    By con19m32 in forum Remoting
    Replies: 2
    Last Post: Jun 27th, 2007, 12:38 AM
  2. Replies: 0
    Last Post: Oct 6th, 2005, 03:41 PM
  3. problem running simple aop!
    By khalidhajsaleh in forum AOP
    Replies: 2
    Last Post: Jul 27th, 2005, 01:37 PM
  4. Replies: 2
    Last Post: Jan 24th, 2005, 09:07 AM
  5. Replies: 3
    Last Post: Sep 1st, 2004, 12:38 PM

Posting Permissions

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