Announcement Announcement Module
Collapse
No announcement yet.
AOP not working on DAO interface Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP not working on DAO interface

    Hi all,

    i'm setting up a web server with Spring 3.0.5, and i'm having issues trying to declare an aspect on a DAO interface.

    My DAO object hierarchy (described in attached picture Attachment ) defines a template DAO base interface IBaseDAO<T>, implemented by a template DAO base abstract class: BaseDao<T> which implements a base version of all the IBaseDAO methods, including saveOrUpdate(T) amongst others.

    For each business object class, i create a specialization of the IBaseDAO<T>, and i create a DAO class that both implements that specialized interface and extends the base abstract DAO class BaseDAO<T>.

    For instance, for the Comment BO, i define the CommentDAO class (no method redefinition), that implements ICommentDAO (this interface has no method) and extends IBaseDAO<T>.

    I'd like to create an aspect that triggers when the method saveOrUpdate() is called on class CommentDAO. For that i define the following aspect:

    Code:
    <aop:config>
    	<aop:aspect ref="systemPropController">
    		<aop:before
    			pointcut="execution(* fr.magellium.training.model.dao.iface.ICommentDAO.saveOrUpdate(..))"
    			method="updateLastModifDate" />
    	</aop:aspect>
    </aop:config>
    This aspect never triggers. The only workaround I found is to declare an aspect on every call to saveOrUpdate(), whatever the class:

    Code:
    <aop:config>
    	<aop:aspect ref="systemPropController">
    		<aop:before
    			pointcut="execution(* saveOrUpdate(..))"
    			method="updateLastModifDate" />
    	</aop:aspect>
    </aop:config>
    It seems like Spring AOP doesn't recognize saveOrUpdate(..) as a method of the ICommentDAO interface.

    I can't figure out what i'm missing here...
    Attached Files

  • #2
    Try

    pointcut="execution(* fr.magellium.training.model.dao.iface.ICommentDAO+ .saveOrUpdate(..)

    Comment


    • #3
      Thanks for your reply, rishishehrawat.

      I applied your aspect definition, and it did not work either. I notice that there is a blank between '+' and '.' in your pointcut definition, is it intentional? I tried with and without the blank, it didn't make a difference.

      Comment

      Working...
      X