summaryrefslogtreecommitdiffstats
path: root/org.aspectj.lib/src/org/aspectj/lib/tracing/TraceJoinPointsBase.java
blob: 989c298e70d553d6b0658c79abd08d798458b544 (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
60
61
62
63
64
65
66
67
68
69
70
/* *******************************************************************
 * Copyright (c) 2005 Contributors.
 * All rights reserved. 
 * This program and the accompanying materials are made available 
 * under the terms of the Eclipse Public License v1.0 
 * which accompanies this distribution and is available at 
 * http://eclipse.org/legal/epl-v10.html 
 *  
 * Contributors: 
 *     Wes Isberg       initial implementation 
 * ******************************************************************/

// START-SAMPLE tracing-traceJoinPoints Trace join points executed   

package org.aspectj.lib.tracing;

import org.aspectj.lang.JoinPoint;

/**
 * Trace join points being executed in context.
 * To use this, define the abstract members in a subaspect.
 * <b>Warning</b>: this does not trace join points that do not
 * support after advice.
 * @author Jim Hugunin, Wes Isberg
 */
abstract aspect TraceJoinPointsBase {

    declare precedence : TraceJoinPointsBase, *;

    abstract protected pointcut entry();

    /** ignore join points outside this scope - use within(..) */
    abstract protected pointcut withinScope();

    protected pointcut exit(): withinScope() && call(* java..*.*(..));

    final pointcut start(): withinScope() && entry() && !cflowbelow(entry());

    final pointcut trace(): withinScope() && cflow(entry()) 
        && !cflowbelow(exit()) && !within(TraceJoinPointsBase+);

    private pointcut supportsAfterAdvice() : !handler(*)
        && !preinitialization(new(..));

    before(): start() { startLog(); }

    before(): trace() && supportsAfterAdvice(){ 
        logEnter(thisJoinPointStaticPart); 
    }

    after(): trace() && supportsAfterAdvice() { 
        logExit(thisJoinPointStaticPart); 
    }

    after(): start() { completeLog(); }
    
    abstract protected void logEnter(JoinPoint.StaticPart jp);

    abstract protected void logExit(JoinPoint.StaticPart jp);
    
    /** called before any logging */
    abstract protected void startLog();
    
    /** called after any logging */
    abstract protected void completeLog();
}

// END-SAMPLE tracing-traceJoinPoints