1 22 package org.jboss.aop.joinpoint; 23 24 import org.jboss.aop.Advisor; 25 import org.jboss.aop.MethodByConInfo; 26 import org.jboss.aop.advice.Interceptor; 27 28 import java.lang.reflect.Constructor ; 29 import java.lang.reflect.InvocationTargetException ; 30 import java.lang.reflect.Method ; 31 32 33 41 public class MethodCalledByConstructorInvocation extends CallerInvocation 42 { 43 private static final long serialVersionUID = -1903092605231217830L; 44 45 protected Constructor calling; 47 protected Method method; 48 protected Object [] arguments = null; 49 50 public MethodCalledByConstructorInvocation(MethodByConInfo info, Object target, Object [] args, Interceptor[] interceptors) 51 { 52 this(info.getAdvisor(), info.getCalling(), info.getMethod(), target, args, interceptors); 53 } 54 55 public MethodCalledByConstructorInvocation(MethodByConInfo info, Object target, Interceptor[] interceptors) 56 { 57 this(info.getAdvisor(), info.getCalling(), info.getMethod(), target, null, interceptors); 58 } 59 60 public MethodCalledByConstructorInvocation(Advisor advisor, Constructor calling, Method method, Object target, Object [] args, Interceptor[] interceptors) 61 { 62 super(advisor, interceptors); 63 this.calling = calling; 64 this.method = method; 65 setTargetObject(target); 66 this.arguments = args; 67 } 68 69 public MethodCalledByConstructorInvocation(Interceptor[] interceptors) 70 { 71 super(interceptors); 72 } 73 74 79 public Object invokeNext() throws Throwable 80 { 81 if (interceptors != null && currentInterceptor < interceptors.length) 82 { 83 try 84 { 85 return interceptors[currentInterceptor++].invoke(this); 86 } 87 finally 88 { 89 currentInterceptor--; 91 } 92 } 93 94 return invokeTarget(); 95 } 96 97 101 public Object invokeTarget() throws Throwable 102 { 103 try 104 { 105 return method.invoke(getTargetObject(), arguments); 106 } 107 catch (InvocationTargetException e) 108 { 109 throw e.getTargetException(); 110 } 111 } 112 113 122 public Object getMetaData(Object group, Object attr) 123 { 124 Object val = super.getMetaData(group, attr); 125 if (val != null) return val; 126 127 return null; 129 } 130 131 139 public Invocation getWrapper(Interceptor[] newchain) 140 { 141 MethodCalledByConstructorInvocationWrapper wrapper = new MethodCalledByConstructorInvocationWrapper(this, newchain); 142 return wrapper; 143 } 144 145 149 public Invocation copy() 150 { 151 MethodCalledByConstructorInvocation wrapper = new MethodCalledByConstructorInvocation( 152 advisor, calling, method, targetObject, arguments, interceptors); 153 wrapper.currentInterceptor = this.currentInterceptor; 154 wrapper.metadata = this.metadata; 155 wrapper.instanceResolver = this.instanceResolver; 156 return wrapper; 157 } 158 159 165 public Object [] getArguments() 166 { 167 return arguments; 168 } 169 170 174 public void setArguments(Object [] arguments) 175 { 176 this.arguments = arguments; 177 } 178 179 184 public Constructor getCalling() 185 { 186 return calling; 187 } 188 189 193 public Method getCalledMethod() 194 { 195 return method; 196 } 197 } 198 | Popular Tags |