-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoggingAspect.java
57 lines (46 loc) · 2.4 KB
/
LoggingAspect.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.ysingh.springaop.expression.aspect;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@Order(1)
@Aspect
@Component
public class LoggingAspect {
@Before("execution(public void addAccount())")
public void beforeAddAccountAdvice() {
System.out.println("\n====>>> beforeAddAccountAdvice - Executing @Before advice on addAccount()");
}
@Before("execution(public void com.ysingh.springaop.expression.dao.AccountDAO.addAccount())")
public void beforeAccountDAOAddAccountAdvice() {
System.out.println("\n====>>> beforeAccountDAOAddAccountAdvice - Executing @Before advice only on AccountDAO addAccount()");
}
@Before("execution(public void add*())")
public void beforeAnyMethodStartWithAddAdvice() {
System.out.println("\n====>>> beforeAnyMethodStartWithAddAdvice - Executing @Before advice on any method start with add");
}
@Before("execution(boolean add*())")
public void beforeReturnTypeMatchAdvice() {
System.out.println("\n====>>> beforeReturnTypeMatchAdvice - Executing @Before advice on boolean return type method start with add");
}
@Before("execution(* add*())")
public void beforeAnyReturnTypeMatchAdvice() {
System.out.println("\n====>>> beforeAnyReturnTypeMatchAdvice - Executing @Before advice on any return type method start with add");
}
@Before("execution(* add*(com.ysingh.springaop.expression.model.Account))")
public void beforeSpeficParameterMatchAdvice() {
System.out.println("\n====>>> beforeSpeficParameterMatchAdvice - Executing @Before advice on specific parameter matching");
}
@Before("execution(* add*(com.ysingh.springaop.expression.model.Account, ..))")
public void beforeParameterMatchFollowedByAnyNumberOfArgumentAdvice() {
System.out.println("\n====>>> beforeParameterMatchFollowedByAnyNumberOfArgumentAdvice - Executing @Before advice on parameter matching followed by any number of arguments");
}
@Before("execution(* add*(..))")
public void beforeAnyParameterMatchAdvice() {
System.out.println("\n====>>> beforeAnyParameterMatchAdvice - Executing @Before advice on match any parameter");
}
@Before("execution(* com.ysingh.springaop.expression.dao.*.*(..))")
public void beforePackageNameMatchAdvice() {
System.out.println("\n====>>> beforePackageNameMatchAdvice - Executing @Before package name match parameter");
}
}