diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractCustomContext.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractCustomContext.java index 4ac5cac..51146fb 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractCustomContext.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractCustomContext.java @@ -36,7 +36,6 @@ */ package br.gov.frameworkdemoiselle.internal.context; -import java.io.Serializable; import java.lang.annotation.Annotation; import java.util.Collections; import java.util.HashMap; @@ -194,40 +193,38 @@ public abstract class AbstractCustomContext implements CustomContext { return true; } - static class Store implements Serializable { + static class Store { - private static final long serialVersionUID = -8237464177510563034L; - - private final String SEPARATOR = "#"; - - private Map cache = Collections.synchronizedMap(new HashMap()); + private Map, Object>> cache = Collections + .synchronizedMap(new HashMap, Object>>()); + + private Store() { + } private boolean contains(final Class type) { - return cache.containsKey( prefixId(type) ); + return this.getMap().containsKey(type); } private Object get(final Class type) { - return cache.get( prefixId(type) ); + return this.getMap().get(type); } private void put(final Class type, final Object instance) { - cache.put( prefixId(type) , instance); + this.getMap().put(type, instance); } public void clear() { cache.clear(); } - - private String prefixId(Class type){ - return Thread.currentThread().getContextClassLoader().toString() + SEPARATOR + type.getCanonicalName(); - } - /*private Map getMap() { + private Map, Object> getMap() { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + if (!cache.containsKey(classLoader)) { cache.put(classLoader, Collections.synchronizedMap(new HashMap, Object>())); } return cache.get(classLoader); - }*/ + } } } -- libgit2 0.21.2