private static int getLengthNullAsZero(JoinPointInfo info) { Interceptor[] icptrs = info.getInterceptors(); if (icptrs == null) { return 0; } return icptrs.length; } }
/** * Creates a copy of {@code chains}. * * @param chains array of chains to be copied */ private Interceptor[][] copyInterceptorChains(JoinPointInfo[] updatedInfos) { Interceptor[][] copy = new Interceptor[updatedInfos.length][]; for (int i = 0; i < updatedInfos.length; i++) { copy[i] = updatedInfos[i].getInterceptors(); } return copy; }
/** * If the info was updated in response to a rebuildInterceptorsForAddedBinding call it will have the * original interceptors in the interceptors array, and the appended interceptors in the interceptorChain * List. We need to merge the two so that all the interceptors appear in the interceptorChain List before finalizing * the chain */ protected final void adjustInfoForAddedBinding(JoinPointInfo info) { Interceptor[] icptrs = info.getInterceptors(); if (icptrs != null && icptrs.length > 0) { List<Interceptor> chain = info.getInterceptorChain(); List<Interceptor> buf = new ArrayList<Interceptor>(chain.size() + icptrs.length); buf.addAll(Arrays.asList(icptrs)); buf.addAll(chain); chain.clear(); chain.addAll(buf); } }
for (int i = 0; i < interceptors.length; i++) { Interceptor[] oldInterceptorsChain = interceptors[i]; Interceptor[] newInterceptorsChain = updatedInfos[i].getInterceptors(); boolean interceptedBefore = oldInterceptorsChain != null && oldInterceptorsChain.length > 0; boolean interceptedNow = newInterceptorsChain != null && newInterceptorsChain.length > 0;
private AdviceSetups initialiseAdviceInfosAndAddFields(ClassPool pool, CtClass clazz, JoinPointInfo info) throws ClassNotFoundException, NotFoundException, CannotCompileException { HashMap<String, Integer> cflows = new HashMap<String, Integer>(); Collection<AdviceSetup> setups = new ArrayList<AdviceSetup>(info.getInterceptors().length); ClassLoader classLoader = pool.getClassLoader(); if (classLoader == null) { logger.warn("No classloader specified " + clazz.getName(), new Throwable("STACKTRACE")); classLoader = SecurityActions.getContextClassLoader(); } for (int i = 0 ; i < info.getInterceptors().length ; i++) { AdviceSetup setup = new AdviceSetup(i, (GeneratedAdvisorInterceptor)info.getInterceptors()[i], info, classLoader); if (!setup.shouldInvokeAspect()) { continue; } setups.add(setup); addAspectFieldAndGetter(pool, clazz, setup); addCFlowFieldsAndGetters(pool, setup, clazz, cflows); } addLightweightInstanceAspectsTrackerFields(clazz); AdviceSetup[] setupArray = setups.toArray(new AdviceSetup[setups.size()]); return new AdviceSetups(info, setupArray); }
if (myInfo.getInterceptors() != null && otherInfo.getInterceptors() != null)
Interceptor[] currentOldChain = newInfo.getInterceptors();
AdviceSetup(int index, GeneratedAdvisorInterceptor ifw, JoinPointInfo info, ClassLoader classLoader) throws ClassNotFoundException, NotFoundException { this.index = index; scope = ifw.getScope(); adviceName = ifw.getAdviceName(); registeredName = ifw.getRegisteredName(); cflowString = ifw.getCFlowString(); cflowExpr = ifw.getCflowExpression(); if (ifw.isAspectFactory()) { Object aspectInstance = ((GeneratedAdvisorInterceptor)info.getInterceptors()[index]).getAspect(info.getAdvisor(), info.getJoinpoint(), true); if (aspectInstance != null) { aspectClass = aspectInstance.getClass(); } } else { aspectClass = classLoader.loadClass(ifw.getAspectClassName()); } if (aspectClass != null) { aspectCtClass = ReflectToJavassist.classToJavassist(aspectClass); } type = ifw.getType(); }