1 17 18 package org.objectweb.jac.aspects.tracing; 19 20 import java.util.*; 21 import org.objectweb.jac.core.*; 22 import org.objectweb.jac.util.Log; 23 import org.objectweb.jac.wrappers.*; 24 25 33 34 public class TracingAC extends AspectComponent implements TracingConf { 35 36 VerboseWrapper timedWrapper; 37 VerboseWrapper namedWrapper; 38 VerboseWrapper stackWrapper; 39 VerboseWrapper wrappersWrapper; 40 41 public TracingAC () { 42 timedWrapper = new VerboseWrapper(this,VerboseWrapper.TIMED); 43 namedWrapper = new VerboseWrapper(this,VerboseWrapper.NAMED); 44 stackWrapper = new VerboseWrapper(this,VerboseWrapper.STACK); 45 wrappersWrapper = new VerboseWrapper(this,VerboseWrapper.WRAPPERS); 46 } 47 48 public void addTrace(String wrappeeExpr, 49 String wrappeeClassExpr, 50 String wrappeeMethodExpr) { 51 pointcut(wrappeeExpr, wrappeeClassExpr, wrappeeMethodExpr, 52 timedWrapper, null); 53 } 54 55 57 public void addNamedTrace(String wrappeeExpr, 58 String wrappeeClassExpr, 59 String wrappeeMethodExpr) { 60 pointcut(wrappeeExpr, wrappeeClassExpr, wrappeeMethodExpr, 61 namedWrapper, null); 62 } 63 64 public void addStackTrace(String wrappeeExpr, 65 String wrappeeClassExpr, 66 String wrappeeMethodExpr) { 67 68 pointcut(wrappeeExpr, wrappeeClassExpr, wrappeeMethodExpr, 69 stackWrapper, null); 70 } 71 72 public void addWrappersTrace(String wrappeeExpr, 73 String wrappeeClassExpr, 74 String wrappeeMethodExpr) { 75 pointcut(wrappeeExpr, wrappeeClassExpr, wrappeeMethodExpr, 76 wrappersWrapper,null); 77 } 78 79 public void addRecording(String wrappeeExpr, 80 String wrappeeClassExpr, 81 String wrappeeMethodExpr) { 82 83 pointcut(wrappeeExpr+" && !recorder0", 84 wrappeeClassExpr, 85 wrappeeMethodExpr, 86 RecordingWrapper.class.getName(), null, false); 87 } 88 89 Hashtable counters = new Hashtable(); 90 91 public void addCounter(String name, 92 String wrappeeExpr, 93 String wrappeeClassExpr, 94 String wrappeeMethodExpr) { 95 96 Counter c = (Counter) counters.get(name); 97 if (c == null) { 98 c = new Counter(); 99 counters.put(name, c); 100 } 101 pointcut(wrappeeExpr, wrappeeClassExpr, wrappeeMethodExpr, 102 new SimpleCountingWrapper(this,c), null); 103 } 104 105 public void addOptimizedCounter(String name, 106 String wrappeeExpr, 107 String wrappeeClassExpr, 108 String wrappeeMethodExpr, 109 String fieldName, 110 String argNumber) { 111 112 Counter c = (Counter) counters.get(name); 113 if (c == null) { 114 c = new Counter(); 115 counters.put(name,c); 116 } 117 if (!fieldName.equals("")) { 118 pointcut(wrappeeExpr, wrappeeClassExpr, 119 wrappeeMethodExpr, 120 new OptimizedCountingWrapper(this,c,fieldName), 121 null); 122 } 123 if (!argNumber.equals("")) { 124 pointcut(wrappeeExpr, wrappeeClassExpr, 125 wrappeeMethodExpr, 126 new OptimizedCountingWrapper( 127 this, c, (new Integer (argNumber)).intValue()), 128 null ); 129 } 130 } 131 132 141 142 public boolean beforeRunningWrapper (Wrapper wrapper, 143 String wrappingMethod) { 144 if (attr("tracing.globalIncr")!=null) 145 return false; 146 return true; 147 } 148 149 150 } 151 | Popular Tags |