Declaring a pointcut:-
A named pointcut can be declared inside an <aop:config> element, enabling the
pointcut definition to be shared across several aspects and advisors.
A pointcut representing the execution of any business service in the service
layer could be defined as follows:
<aop:config>
<aop:pointcut id="businessService"
expression="execution(* com.xyz.myapp.service..(..))"/>
</aop:config>
A pointcut helps in determining the join points (ie methods) of interest to be executed with different advices. While working with XML Schema based configuration, pointcut will be describrd as follows:
<aop:config> <aop:aspect id="myAspect" ref="aBean">
<aop:pointcut id="businessService"
expression="execution(* com.xyz.myapp.service..(..))"/>
...
</aop:aspect>
</aop:config>
<bean id="aBean" class="...">
...
</bean>
The following example defines a pointcut named 'businessService' that will match the execution of getId() method available in Register class under the package com.r4r.in:
<aop:config> <aop:aspect id="loginAspect" ref="loginAspect">
<aop:pointcut id="businessService"
expression="execution(* com.r4r.in.Register.getId(..))"/>
...
</aop:aspect>
</aop:config>
<bean id="loginAspect" class="com.r4r.in.Register.loginAspect">
...
</bean>