Announcement Announcement Module
Collapse
No announcement yet.
Spring WS endpoint transaction AOP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring WS endpoint transaction AOP

    Hi,

    I've created a web-service based on the holiday example.
    My endpoint classes call a number of manager classes.

    I want to surround the endpoint classes (using AOP) with a transaction so that all manager db actions are atomic.

    I searched a lot but have not yet found the answer, please advice!

    Les

  • #2
    Hi,

    Well I wouldn't do this on the endpoint part. The transaction management with AOP should be implemented on the DAO Layer.

    Your architecture should look something like this:

    * Endpoints --> Web-Service implementations --> DAO Layer

    For example:

    Code:
    <!--  ========================= ASPECT CONFIGURATION ======================== 
      --> 
    - <!-- 		Transaction advice definition, based on method name patterns.
    		Defaults to PROPAGATION_REQUIRED with read-only hint for all methods whose name starts with
    		"start", and to PROPAGATION_REQUIRED for all other methods.
    	
      --> 
    - <tx:advice id="txAdvice" transaction-manager="txManager">
    - <tx:attributes>
      <tx:method name="start*" read-only="true" /> 
      <tx:method name="*" /> 
      </tx:attributes>
      </tx:advice>
    - <aop:config>
    - <!-- 			This definition creates auto-proxy infrastructure based on the given pointcut,
    			expressed in AspectJ pointcut language. Here: applying the advice named
    			"txAdvice" to all methods on classes extended by interfaces defined in at.ontec.econtrol.service.
    		
      --> 
      <aop:advisor pointcut="execution(* com.service.*.*(..))" advice-ref="txAdvice" /> 
    
    <!--  TransactionManager for JDBC DataSource 
      --> 
    - <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource" ref="dataSource" /> 
      </bean>
    There you have advisor, advise and transaction manager. That is everything what you need. Look at examples of spring-ws.

    Regards,

    Music

    Originally posted by Leslie Noth View Post

    I want to surround the endpoint classes (using AOP) with a transaction so that all manager db actions are atomic.

    Les

    Comment


    • #3
      Hi there,
      The transaction management with AOP should be implemented on the DAO Layer.
      You mean on the service layer, that's also what the example code does.

      But I get the general idea: I will make a service class and surround that instead of the endpoint.

      "Almost any programming problem can be solved with enough levels of indirection"

      Thanx,
      Les
      Last edited by Leslie Noth; Oct 7th, 2009, 09:09 AM.

      Comment

      Working...
      X