1 22 package org.jboss.aop; 23 24 import java.lang.ref.WeakReference ; 25 import java.util.ArrayList ; 26 import java.util.Arrays ; 27 28 import org.jboss.aop.advice.Interceptor; 29 import org.jboss.aop.joinpoint.Joinpoint; 30 31 public abstract class JoinPointInfo 32 { 33 private Interceptor[] interceptors; 34 35 private ArrayList interceptorChain = new ArrayList (); 36 37 private WeakReference advisor; 38 39 protected volatile Joinpoint joinpoint; 40 41 protected WeakReference clazz; 42 43 protected JoinPointInfo() 44 { 45 this.clazz = new WeakReference (null); 46 } 47 48 protected JoinPointInfo(Advisor advisor, Class clazz) 49 { 50 setAdvisor(advisor); 51 this.clazz = new WeakReference (clazz); 52 } 53 54 57 protected JoinPointInfo(JoinPointInfo other) 58 { 59 this.advisor = other.advisor; 60 if (other.interceptors != null) 61 { 62 this.interceptors = new Interceptor[other.interceptors.length]; 63 System.arraycopy(other.interceptors, 0, this.interceptors, 0, other.interceptors.length); 64 } 65 if (other.interceptorChain != null)this.interceptorChain = (ArrayList )interceptorChain.clone(); 66 } 67 68 protected void clear() 69 { 70 interceptorChain.clear(); 71 interceptors = null; 72 } 73 74 public Advisor getAdvisor() 75 { 76 if (advisor == null) 77 { 78 return null; 79 } 80 return (Advisor)advisor.get(); 81 } 82 83 public Class getClazz() 84 { 85 return (Class )clazz.get(); 86 } 87 88 public void setAdvisor(Advisor advisor) 89 { 90 this.advisor = new WeakReference (advisor); 91 } 92 93 public boolean hasAdvices() 94 { 95 return (interceptors != null && interceptors.length > 0) ; 96 } 97 98 public boolean equalChains(JoinPointInfo other) 99 { 100 if (this.interceptors == null && other.interceptors == null) return true; 101 if (!(this.interceptors != null && other.interceptors != null))return false; 102 if (this.interceptors.length != other.interceptors.length) return false; 103 104 for (int i = 0 ; i < this.interceptors.length ; i++) 105 { 106 if(!this.interceptors[i].equals(other.interceptors[i])) return false; 107 } 108 109 return true; 110 } 111 112 public Joinpoint getJoinpoint() 113 { 114 if (joinpoint == null) 115 { 116 joinpoint = internalGetJoinpoint(); 117 } 118 return joinpoint; 119 } 120 121 public ArrayList getInterceptorChain() { 122 return interceptorChain; 123 } 124 125 public void setInterceptorChain(ArrayList interceptorChain) { 126 this.interceptorChain = interceptorChain; 127 } 128 129 public Interceptor[] getInterceptors() { 130 return interceptors; 131 } 132 133 public void setInterceptors(Interceptor[] interceptors) { 134 this.interceptors = interceptors; 135 } 136 137 protected abstract Joinpoint internalGetJoinpoint(); 138 public abstract JoinPointInfo copy(); 139 } 140 | Popular Tags |