Declaring advices by R4R Team

Declaring advices:-
Advice is associated with a pointcut expression, and runs before, after, or around method executions matched by the pointcut. The pointcut expression may be either a simple reference to a named pointcut, or a pointcut expression declared in place.You can declare any of the five advices using @{ADVICE-NAME} annotations.
 

1 Before advice
Before advice is declared in an aspect using the @Before annotation:

import org.aspectj.lang.annotation.Aspect;

import org.aspectj.lang.annotation.Before;

@Aspect

public class BeforeExample {

@Before("execution(* com.xyz.myapp.service.(..))")

public void logRequiredTask() {

// ...

}}

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!