public void put(long hash, MethodInfo info) { infos.put(hash, new MethodMatchInfo(advisor, info)); }
private void simplePopulateBindings(ArrayList<AdviceBinding> applicableBindings) { int size = bindings.size(); for (int i = 0 ; i < size ; i++) { AdviceBinding binding = bindings.get(i); applyBinding(applicableBindings, binding); } }
public MethodInfo getMethodInfo(long hash) { MethodMatchInfo info = getMatchInfo(hash); if (info != null) { return info.getInfo(); } return null; }
public ArrayList<AdviceBinding> populateBindings() { if (bindings != null) { ArrayList<AdviceBinding> applicableBindings = new ArrayList<AdviceBinding>(); if (advisor.chainOverridingForInheritedMethods()) { overridePopulateBindings(applicableBindings); } else { simplePopulateBindings(applicableBindings); } if (applicableBindings.size() > 0) { return applicableBindings; } } return null; }
protected void finalizeMethodChain() { boolean maintain = AspectManager.maintainAdvisorMethodInterceptors; TLongObjectHashMap newMethodInfos = (maintain) ? new TLongObjectHashMap() : null; long[] keys = methodInfos.keys(); for (int i = 0; i < keys.length; i++) { MethodMatchInfo matchInfo = methodInfos.getMatchInfo(keys[i]); matchInfo.populateBindings(); MethodInfo info = matchInfo.getInfo(); 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); if (maintain) { newMethodInfos.put(keys[i], info); } } methodInterceptors = newMethodInfos; }
protected void updateMethodPointcutAfterRemove(AdviceBinding binding) { long[] keys = methodInfos.keys(); for(int i =0; i < keys.length; i++) { Method method = (Method) advisedMethods.get(keys[i]); PointcutMethodMatch match = binding.getPointcut().matchesExecution(this, method); if (match != null && match.isMatch()) { if (AspectManager.verbose) { logger.debug("removing matched binding: "+method.toString()); } MethodMatchInfo info = methodInfos.getMatchInfo(keys[i]); info.removeMatchedBinding(binding, match); info.getInfo().clear(); if (AspectManager.maintainAdvisorMethodInterceptors) { methodInterceptors.put(keys[i], info); } } } }
info.addMatchedBinding(binding, match); if (AspectManager.maintainAdvisorMethodInterceptors)
@Override protected void initializeMethodChain() { //We have all the advised methods here, need to get all the others here too long[] keys = advisedMethods.keys(); for (int i = 0; i < keys.length; i++) { MethodMatchInfo matchInfo = methodInfos.getMatchInfo(keys[i]); if (super.initialized && matchInfo != null) { matchInfo.clear(); } if (matchInfo == null) { MethodInfo info = new MethodInfo(); Method amethod = (Method) advisedMethods.get(keys[i]); info.setAdvisedMethod(amethod); info.setUnadvisedMethod(amethod); info.setHash(keys[i]); info.setAdvisor(this); methodInfos.put(keys[i], info); } } }
private void fullWorkFinalizeMethodChain(MethodInterceptors newMethodInterceptors) { //We are either the class advisor or an instanceadvisor with own data so we need to do all the work TLongObjectHashMap newMethodInfos = new TLongObjectHashMap(); long[] keys = newMethodInterceptors.keys(); for (int i = 0; i < keys.length; i++) { MethodMatchInfo matchInfo = newMethodInterceptors.getMatchInfo(keys[i]); matchInfo.populateBindings(); MethodInfo info = matchInfo.getInfo(); newMethodInfos.put(keys[i], info); MethodJoinPointGenerator generator = getJoinPointGenerator(info); finalizeChainAndRebindJoinPoint(oldInfos, info, generator, OldInfoMaps.INFOS); } if (AspectManager.maintainAdvisorMethodInterceptors) { methodInterceptors = newMethodInfos; } //Handle the overridden methods if (overriddenMethods != null && overriddenMethods.size() > 0) { for (MethodInfo info : overriddenMethods) { MethodJoinPointGenerator generator = getJoinPointGenerator(info); finalizeChainAndRebindJoinPoint(oldInfos, info, generator, OldInfoMaps.INFOS); } } }
protected void lockWriteChain(MethodInterceptors methodInterceptors) { Object[] methodMatchInfos = methodInterceptors.infos.getValues(); for (int i = 0; i < methodMatchInfos.length; i++) { MethodMatchInfo methodMatchInfo = (MethodMatchInfo) methodMatchInfos[i]; methodMatchInfo.getInfo().getInterceptorChainReadWriteLock().writeLock().lock(); } }
private void overridePopulateBindings(ArrayList<AdviceBinding> applicableBindings) { if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("populate bindings for " + info.getMethod() + " all bindings"); int size = bindings.size(); int minMatchLevel = 1000000; for (int i = 0 ; i < size ; i++) { AdviceBinding binding = bindings.get(i); PointcutMethodMatch match = pointcutMethodMatches.get(i); if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug(match.getMatchLevel() + " " + match.getMatchedClass().getName() + " " + binding.getPointcut().getExpr() + " : " + binding.getInterceptorFactories().length); if (minMatchLevel > match.getMatchLevel() && !match.isInstanceOf()) { minMatchLevel = match.getMatchLevel(); } } if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("populate bindings for " + info.getMethod() + " actual bindings"); for (int i = 0 ; i < size ; i++) { AdviceBinding binding = bindings.get(i); PointcutMethodMatch match = pointcutMethodMatches.get(i); if (match.isInstanceOf() || match.getMatchLevel() == minMatchLevel) { if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug(match.getMatchLevel() + " " + match.getMatchedClass().getName() + " " + binding.getPointcut().getExpr() + " : " + binding.getInterceptorFactories().length); applyBinding(applicableBindings, binding); } } }
protected void unlockWriteChain(MethodInterceptors methodInterceptors) { Object[] methodMatchInfos = methodInterceptors.infos.getValues(); for (int i = 0; i < methodMatchInfos.length; i++) { MethodMatchInfo methodMatchInfo = (MethodMatchInfo) methodMatchInfos[i]; methodMatchInfo.getInfo().getInterceptorChainReadWriteLock().writeLock().unlock(); } }
protected void resetChainKeepInterceptors(MethodInterceptors methodInterceptors) { Object[] methodMatchInfos = methodInterceptors.infos.getValues(); for (int i = 0; i < methodMatchInfos.length; i++) { MethodMatchInfo methodMatchInfo = (MethodMatchInfo) methodMatchInfos[i]; JoinPointInfo info = methodMatchInfo.getInfo(); info.clear(); } }
protected void resetChain(MethodInterceptors methodInterceptors) { Object[] methodMatchInfos = methodInterceptors.infos.getValues(); for (int i = 0; i < methodMatchInfos.length; i++) { MethodMatchInfo methodMatchInfo = (MethodMatchInfo) methodMatchInfos[i]; if (methodMatchInfo.bindings != null) { methodMatchInfo.bindings.clear(); } if (methodMatchInfo.pointcutMethodMatches != null) { methodMatchInfo.pointcutMethodMatches.clear(); } methodMatchInfo.getInfo().clear(); } }
private void easyFinalizeMethodChainForInstance(ClassAdvisor classAdvisor, MethodInterceptors newMethodInterceptors) { long[] keys = newMethodInterceptors.keys(); for (int i = 0; i < keys.length; i++) { MethodInfo classMethodInfo = classAdvisor.getMethodInfo(keys[i]); MethodMatchInfo matchInfo = newMethodInterceptors.getMatchInfo(keys[i]); MethodInfo myMethodInfo = matchInfo.getInfo(); myMethodInfo.cloneChains(classMethodInfo); if (updateOldInfo(oldInfos, myMethodInfo, OldInfoMaps.INFOS)) { MethodJoinPointGenerator generator = getJoinPointGenerator(myMethodInfo); generator.rebindJoinpoint(myMethodInfo); } } }