/** * 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); } }
protected void finalizeChain(JoinPointInfo[] infos) { if (infos == null) { return; } for (int i = 0; i < infos.length; i++) { JoinPointInfo info = infos[i]; adjustInfoForAddedBinding(info); ArrayList<Interceptor> list = info.getInterceptorChain(); Interceptor[] interceptors = null; if (list.size() > 0) { interceptors = applyPrecedence(list.toArray(new Interceptor[list.size()])); } info.setInterceptors(interceptors); } }
private void finalizeChainAndRebindJoinPoint(Map<Joinpoint, Interceptor[]> oldInfos, JoinPointInfo info, JoinPointGenerator generator, OldInfoMaps oldInfoMapInstance) { adjustInfoForAddedBinding(info); List<Interceptor> list = info.getInterceptorChain(); GeneratedAdvisorInterceptor[] factories = null; if (list.size() > 0) { factories = applyPrecedence(list.toArray(new GeneratedAdvisorInterceptor[list.size()])); } info.setInterceptors(factories); if (updateOldInfo(oldInfos, info, oldInfoMapInstance)) { generator.rebindJoinpoint(info); } }
/** * Default implementation adds interceptorChain directly to the info. * GeneratedClassAdvisor overrides this */ protected void pointcutResolved(JoinPointInfo info, AdviceBinding binding, Joinpoint joinpoint) { ArrayList<Interceptor> curr = info.getInterceptorChain(); if (binding.getCFlow() != null) { ArrayList<Interceptor> cflowChain = new ArrayList<Interceptor>(); createInterceptorChain(binding.getInterceptorFactories(), cflowChain, joinpoint); Interceptor[] cflowInterceptors = cflowChain.toArray(new Interceptor[cflowChain.size()]); curr.add(new CFlowInterceptor(binding.getCFlowString(), binding.getCFlow(), cflowInterceptors)); } else { createInterceptorChain(binding.getInterceptorFactories(), curr, joinpoint); } }
/** * Override default behaviour of when a pointcut is matched, populate the factories since this * is what is needed for generating the optimized invocation method */ @Override protected void pointcutResolved(JoinPointInfo info, AdviceBinding binding, Joinpoint joinpoint) { ArrayList<Interceptor> curr = info.getInterceptorChain(); if (binding.getCFlow() != null) { InterceptorFactory[] factories = binding.getInterceptorFactories(); for (int i = 0 ; i < factories.length ; i++) { curr.add(new GeneratedAdvisorInterceptor(factories[i], this, joinpoint, binding.getCFlowString(), binding.getCFlow())); } } else { InterceptorFactory[] factories = binding.getInterceptorFactories(); for (int i = 0 ; i < factories.length ; i++) { curr.add(new GeneratedAdvisorInterceptor(factories[i], this, joinpoint)); } } }