protected void initAdvisedMethodsMap() { if (advisedMethods == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP) { synchronized(lazyCollectionLock) { if (advisedMethods == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP) { advisedMethods = new TLongObjectHashMap(); } } } }
private void initializeConCalledByConEmptyChain(int callingIndex, String calledClass, long calledConHash) throws Exception { HashMap<String, TLongObjectHashMap> callingCon = conCalledByConBindings[callingIndex]; if (callingCon == null) { callingCon = new HashMap<String, TLongObjectHashMap>(); conCalledByConBindings[callingIndex] = callingCon; } TLongObjectHashMap classMap = callingCon.get(calledClass); if (classMap == null) { classMap = new TLongObjectHashMap(); callingCon.put(calledClass, classMap); } ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledConHash); if (bindings == null) { bindings = new ArrayList<AdviceBinding>(); classMap.put(calledConHash, bindings); } }
conCalledByMethodBindings = new TLongObjectHashMap(); conCalledByMethodInterceptors = new TLongObjectHashMap();
private ConByConInfo initializeConCalledByConInterceptorsMap(Class<?> callingClass, int callingIndex, String calledClass, long calledConHash, Constructor<?> calledCon) throws Exception { HashMap<String, TLongObjectHashMap> calledClassesMap = conCalledByConInterceptors[callingIndex]; if (calledClassesMap == null) { calledClassesMap = new HashMap<String, TLongObjectHashMap>(); conCalledByConInterceptors[callingIndex] = calledClassesMap; } TLongObjectHashMap calledMethodsMap = calledClassesMap.get(calledClass); if (calledMethodsMap == null) { calledMethodsMap = new TLongObjectHashMap(); calledClassesMap.put(calledClass, calledMethodsMap); } ConByConInfo info = createConByConInfo(callingClass, callingIndex, calledClass, calledCon, calledConHash); calledMethodsMap.put(calledConHash, info); return info; }
methodCalledByMethodBindings = new TLongObjectHashMap(); methodCalledByMethodInterceptors = new TLongObjectHashMap();
private void initializeEmptyConstructorCallerChain(int callingIndex, String calledClass, long calledMethodHash) throws Exception { HashMap<String, TLongObjectHashMap> callingCon = methodCalledByConBindings[callingIndex]; if (callingCon == null) { callingCon = new HashMap<String, TLongObjectHashMap>(); methodCalledByConBindings[callingIndex] = callingCon; } TLongObjectHashMap classMap = callingCon.get(calledClass); if (classMap == null) { classMap = new TLongObjectHashMap(); callingCon.put(calledClass, classMap); } ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledMethodHash); if (bindings == null) { bindings = new ArrayList<AdviceBinding>(); classMap.put(calledMethodHash, bindings); } }
private MethodByConInfo initializeConstructorCallerInterceptorsMap(Class<?> callingClass, int callingIndex, String calledClass, long calledMethodHash, Method calledMethod) throws Exception { HashMap<String, TLongObjectHashMap> calledClassesMap = methodCalledByConInterceptors[callingIndex]; if (calledClassesMap == null) { calledClassesMap = new HashMap<String, TLongObjectHashMap>(); methodCalledByConInterceptors[callingIndex] = calledClassesMap; } TLongObjectHashMap calledMethodsMap = calledClassesMap.get(calledClass); if (calledMethodsMap == null) { calledMethodsMap = new TLongObjectHashMap(); calledClassesMap.put(calledClass, calledMethodsMap); } //The standard MethodCalledByXXXXInvocation class calls by reflection and needs access SecurityActions.setAccessible(calledMethod); Class<?> calledClazz = getClassLoader().loadClass(calledClass); MethodByConInfo info = new MethodByConInfo(this, calledClazz, callingClass, callingIndex, calledMethod, calledMethodHash, null); calledMethodsMap.put(calledMethodHash, info); return info; }
private void initializeConCalledByMethodEmptyChain(long callingMethodHash, String calledClass, long calledConHash) throws Exception { HashMap<String, TLongObjectHashMap> callingMethod = (HashMap<String, TLongObjectHashMap>) conCalledByMethodBindings.get(callingMethodHash); if (callingMethod == null) { callingMethod = new HashMap<String, TLongObjectHashMap>(); conCalledByMethodBindings.put(callingMethodHash, callingMethod); } TLongObjectHashMap classMap = callingMethod.get(calledClass); if (classMap == null) { classMap = new TLongObjectHashMap(); callingMethod.put(calledClass, classMap); } ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledConHash); if (bindings == null) { bindings = new ArrayList<AdviceBinding>(); classMap.put(calledConHash, bindings); } }
private ConByMethodInfo initializeConCalledByMethodInterceptorsMap(Method callingMethod, long callingMethodHash, String calledClass, long calledConHash, Constructor<?> calledCon) throws Exception { HashMap<String, TLongObjectHashMap> calledClassesMap = (HashMap<String, TLongObjectHashMap>) conCalledByMethodInterceptors.get(callingMethodHash); if (calledClassesMap == null) { calledClassesMap = new HashMap<String, TLongObjectHashMap>(); conCalledByMethodInterceptors.put(callingMethodHash, calledClassesMap); } TLongObjectHashMap calledMethodsMap = calledClassesMap.get(calledClass); if (calledMethodsMap == null) { calledMethodsMap = new TLongObjectHashMap(); calledClassesMap.put(calledClass, calledMethodsMap); } ConByMethodInfo info = createConByMethodInfo(calledClass, callingMethod, callingMethodHash, calledCon, calledConHash); calledMethodsMap.put(calledConHash, info); return info; }
private MethodByMethodInfo initializeCallerInterceptorsMap(long callingMethodHash, String calledClass, long calledMethodHash, Method callingMethod, Method calledMethod) throws Exception { //Called via resolveCallerMethodInfo, maps are initialised HashMap<String, TLongObjectHashMap> calledClassesMap = (HashMap<String, TLongObjectHashMap>) methodCalledByMethodInterceptors.get(callingMethodHash); if (calledClassesMap == null) { calledClassesMap = new HashMap<String, TLongObjectHashMap>(); methodCalledByMethodInterceptors.put(callingMethodHash, calledClassesMap); } TLongObjectHashMap calledMethodsMap = calledClassesMap.get(calledClass); if (calledMethodsMap == null) { calledMethodsMap = new TLongObjectHashMap(); calledClassesMap.put(calledClass, calledMethodsMap); } //The standard MethodCalledByXXXXInvocation class calls by reflection and needs access calledMethod.setAccessible(true); Class<?> calledClazz = getClassLoader().loadClass(calledClass); MethodByMethodInfo info = new MethodByMethodInfo(ClassAdvisor.this, calledClazz, calledMethod, callingMethod, callingMethodHash, calledMethodHash, null); calledMethodsMap.put(calledMethodHash, info); return info; }
private void initializeEmptyCallerChain(long callingMethodHash, String calledClass, long calledMethodHash) throws Exception { //Called via resolveCallerMethodInfo, maps are initialised HashMap<String, TLongObjectHashMap> callingMethod = (HashMap<String, TLongObjectHashMap>) methodCalledByMethodBindings.get(callingMethodHash); if (callingMethod == null) { callingMethod = new HashMap<String, TLongObjectHashMap>(); methodCalledByMethodBindings.put(callingMethodHash, callingMethod); } TLongObjectHashMap classMap = callingMethod.get(calledClass); if (classMap == null) { classMap = new TLongObjectHashMap(); callingMethod.put(calledClass, classMap); } ArrayList<AdviceBinding> bindings = (ArrayList<AdviceBinding>) classMap.get(calledMethodHash); if (bindings == null) { bindings = new ArrayList<AdviceBinding>(); classMap.put(calledMethodHash, bindings); } }
if (classMap == null) classMap = new TLongObjectHashMap(); callingCon.put(calledClass, classMap);
if (classMap == null) classMap = new TLongObjectHashMap(); callingCon.put(calledClass, classMap);
if (classMap == null) classMap = new TLongObjectHashMap(); callingMethod.put(calledClass, classMap);
if (classMap == null) classMap = new TLongObjectHashMap(); callingMethod.put(calledClass, classMap);
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; }
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); } } }