1 22 package org.jboss.aop.joinpoint; 23 24 import org.jboss.aop.FieldInfo; 25 import org.jboss.aop.advice.Interceptor; 26 27 import java.lang.reflect.Field ; 28 29 30 38 public class FieldWriteInvocation extends FieldInvocation 39 { 40 static final long serialVersionUID = 6795964118579848645L; 41 42 protected Object value; 43 44 public FieldWriteInvocation(Field field, int index, Object value, Interceptor[] interceptors) 45 { 46 super(field, index, interceptors); 47 this.value = value; 48 } 49 50 protected FieldWriteInvocation(Interceptor[] interceptors) 51 { 52 super(interceptors); 53 } 54 55 protected FieldWriteInvocation(FieldInfo info, Interceptor[] interceptors) 56 { 57 super(info, interceptors); 58 } 59 60 protected FieldWriteInvocation(FieldInfo info, Object value, Interceptor[] interceptors) 61 { 62 super(info, interceptors); 63 this.value = value; 64 } 65 66 71 public Object invokeNext() throws Throwable 72 { 73 if (interceptors != null && currentInterceptor < interceptors.length) 74 { 75 try 76 { 77 return interceptors[currentInterceptor++].invoke(this); 78 } 79 finally 80 { 81 currentInterceptor--; 83 } 84 } 85 86 return invokeTarget(); 87 } 88 89 93 public Object invokeTarget() throws Throwable 94 { 95 field.set(getTargetObject(), getValue()); 96 return null; 97 } 98 99 107 public Invocation getWrapper(Interceptor[] newchain) 108 { 109 FieldWriteInvocationWrapper wrapper = new FieldWriteInvocationWrapper(this, newchain); 110 return wrapper; 111 } 112 113 117 public Invocation copy() 118 { 119 FieldWriteInvocation wrapper = new FieldWriteInvocation(field, index, value, interceptors); 120 wrapper.setAdvisor(this.getAdvisor()); 121 wrapper.setTargetObject(this.getTargetObject()); 122 wrapper.currentInterceptor = this.currentInterceptor; 123 wrapper.instanceResolver = this.instanceResolver; 124 wrapper.metadata = this.metadata; 125 return wrapper; 126 } 127 128 public Object getValue() 129 { 130 return value; 131 } 132 133 public void setValue(Object value) 134 { 135 this.value = value; 136 } 137 } 138 | Popular Tags |