public void clearAllEntries() { for (Cache cache : cachesMap.values()) { cache.clear(); } }
public void addCache(Cache cache) { synchronized (cachesMap) { String name = cache.getName(); if (cacheExists(name)) { MappingUtils.throwMappingException("Cache already exists with name: " + name); } cachesMap.put(name, cache); } }
public Class getCustomConverter(Class<?> srcClass, Class<?> destClass, Cache converterTypeCache) { if (converters.isEmpty()) { return null; } // Check cache first final Object cacheKey = CacheKeyFactory.createKey(destClass, srcClass); if (converterTypeCache.containsKey(cacheKey)) { // even null return (Class) converterTypeCache.get(cacheKey); } // Let's see if the incoming class is a primitive: final Class src = ClassUtils.primitiveToWrapper(srcClass); final Class dest = ClassUtils.primitiveToWrapper(destClass); Class appropriateConverter = findConverter(src, dest); converterTypeCache.put(cacheKey, appropriateConverter); return appropriateConverter; }
private Collection<ClassMap> checkForSuperTypeMapping(Class<?> srcClass, Class<?> destClass) { // Check cache first Object cacheKey = CacheKeyFactory.createKey(destClass, srcClass); Collection<ClassMap> cachedResult = (Collection<ClassMap>) superTypeCache.get(cacheKey); if (cachedResult != null) { return cachedResult; } // If no existing cache entry is found, determine super type mappings. // Recursively walk the inheritance hierarchy. List<ClassMap> superClasses = new ArrayList<ClassMap>(); // Need to call getRealSuperclass because proxied data objects will not return correct // superclass when using basic reflection List<Class<?>> superSrcClasses = MappingUtils.getSuperClassesAndInterfaces(srcClass); List<Class<?>> superDestClasses = MappingUtils.getSuperClassesAndInterfaces(destClass); // add the actual classes to check for mappings between the original and the opposite // super classes superSrcClasses.add(0, srcClass); superDestClasses.add(0, destClass); for (Class<?> superSrcClass : superSrcClasses) { for (Class<?> superDestClass : superDestClasses) { if (!(superSrcClass.equals(srcClass) && superDestClass.equals(destClass))) { checkForClassMapping(superSrcClass, superClasses, superDestClass); } } } Collections.reverse(superClasses); // Done so base classes are processed first superTypeCache.put(cacheKey, superClasses); return superClasses; }
if (cache.containsKey(cacheKey)) { return (CustomConverter) cache.get(cacheKey); cache.put(cacheKey, converterInstance);
if (cache.containsKey(cacheKey)) { return (CustomConverter) cache.get(cacheKey); cache.put(cacheKey, converterInstance);
public void addCache(Cache cache) { synchronized (cachesMap) { String name = cache.getName(); if (cacheExists(name)) { MappingUtils.throwMappingException("Cache already exists with name: " + name); } cachesMap.put(name, cache); } }
public void clearAllEntries() { for (Cache cache : cachesMap.values()) { cache.clear(); } }