Aspect configuration in XML



Elements
<aop:advisor> : It is used to Defines an advisor .
<aop:after> : It is used to Defines an after advice (method returns successfully).
<aop:before> : It is used to Defines an before advice.
<aop:around> : It is used to Defines an around advice.
<aop:after-returning> : It is used to Defines an after-returning advice.
<aop:after-throwing> : It is used to Defines an after-throwing advice.
<aop:aspect> : It is used to Defines an aspect.
<aop:aspectj-autoproxy> : It Enables aspect with annotation-driven with use of @AspectJ.
<aop:config> : This is the main top-level element. Most <aop:*> elements must be placed within this element.
<aop:pointcut>: It is used to Defines a pointcut.

Example
<aop:config>
    <aop:aspect ref="gameViewers">
        <aop:before pointcut="execution(** game.Football.playGame(..))" method="preparePlayer"/>
        <aop:before pointcut="execution(** game.Football.playGame(..))" method="startGame"/>
        <aop:after-returning pointcut="execution(** game.Football.playGame(..))" method="breakTime"/>
        <aop:after-throwing pointcut="execution(** game.Football.playGame(..))" method="endGame"/>
    </aop:aspect>
</aop:config>

PointCut declation in XML
<aop:pointcut
id="playGamePointCut"
expression="execution(** game.Football.playGame(..))" />

<aop:before pointcut-ref="playGamePointCut" method="startGame"/>
<aop:before pointcut-ref="playGamePointCut" method="endGame"/