1 25 26 package org.snipsnap.interceptor; 27 28 import java.lang.reflect.Method ; 29 import java.util.Iterator ; 30 import java.util.List ; 31 32 public class Invocation { 33 private Iterator chain; 34 private Object target; 35 private Method method; 36 private Object [] args; 37 38 public Invocation(Object target, Method method, Object [] args, List interceptors) { 39 this.target = target; 40 this.method = method; 41 this.args = args; 42 chain = interceptors.iterator(); 43 } 44 45 public Object [] getArgs() { 46 return args; 47 } 48 49 public Method getMethod() { 50 return method; 51 } 52 53 public Object getTarget() { 54 return target; 55 } 56 57 public Object next() throws Throwable { 58 if (chain.hasNext()) { 59 Interceptor i = (Interceptor) chain.next(); 60 return i.invoke(this); 64 } 65 return method.invoke(target, args); 67 } 68 } 69 | Popular Tags |