1 8 package examples.logging; 9 10 import org.codehaus.aspectwerkz.annotation.Annotation; 11 import org.codehaus.aspectwerkz.joinpoint.JoinPoint; 12 import org.codehaus.aspectwerkz.joinpoint.MethodSignature; 13 import org.codehaus.aspectwerkz.definition.Pointcut; 14 import org.codehaus.aspectwerkz.definition.Pointcut; 15 16 20 public class ArgAspect { 21 22 private int m_level = 0; 23 24 27 public Object around1(final JoinPoint joinPoint, int ai, String as) throws Throwable { 28 indent(); 29 m_level++; 30 System.out.println(" ==> around1 -- pre " + ai + ", " + as); 31 Object result = joinPoint.proceed(); 32 m_level--; 33 indent(); 34 System.out.println(" ==> around1 -- post " + ai + ", " + as); 35 return result; 36 } 37 38 41 public void before1(final JoinPoint joinPoint, int ai, String as) throws Throwable { 42 indent(); 43 m_level++; 44 System.out.println(" ==> before1: " + ai + ", " + as); 45 } 46 47 50 public void after1(final JoinPoint joinPoint, int ai, String as) throws Throwable { 51 m_level--; 52 indent(); 53 System.out.println(" ==> after1: " + ai + ", " + as); 54 } 55 56 59 public void before2(final JoinPoint joinPoint, String as, int ai) throws Throwable { 60 indent(); 61 m_level++; 62 System.out.println(" ==> before2: " + as + ", " + ai); 63 } 64 65 68 public void after2(final JoinPoint joinPoint, String as, int ai) throws Throwable { 69 m_level--; 70 indent(); 71 System.out.println(" ==> after2: " + as + ", " + ai); 72 } 73 74 77 public Object around3(final JoinPoint joinPoint, String [] sarr) throws Throwable { 78 indent(); 79 m_level++; 80 System.out.println("==> around3 -- pre " + sarr); 81 Object result = joinPoint.proceed(); 82 m_level--; 83 indent(); 84 System.out.println("==> around3 -- post " + sarr); 85 return result; 86 } 87 88 91 public void before3(final JoinPoint joinPoint, String [] sarr) throws Throwable { 92 indent(); 93 m_level++; 94 System.out.println("==> before3: " + sarr); 95 } 96 97 100 public void after3(final JoinPoint joinPoint, String [] sarr) throws Throwable { 101 m_level--; 102 indent(); 103 System.out.println("==> after3: " + sarr); 104 } 105 106 109 public Object aroundField(final JoinPoint joinPoint) throws Throwable { 110 indent(); 111 m_level++; 112 System.out.println("==> aroundField -- pre"); 113 Object result = joinPoint.proceed(); 114 m_level--; 115 indent(); 116 System.out.println("==> aroundField -- post"); 117 return result; 118 } 119 120 123 public void beforeField(final JoinPoint joinPoint) throws Throwable { 124 indent(); 125 m_level++; 126 System.out.println("==> beforeField"); 127 } 128 129 132 public void after3(final JoinPoint joinPoint) throws Throwable { 133 m_level--; 134 indent(); 135 System.out.println("==> beforeField"); 136 } 137 138 141 Pointcut pc1(int i, String s) { 142 return null; 143 } 144 145 148 Pointcut pc2(String [] sarr) { 149 return null; 150 } 151 152 155 Pointcut pc3() { 156 return null; 157 } 158 159 162 Pointcut pcSet() { 163 return null; 164 } 165 166 169 Pointcut pcGet() { 170 return null; 171 } 172 173 private void indent() { 174 for (int i = 0; i < m_level; i++) { 175 System.out.print(" "); 176 } 177 } 178 } | Popular Tags |