MentaContainer

Compare Revisions

Regard whitespace Rev 141 → Rev 142

/trunk/src/main/java/org/mentacontainer/impl/MentaContainer.java
12,7 → 12,6
import org.mentacontainer.ConfigurableFactory;
import org.mentacontainer.Container;
import org.mentacontainer.Creator;
import org.mentacontainer.Interceptor;
import org.mentacontainer.Pool;
import org.mentacontainer.Scope;
import org.mentacontainer.util.InjectionUtils;
40,7 → 39,7
private Set<ConstructorDependency> forConstructMethod = Collections.synchronizedSet(new HashSet<ConstructorDependency>());
@Override
public Class<? extends Object> getType(Object key) {
public Class<?> getType(Object key) {
String k = InjectionUtils.getKeyName(key);
216,8 → 215,6
target = c.createInstance();
checkInterceptable(c, target);
synchronized(this) {
 
singletonsCache.put(keyString, target);
270,8 → 267,6
target = c.createInstance();
checkInterceptable(c, target);
t.set(target);
}
287,8 → 282,6
 
target = c.createInstance();
checkInterceptable(c, target);
} else {
throw new UnsupportedOperationException("Don't know how to handle scope: " + scope);
338,16 → 331,6
}
}
private final void checkInterceptable(Creator<?> f, Object value) {
if (f instanceof Interceptor) {
Interceptor i = (Interceptor) f;
((Interceptor) f).onCreated(value);
}
}
private static <T> Pool<T> fromFactory(final Creator<T> creator) {
return new Pool<T>() {
371,10 → 354,15
@Override
public <T> Creator<T> ioc(Object key, Creator<T> factory, Scope scope) {
return ioc(key, fromFactory(factory), scope);
}
@Override
public <T> Pool<T> ioc(Object key, Pool<T> factory, Scope scope) {
String keyString = InjectionUtils.getKeyName(key);
factoriesByName.put(keyString, fromFactory(factory));
factoriesByName.put(keyString, factory);
singletonsCache.remove(keyString); // just in case we are overriding a previous singleton bean...
391,12 → 379,18
}
@Override
public Creator<?> ioc(Object key, Creator<?> factory) {
public <T> Creator<T> ioc(Object key, Creator<T> factory) {
return ioc(key, factory, Scope.NONE);
return ioc(key, fromFactory(factory));
}
@Override
public <T> Pool<T> ioc(Object key, Pool<T> pool) {
return ioc(key, pool, Scope.NONE);
}
@Override
public <T> ConfigurableFactory<T> ioc(Object key, Class<T> klass) {
ConfigurableFactory<T> cc = new ClassFactory<T>(this, klass);