MentaContainer

Compare Revisions

Ignore whitespace Rev 4 → Rev 3

/trunk/src/main/java/org/mentacontainer/impl/Dependency.java
17,6 → 17,8
private Map<String, Method> cache = new HashMap<String, Method>();
private Map<Object, Object> received = new WeakHashMap<Object, Object>();
public Dependency(String target, Class<? extends Object> klass, String source) {
this.klass = klass;
103,4 → 105,30
 
return null;
}
/*
* Check if this object has already received the dependency, because we don't want to
* inject every time. Injecting just once is the correct behavior.
*/
public boolean hasAlreadyReceived(Object target) {
 
synchronized(received) {
 
return received.containsKey(target);
 
}
}
/*
* Flag that this object has already received the dependency.
*/
public void setAlreadyReceived(Object target) {
 
synchronized(received) {
 
received.put(target, null);
 
}
}
 
}