MentaContainer

Compare Revisions

Ignore whitespace Rev 105 → Rev 106

/trunk/src/main/java/org/mentacontainer/impl/MentaContainer.java
12,7 → 12,7
import org.mentacontainer.ConfigurableFactory;
import org.mentacontainer.Container;
import org.mentacontainer.Factory;
import org.mentacontainer.Interceptable;
import org.mentacontainer.Interceptor;
import org.mentacontainer.Scope;
import org.mentacontainer.util.InjectionUtils;
import org.mentacontainer.util.InjectionUtils.Provider;
59,11 → 59,11
for(String key : singletonsCache.keySet()) {
Factory comp = factoriesByName.get(key);
Factory factory = factoriesByName.get(key);
if (comp instanceof Interceptable) {
if (factory instanceof Interceptor) {
Interceptable<Object> c = (Interceptable<Object>) comp;
Interceptor c = (Interceptor) factory;
Object value = singletonsCache.get(key);
86,11 → 86,11
for(String key : threadLocalsCache.keySet()) {
Factory comp = factoriesByName.get(key);
Factory factory = factoriesByName.get(key);
if (comp instanceof Interceptable) {
if (factory instanceof Interceptor) {
Interceptable<Object> c = (Interceptable<Object>) comp;
Interceptor c = (Interceptor) factory;
ThreadLocal<Object> t = threadLocalsCache.get(key);
131,18 → 131,18
if (value != null) {
Factory comp = factoriesByName.get(key);
Factory factory = factoriesByName.get(key);
if (comp instanceof Interceptable) {
if (factory instanceof Interceptor) {
Interceptable<Object> c = (Interceptable<Object>) comp;
Interceptor c = (Interceptor) factory;
cp = new ClearableHolder(c, value);
}
}
}
if (cp != null) cp.c.onCleared(cp.value);
if (cp != null) cp.c.onDestroyed(cp.value);
return (T) value;
162,11 → 162,11
if (o != null) {
Factory comp = factoriesByName.get(key);
Factory factory = factoriesByName.get(key);
if (comp instanceof Interceptable) {
if (factory instanceof Interceptor) {
Interceptable<Object> c = (Interceptable<Object>) comp;
Interceptor c = (Interceptor) factory;
cp = new ClearableHolder(c, o);
}
178,7 → 178,7
}
}
if (cp != null) cp.c.onCleared(cp.value);
if (cp != null) cp.c.onDestroyed(cp.value);
return (T) retVal;
353,11 → 353,11
private final void checkInterceptable(Factory f, Object value) {
if (f instanceof Interceptable) {
if (f instanceof Interceptor) {
Interceptable i = (Interceptable) f;
Interceptor i = (Interceptor) f;
((Interceptable) f).onCreated(value);
((Interceptor) f).onCreated(value);
}
}
517,16 → 517,16
private static class ClearableHolder {
 
private Interceptable<Object> c;
private Interceptor c;
private Object value;
public ClearableHolder(Interceptable<Object> c, Object value) {
public ClearableHolder(Interceptor c, Object value) {
this.c = c;
this.value = value;
}
public void clear() {
c.onCleared(value);
c.onDestroyed(value);
}
}