1 22 package org.jboss.test.aop.args; 23 24 import org.jboss.aop.joinpoint.CurrentInvocation; 25 import org.jboss.aop.joinpoint.MethodInvocation; 26 27 33 public class Aspect implements PojoInterface 34 { 35 public static boolean echoCalled = false; 36 37 public String echo(String arg) 38 { 39 echoCalled = true; 40 41 if (!arg.equals("hello")) throw new RuntimeException ("Args don't match"); 42 43 try 44 { 45 return (String ) CurrentInvocation.proceed(); 46 } 47 catch (Throwable throwable) 48 { 49 throw new RuntimeException (throwable); 50 } 51 } 52 53 public static boolean wrapped = false; 54 55 public Object wrap(MethodInvocation invocation) throws Throwable 56 { 57 wrapped = true; 58 return invocation.invokeNext(); 59 } 60 61 public static boolean args = false; 62 63 public Object bunchArgs(int x, double y, float z, String str, int q) throws Throwable 64 { 65 args = true; 66 return CurrentInvocation.proceed(); 67 } 68 69 public static boolean argsWithInvocation = false; 70 71 public Object bunchArgsWithInvocation(MethodInvocation invocation, int x, double y, float z, String str, int q) throws Throwable 72 { 73 argsWithInvocation = true; 74 return invocation.invokeNext(); 75 } 76 77 78 public static boolean bunchCalled = false; 79 80 public int bunch(int x, double y, float z, String str, int q) 81 { 82 bunchCalled = true; 83 84 if (x != 1 && y != 2.2 && z != 3.3F && !str.equals("four") && q != 5) 85 { 86 throw new RuntimeException ("Arguments don't match"); 87 } 88 try 89 { 90 return ((Integer ) CurrentInvocation.proceed()).intValue(); 91 } 92 catch (Throwable throwable) 93 { 94 throw new RuntimeException (throwable); 95 } 96 } 97 98 public static boolean arg1Called = false; 99 100 public Object arg1(int x) throws Throwable 101 { 102 arg1Called = true; 103 104 if (x != 1) throw new RuntimeException ("Args don't match"); 105 return CurrentInvocation.proceed(); 106 } 107 108 public static boolean arg2Called = false; 109 110 public Object arg2(double y) throws Throwable 111 { 112 arg2Called = true; 113 114 if (y != 2.2) throw new RuntimeException ("Args don't match"); 115 return CurrentInvocation.proceed(); 116 } 117 118 public static boolean arg3Called = false; 119 120 public Object arg3(float z) throws Throwable 121 { 122 arg3Called = true; 123 124 if (z != 3.3F) throw new RuntimeException ("Args don't match for arg3: " + z); 125 return CurrentInvocation.proceed(); 126 } 127 128 public static boolean arg4Called = false; 129 130 public Object arg4(String str) throws Throwable 131 { 132 arg4Called = true; 133 134 if (!str.equals("four")) throw new RuntimeException ("Args don't match"); 135 return CurrentInvocation.proceed(); 136 } 137 138 public static boolean arg15Called = false; 139 140 public Object arg15(int x, int q) throws Throwable 141 { 142 arg15Called = true; 143 144 if (x != 1 && q != 5) throw new RuntimeException ("Args don't match"); 145 return CurrentInvocation.proceed(); 146 } 147 148 public static boolean arg24Called = false; 149 150 public Object arg24(double y, String str) throws Throwable 151 { 152 arg24Called = true; 153 154 if (y != 2.2 && !str.equals("four")) throw new RuntimeException ("Args don't match"); 155 return CurrentInvocation.proceed(); 156 } 157 } 158 | Popular Tags |