Results 1 to 2 of 2

Thread: transactionAttributes if single entry method

  1. #1
    Join Date
    Oct 2004
    Location
    Brussels, Belgium
    Posts
    1

    Default transactionAttributes if single entry method

    All the services of my business tier have the same signature:

    Code:
    public class myFacade extends BusinessFacade {
      public void myService1(BusinessRequest req, BusinessReponse resp) throws BusinessException;
      public void myService2(BusinessRequest req, BusinessReponse resp) throws BusinessException;
    }
    In the abstract ancestor of business facades, I have defined a single entry method which is a dispatcher to the appropriate service (ie "myServiceX) :

    Code:
    public abstract class BusinessFacade {
      public void invokeService(BusinessRequest req, BusinessReponse resp) throws BusinessException {
      // invoke in concrete class the method named <req.getRequestedService&#40;&#41;> - eg "myService1"
    &#125;
    Now, I would like to define the transaction attributes of every concrete service (myService1, myService2) :

    Code:
    <bean id="..." class="...TransactionProxyFactoryBean">
    <property name="transactionAttributes">
      <props>
        <prop key="invokeService">PROPAGATION_REQUIRED</prop>
        <prop key="myService1">PROPAGATION_REQUIRED</prop>
        <prop key="myService2">PROPAGATION_REQUIRED,readOnly</prop>
      </props>
    But as the generic method invokeService() is supposed to be THE - only - "normal" way of calling business service (although you could invoke directly myService1), it is always that front method that is first called on the TransactionProxy. Therefore I cannot reasonnably set it to "ReadOnly". The subsequent call/forward to the wanted service (myService1) is done on the concrete facade - no more on the proxy , making so unnecessary my settings for myService1 & myService2...

    Question:
    How could I ensure a read-only transaction for myService2 knowing that myService2 is actually a (so to say) nested service of the non read-only primary invokeService service ?

    Thanks in advance,

    Bernard.

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    It would tie your ancestor class slightly to Spring, but in your ancestor class you could have a method:

    Object getThis() {
    return AopContext.currentProxy();
    }

    and use this to get the current proxy for the class you are in, and dispatch through that. Note that you have to set your transaction proxies (via the related property) to expose the current proxy as a threadlocal.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. PerformanceMonitorInterceptor
    By tnist in forum AOP
    Replies: 3
    Last Post: Aug 24th, 2005, 01:39 PM
  5. Replies: 1
    Last Post: Jul 28th, 2005, 05:08 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
  •