1 package org.sapia.soto.aop; 2 3 import net.sf.cglib.proxy.MethodProxy; 4 5 import java.lang.reflect.Method ; 6 7 8 16 public class Invocation { 17 private boolean _invokeNext; 18 private Method _method; 19 private MethodProxy _proxy; 20 private Object _instance; 21 private Object _returnVal; 22 private Object [] _args; 23 boolean _invoked; 24 25 28 Invocation(Object instance, Method meth, MethodProxy proxy, Object [] args) { 29 _instance = instance; 30 _method = meth; 31 _proxy = proxy; 32 _args = args; 33 } 34 35 50 public void abortInvoke(Object returnVal) { 51 _invoked = true; 52 _returnVal = returnVal; 53 } 54 55 85 90 public String getMethodName() { 91 return _method.getName(); 92 } 93 94 100 public Class [] getParameterTypes() { 101 return _method.getParameterTypes(); 102 } 103 104 109 public Class getReturnType() { 110 return _method.getReturnType(); 111 } 112 113 120 public Object getReturnValue() throws IllegalStateException { 121 if (!_invoked) { 122 throw new IllegalStateException ("Method " + _method + " not yet invoked"); 123 } 124 125 return _returnVal; 126 } 127 128 134 public Object invoke() throws Throwable { 135 if (_invoked) { 136 throw new IllegalStateException ("Method " + _method + 137 "was already invoked"); 138 } 139 140 _invoked = true; 141 142 return _returnVal = _proxy.invokeSuper(_instance, _args); 143 } 144 145 150 public boolean wasInvoked() { 151 return _invoked; 152 } 153 154 159 public Object getTarget() { 160 return _instance; 161 } 162 163 169 public Object [] getArgs() { 170 return _args; 171 } 172 173 178 Method getMethod() { 179 return _method; 180 } 181 182 void setReturnValue(Object val) { 183 if (!_invoked) { 184 throw new IllegalStateException ("Method " + _method + " not yet invoked"); 185 } 186 } 187 } 188 | Popular Tags |