1 22 package org.jboss.aop.joinpoint; 23 24 import java.lang.reflect.Constructor ; 25 26 import org.jboss.aop.ConstructionInfo; 27 import org.jboss.aop.advice.Interceptor; 28 29 37 public class ConstructionInvocation extends InvocationBase 38 { 39 40 private static final long serialVersionUID = -6040602776303875808L; 41 42 protected Object [] arguments = null; protected transient Constructor constructor = null; 44 45 public ConstructionInvocation(Interceptor[] interceptors, Constructor con, Object [] args) 46 { 47 super(interceptors); 48 this.constructor = con; 49 this.arguments = args; 50 } 51 52 53 public ConstructionInvocation(Interceptor[] interceptors, Constructor con) 54 { 55 super(interceptors); 56 this.constructor = con; 57 } 58 59 public ConstructionInvocation(ConstructionInfo info, Interceptor[] interceptors) 60 { 61 super(interceptors); 62 this.constructor = info.getConstructor(); 63 super.advisor = info.getAdvisor(); 64 } 65 66 67 72 public Object invokeNext() throws Throwable 73 { 74 if (interceptors != null && currentInterceptor < interceptors.length) 75 { 76 try 77 { 78 return interceptors[currentInterceptor++].invoke(this); 79 } 80 finally 81 { 82 currentInterceptor--; 84 } 85 } 86 87 return invokeTarget(); 88 } 89 90 91 95 public Object invokeTarget() throws Throwable 96 { 97 return null; 98 } 99 100 101 105 public Object resolveAnnotation(Class annotation) 106 { 107 Object val = super.resolveAnnotation(annotation); 108 if (val != null) return val; 109 110 if (getAdvisor() != null) 111 { 112 val = getAdvisor().resolveAnnotation(constructor, annotation); 113 if (val != null) return val; 114 } 115 116 return null; 117 } 118 119 128 public Object getMetaData(Object group, Object attr) 129 { 130 Object val = super.getMetaData(group, attr); 131 if (val != null) return val; 132 133 if (getAdvisor() != null) 134 { 135 val = getAdvisor().getConstructorMetaData().resolve(this, group, attr); 136 if (val != null) return val; 137 } 138 139 if (getAdvisor() != null) 140 { 141 val = getAdvisor().getDefaultMetaData().resolve(this, group, attr); 142 if (val != null) return val; 143 } 144 145 return null; 146 } 147 148 156 public Invocation getWrapper(Interceptor[] newchain) 157 { 158 ConstructionInvocationWrapper wrapper = new ConstructionInvocationWrapper(this, newchain); 159 return wrapper; 160 } 161 162 166 public Invocation copy() 167 { 168 ConstructionInvocation wrapper = new ConstructionInvocation(interceptors, constructor, arguments); 169 wrapper.setAdvisor(this.getAdvisor()); 170 wrapper.currentInterceptor = this.currentInterceptor; 171 wrapper.metadata = this.metadata; 172 return wrapper; 173 } 174 175 public Object [] getArguments() 176 { 177 return arguments; 178 } 179 180 public void setArguments(Object [] arguments) 181 { 182 this.arguments = arguments; 183 } 184 185 public Constructor getConstructor() 186 { 187 return constructor; 188 } 189 190 public void setConstructor(Constructor constructor) 191 { 192 this.constructor = constructor; 193 } 194 } 195 | Popular Tags |