remove dsl caching in Casser, no need it
This commit is contained in:
parent
9afca8a957
commit
e6dae633f7
1 changed files with 1 additions and 19 deletions
|
@ -16,8 +16,6 @@
|
||||||
package casser.core;
|
package casser.core;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
|
||||||
|
|
||||||
import casser.config.CasserSettings;
|
import casser.config.CasserSettings;
|
||||||
import casser.config.DefaultCasserSettings;
|
import casser.config.DefaultCasserSettings;
|
||||||
|
@ -31,8 +29,6 @@ public final class Casser {
|
||||||
|
|
||||||
private static volatile CasserSettings settings = new DefaultCasserSettings();
|
private static volatile CasserSettings settings = new DefaultCasserSettings();
|
||||||
|
|
||||||
private static final ConcurrentMap<Class<?>, Object> dslCache = new ConcurrentHashMap<Class<?>, Object>();
|
|
||||||
|
|
||||||
private Casser() {
|
private Casser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,21 +66,7 @@ public final class Casser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <E> E dsl(Class<E> iface, ClassLoader classLoader) {
|
public static <E> E dsl(Class<E> iface, ClassLoader classLoader) {
|
||||||
|
return settings.getDslInstantiator().instantiate(iface, classLoader);
|
||||||
Object instance = dslCache.get(iface);
|
|
||||||
|
|
||||||
if (instance == null) {
|
|
||||||
|
|
||||||
instance = settings.getDslInstantiator().instantiate(iface, classLoader);
|
|
||||||
|
|
||||||
Object c = dslCache.putIfAbsent(iface, instance);
|
|
||||||
if (c != null) {
|
|
||||||
instance = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (E) instance;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <E> E wrap(Map<String, Object> map, Class<E> iface) {
|
public static <E> E wrap(Map<String, Object> map, Class<E> iface) {
|
||||||
|
|
Loading…
Reference in a new issue