Results 1 to 3 of 3

Thread: TransactionProxyFactoryBean interception

  1. #1
    Join Date
    Aug 2004
    Posts
    123

    Default TransactionProxyFactoryBean interception

    I'm working on a cacheing mechanism for a Spring/Hibernate/Struts based application. All access to the DAO layer is via a service facade, using TransactionProxyFactoryBean, so I'd have something like this for each "subject area":

    <bean id="organisationService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager">
    <ref local="transactionManager"/>
    </property>
    <property name="transactionAttributes">
    <props>
    <prop key="store*">PROPAGATION_REQUIRED</prop>
    <prop key="delete*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    <property name="target">
    <ref local="organisationServiceTarget"/>
    </property>
    </bean>


    <bean id="organisationServiceTarget" class="mypackage.service.OrganisationServiceImpl">
    <property name="organisationDAO">
    <ref local="organisationDAO"/>
    </property>
    </bean>

    <bean id="organisationDAO" parent="baseDAO" class="mypackage.dao.organisation.HibernateOrganis ationDAO"/>


    Now, I want to throw cacheing into the mix - purging the cache when certain methods are used, checking and perhaps using the content of the cache when other methods are used. My first attempt used BeanNameAutoProxyCreator to allow me to apply my interceptor to all relevant beans, but I found that if I match *Service, the only method that gets intercepted is the getObject method of the TransactionProxyFactoryBean, NOT the methods of the proxied object. Changing this to *ServiceTarget (i.e, the objects themselves) gets the right methods called.

    But I'm wondering whether this is the right approach at all. Should I be adding stuff into the configuration of the service beans themselves instead, namely PreInterceptors or PostInterceptors for the TransactionProxyFactoryBean, or perhaps specifying a MethodPointcut for the TransactionInterceptor?

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Autoproxying or pre- or post-interceptors should work. I would probably incline to the latter approach, with a base template, as it's a bit more convenient.

    Note that you can use autowiring with TransactionProxyFactoryBean if you use an "inner bean" for the target, instead of the X/XTarget approach.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Aug 2004
    Posts
    123

    Default

    Thanks, Rod, I'll look into those options. And thanks, too, for Spring itself, a fabulous piece of work.

    John

Similar Threads

  1. Simple Interception
    By belaran in forum AOP
    Replies: 6
    Last Post: Jul 25th, 2005, 11:29 AM
  2. aop-alliance interfaces for interception
    By sven.bauer in forum Architecture
    Replies: 3
    Last Post: Jan 25th, 2005, 02:59 AM
  3. Replies: 5
    Last Post: Nov 10th, 2004, 01:44 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
  •