1 18 19 package org.objectweb.jac.core; 20 21 import java.util.Vector ; 22 import org.aopalliance.intercept.Interceptor; 23 24 36 37 public class CompositionAspect extends AspectComponent { 38 39 40 42 44 46 47 protected Vector wrappingOrder = JacPropLoader.wrappingOrder; 48 49 50 protected Vector incompatibleACs = JacPropLoader.incompatibleACs; 51 52 53 protected Vector dependentACs = JacPropLoader.dependentACs; 54 55 58 59 public CompositionAspect() { 60 } 61 62 75 public int getWeaveTimeRank(WrappingChain wrappingChain, Wrapper wrapper) { 76 int i = 0; 77 Interceptor[] chain = wrappingChain.chain; 78 int wrapperRank = wrappingOrder.indexOf(wrapper.getClass().getName()); 79 for (; i < chain.length; i++) { 80 if (wrapperRank 81 <= wrappingOrder.indexOf(chain[i].getClass().getName())) { 82 return i; 83 } 84 } 85 88 return i; 89 } 90 91 101 102 public final boolean areCorrectlyOrdered( 103 String wrapperType1, 104 String wrapperType2) { 105 109 return ( 110 wrappingOrder.indexOf(wrapperType1) 111 <= wrappingOrder.indexOf(wrapperType2)); 112 116 } 117 118 122 123 public final Vector getWrappingTypesOrder() { 124 return wrappingOrder; 125 } 126 127 139 140 public final void addIncompatibleACPair( 141 AspectComponent ac1, 142 AspectComponent ac2) { 143 incompatibleACs.add(ac1); 144 incompatibleACs.add(ac2); 145 } 146 147 158 159 public final void addDependentACPair( 160 AspectComponent ac1, 161 AspectComponent ac2) { 162 dependentACs.add(ac1); 163 dependentACs.add(ac2); 164 } 165 166 176 177 public final boolean areIncompatible( 178 AspectComponent ac1, 179 AspectComponent ac2) { 180 for (int i = 0; i < incompatibleACs.size(); i += 2) { 181 if ((ac1.equals(incompatibleACs.get(i)) 182 && ac2.equals(incompatibleACs.get(i + 1))) 183 || (ac2.equals(incompatibleACs.get(i)) 184 && ac1.equals(incompatibleACs.get(i + 1)))) { 185 return true; 186 } 187 } 188 return false; 189 } 190 191 201 202 public final boolean areDependent( 203 AspectComponent ac1, 204 AspectComponent ac2) { 205 for (int i = 0; i < dependentACs.size(); i += 2) { 206 if ((ac1.equals(dependentACs.get(i)) 207 && ac2.equals(dependentACs.get(i + 1))) 208 || (ac2.equals(dependentACs.get(i)) 209 && ac1.equals(dependentACs.get(i + 1)))) { 210 return true; 211 } 212 } 213 return false; 214 } 215 216 } 217 | Popular Tags |