/** * @param fieldName * @param classfield */ private void addField(long shaHashKey, String fieldName, ClassMetadataField classfield) { this.fields.put(fieldName,classfield); this.hashFields.put(shaHashKey,classfield); }
/** * @param fieldName * @param classfield */ private void addField(long shaHashKey, String fieldName, ClassMetadataField classfield) { this.fields.put(fieldName,classfield); this.hashFields.put(shaHashKey,classfield); }
/** * @param fieldName * @param classfield */ private void addField(long shaHashKey, String fieldName, ClassMetadataField classfield) { this.fields.put(fieldName, classfield); this.hashFields.put(shaHashKey, classfield); }
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); int size = stream.readInt(); setUp(size); while (size-- > 0) { long key = stream.readLong(); Object val = stream.readObject(); put(key, val); } } } // TLongObjectHashMap
public void addMethodInfo(MethodInfo info) { methodInfos.put(info.getHash(), info); }
public void put(long hash, MethodInfo info) { infos.put(hash, new MethodMatchInfo(advisor, info)); }
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 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 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; }
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); } }
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); } }
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 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; }
protected void createMethodMap() { initAdvisedMethodsMap(); try { Method[] declaredMethods = clazz.getMethods(); for (int i = 0; i < declaredMethods.length; i++) { if (ClassAdvisor.isAdvisable(declaredMethods[i])) { long hash = MethodHashing.methodHash(declaredMethods[i]); advisedMethods.put(hash, declaredMethods[i]); } } } catch (Exception e) { throw new RuntimeException(e); } }
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; }
/** * Inserts a key/value pair into the map. * * @param key an <code>Object</code> value * @param value an <code>Object</code> value * @return the previous value associated with <tt>key</tt>, * or Integer(0) if none was found. */ public Object put(Object key, Object value) { return wrapValue(_map.put(unwrapKey(key), unwrapValue(value))); }
@Override protected void createMethodTables() throws Exception { super.createMethodTables(); List<Method> virtualMethods = getVirtualMethods(); if(virtualMethods != null) { for(Method virtualMethod : virtualMethods) { long hash = MethodHashing.methodHash(virtualMethod); advisedMethods.put(hash, virtualMethod); } } }
private void addMethodsFromInterfaces(String[] intf) throws Exception { ClassLoader cl = SecurityActions.getClassLoader(clazz); if (cl == null) { //Fall back to context classloader cl = SecurityActions.getContextClassLoader(); } for (int j = 0; intf != null && j < intf.length; ++j) { Class<?> iface = cl.loadClass(intf[j]); Method[] ifaceMethods = iface.getMethods(); for (int k = 0; k < ifaceMethods.length; k++) { long hash = MethodHashing.methodHash(ifaceMethods[k]); if (advisedMethods.get(hash) == null) { advisedMethods.put(hash, ifaceMethods[k]); } } } }
/** * Create a HashMap of method hash and Method * Superclasses get added first so subclasses will override with * correct overriden method */ private void populateMethodTables(Class<?> superclass) throws Exception { if (superclass == null) return; if (superclass.equals(Object.class)) return; populateMethodTables(superclass.getSuperclass()); //The advisor for the superclass may be a container Advisor superAdvisor = manager.getAnyAdvisorIfAdvised(superclass); if (superAdvisor != null && superAdvisor instanceof ClassAdvisor) { TLongObjectHashMap superHash = ((ClassAdvisor)superAdvisor).getUnadvisedMethods(); long[] keys = superHash.keys(); for (int i = 0; i < keys.length; i++) { unadvisedMethods.put(keys[i], superHash.get(keys[i])); } } addDeclaredMethods(superclass); }
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); } } } }