MentaContainer

Compare Revisions

Ignore whitespace Rev 57 → Rev 58

/trunk/src/main/java/org/mentacontainer/impl/MentaContainer.java
45,6 → 45,42
}
}
}
public <T> T clear(String key) {
Scope scope = scopes.get(key);
if (scope == Scope.SINGLETON) {
return (T) singletonsCache.remove(key);
} else if (scope == Scope.THREAD) {
ThreadLocal<Object> t = threadLocalsCache.get(key);
if (t != null) {
Object o = t.get();
if (o != null) {
t.set(null);
return (T) o;
}
}
return null;
} else if (scope == Scope.NONE) {
return null; // always...
} else {
throw new UnsupportedOperationException("Scope not supported: " + scope);
}
}
 
public <T> T get(String key) {
 
232,9 → 268,9
return MentaContainer.this.get(key);
}
public boolean contains(String key) {
public boolean hasValue(String key) {
return MentaContainer.this.contains(key);
return MentaContainer.this.check(key);
}
};
251,8 → 287,27
return this;
}
 
public boolean contains(String key) {
 
return beans.containsKey(key);
public boolean check(String key) {
Scope scope = scopes.get(key);
if (scope == Scope.NONE) {
return false; // always...
} else if (scope == Scope.SINGLETON) {
return singletonsCache.containsKey(key);
} else if (scope == Scope.THREAD) {
ThreadLocal<Object> t = threadLocalsCache.get(key);
return t.get() != null;
} else {
throw new UnsupportedOperationException("This scope is not supported: " + scope);
}
}
}