aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs186/462821/AbstractLoggerAspect.java
blob: 5b9e3c14ba729dba0d521a4286898356fc7531a3 (plain)
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
58
59
//package no.kantega;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public abstract class AbstractLoggerAspect {

    @Pointcut
    public abstract void debugJoinPoints();

    @Pointcut
    public abstract void infoJoinPoints();

    @Pointcut
    public abstract void excludedJoinPoints();


    @Pointcut("execution(public String Object+.toString()) || call(public String Object.toString())"
            + "|| call(public int Object.hashCode()) || call(public boolean Object.equals())"
            + "|| execution(public static void Object+.main(String[])) ")
    public void defaultExcludedJoinPoints() {}

    @Pointcut("(infoJoinPoints() && !defaultExcludedJoinPoints() && !excludedJoinPoints())")
    public void infoJoinPointsToLog() {}

/*
    @Pointcut("(debugJoinPoints() && !defaultExcludedJoinPoints() && !infoJoinPointsToLog() && !excludedJoinPoints())")
    public void debugJoinPointsToLog() {}


    @Around("debugJoinPointsToLog()")
    public Object handleDebugJoinPointsToLog(ProceedingJoinPoint thisJoinPoint)
    {
        // do stuff
        try {
            return thisJoinPoint.proceed();
        } catch (Throwable throwable) {
            throw new RuntimeException("foo");
        }
        // then do other stuff
    }
*/

    @Around("infoJoinPoints()")
    public Object handleInfoJoinPointsToLog(ProceedingJoinPoint thisJoinPoint)
    {
        // first do stuff
        try {
            return thisJoinPoint.proceed();
        } catch (Throwable throwable) {
            throw new RuntimeException("foo");
        }
        // then do other stuff
    }
}