Search in sources :

Example 1 with ModelCache

use of freemarker.ext.util.ModelCache in project freemarker by apache.

the class ClassIntrospector method remove.

/**
 * Corresponds to {@link BeansWrapper#removeFromClassIntrospectionCache(Class)}.
 *
 * @since 2.3.20
 */
void remove(Class<?> clazz) {
    synchronized (sharedLock) {
        cache.remove(clazz);
        cacheClassNames.remove(clazz.getName());
        clearingCounter++;
        for (WeakReference<Object> regedMfREf : modelFactories) {
            Object regedMf = regedMfREf.get();
            if (regedMf != null) {
                if (regedMf instanceof ClassBasedModelFactory) {
                    ((ClassBasedModelFactory) regedMf).removeFromCache(clazz);
                } else if (regedMf instanceof ModelCache) {
                    // doesn't support selective clearing ATM
                    ((ModelCache) regedMf).clearCache();
                } else {
                    throw new BugException();
                }
            }
        }
        removeClearedModelFactoryReferences();
    }
}
Also used : BugException(freemarker.core.BugException) ModelCache(freemarker.ext.util.ModelCache)

Example 2 with ModelCache

use of freemarker.ext.util.ModelCache in project freemarker by apache.

the class ClassIntrospector method forcedClearCache.

private void forcedClearCache() {
    synchronized (sharedLock) {
        cache.clear();
        cacheClassNames.clear();
        clearingCounter++;
        for (WeakReference<Object> regedMfREf : modelFactories) {
            Object regedMf = regedMfREf.get();
            if (regedMf != null) {
                if (regedMf instanceof ClassBasedModelFactory) {
                    ((ClassBasedModelFactory) regedMf).clearCache();
                } else if (regedMf instanceof ModelCache) {
                    ((ModelCache) regedMf).clearCache();
                } else {
                    throw new BugException();
                }
            }
        }
        removeClearedModelFactoryReferences();
    }
}
Also used : BugException(freemarker.core.BugException) ModelCache(freemarker.ext.util.ModelCache)

Aggregations

BugException (freemarker.core.BugException)2 ModelCache (freemarker.ext.util.ModelCache)2