Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ajdt-dev] AspectJ newbie

Hi All,

I have recently joined this group.

I know it is a good idea to use AOP for functionalities which are
scattered all over the code. I have a project in which transaction control
is to be handled using AspectJ. In this project transaction control has
been done at most places but at some places it is not done. Is it a good
idea to use AspectJ for transaction control? And if yes how will it affect
already existing transaction control functionality? Should I manually go
into code and remove already existing transaction control code Â…but then
the purpose of AOP is lost.



I got this example from internet :



aspect DatabaseAspect {



  pointcut transactionalMethods ():

     execution (/* pattern for transactional methods */) ;

  before(): transactionalMethods () {

    initialiseDatabase() ;

  }

  after() returning: transactionalMethods() {

    commitTransaction() ;

  }

  after() throwing: transactionalMethods() {

    rollbackTransaction() ;

  }

}


Help is appreciated.

Thanks,

Dimple





Back to the top