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); } }
public int size() { return infos.size(); } }
/** * Compares this map with another map for equality of their stored * entries. * * @param other an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean equals(Object other) { if (! (other instanceof TLongObjectHashMap)) { return false; } TLongObjectHashMap that = (TLongObjectHashMap)other; if (that.size() != this.size()) { return false; } return forEachEntry(new EqProcedure(that)); }
/** * @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 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]); } } } }
@Override public MethodInfo getMethodInfo(long hash) { MethodInfo info = (MethodInfo)methodInfos.get(hash); return info; }
public void rebuildCallerInterceptors() throws Exception { long[] callingKeys = conCalledByMethodInterceptors.keys(); for (int i = 0; i < callingKeys.length; i++) { long callingHash = callingKeys[i]; HashMap<String, TLongObjectHashMap> calledClasses = (HashMap<String, TLongObjectHashMap>) conCalledByMethodInterceptors.get(callingHash); for (Map.Entry<String, TLongObjectHashMap> entry : calledClasses.entrySet()) { String cname = entry.getKey(); TLongObjectHashMap calledMethods = entry.getValue(); long[] calledKeys = calledMethods.keys(); for (int j = 0; j < calledKeys.length; j++) { long calledHash = calledKeys[j]; ArrayList<AdviceBinding> bindings = getConCalledByMethodBindings(callingHash, cname, calledHash); bindConCalledByMethodInterceptorChain(bindings, callingHash, cname, calledHash); } } } }
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; }
/** * 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); }
if (_map.equals(other)) { return true; // comparing two trove maps } else if (other instanceof Map) { Map that = (Map)other; if (that.size() != _map.size()) { return false; // different sizes, no need to compare } else { // now we have to do it the hard way long k = unwrapKey(key); Object v = unwrapValue(val); if (_map.containsKey(k) && v == _map.get(k)) {
protected void initAdvisedMethodsMap() { if (advisedMethods == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP) { synchronized(lazyCollectionLock) { if (advisedMethods == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP) { advisedMethods = new TLongObjectHashMap(); } } } }
/** * checks for the present of <tt>key</tt> in the keys of the map. * * @param key an <code>long</code> value * @return a <code>boolean</code> value */ public boolean containsKey(long key) { return contains(key); }
/** * @param fieldName * @param classfield */ private void addField(long shaHashKey, String fieldName, ClassMetadataField classfield) { this.fields.put(fieldName,classfield); this.hashFields.put(shaHashKey,classfield); }
public MethodMatchInfo getMatchInfo(long hash) { return (MethodMatchInfo)infos.get(hash); }
public void rebuildCallerInterceptors() throws Exception { //No need to initialise map here if it is empty long[] callingKeys = methodCalledByMethodInterceptors.keys(); for (int i = 0; i < callingKeys.length; i++) { long callingHash = callingKeys[i]; HashMap<String, TLongObjectHashMap> calledClasses = (HashMap<String, TLongObjectHashMap>) methodCalledByMethodInterceptors.get(callingHash); for (Map.Entry<String, TLongObjectHashMap> entry : calledClasses.entrySet()) { String cname = entry.getKey(); TLongObjectHashMap calledMethods = entry.getValue(); long[] calledKeys = calledMethods.keys(); for (int j = 0; j < calledKeys.length; j++) { long calledHash = calledKeys[j]; ArrayList<AdviceBinding> bindings = getCallerBindings(callingHash, cname, calledHash); Method calling = MethodHashing.findMethodByHash(clazz, callingHash); bindCallerInterceptorChain(bindings, callingHash, cname, calledHash, calling); } } } }
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; }