MentaContainer

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 4
Line 14... Line 14...
14
        private String source;
14
        private String source;
15
       
15
       
16
        private final Class<? extends Object> klass;
16
        private final Class<? extends Object> klass;
17
       
17
       
18
        private Map<String, Method> cache = new HashMap<String, Method>();
18
        private Map<String, Method> cache = new HashMap<String, Method>();
19
       
-
 
20
        private Map<Object, Object> received = new WeakHashMap<Object, Object>();
-
 
21
       
19
       
22
        public Dependency(String target, Class<? extends Object> klass, String source) {
20
        public Dependency(String target, Class<? extends Object> klass, String source) {
23
               
21
               
24
                this.klass = klass;
22
                this.klass = klass;
25
               
23
               
Line 103... Line 101...
103
               
101
               
104
        }
102
        }
105
103
106
        return null;
104
        return null;
107
    }
105
    }
108
   
-
 
109
    /*
-
 
110
     * Check if this object has already received the dependency, because we don't want to
-
 
111
     * inject every time. Injecting just once is the correct behavior.
-
 
112
     */
-
 
113
    public boolean hasAlreadyReceived(Object target) {
-
 
114
-
 
115
        synchronized(received) {
-
 
116
-
 
117
            return received.containsKey(target);
-
 
118
-
 
119
        }
-
 
120
    }
-
 
121
   
-
 
122
    /*
-
 
123
     * Flag that this object has already received the dependency.
-
 
124
     */
-
 
125
    public void setAlreadyReceived(Object target) {
-
 
126
-
 
127
        synchronized(received) {
-
 
128
-
 
129
            received.put(target, null);
-
 
130
-
 
131
        }
-
 
132
    }
-
 
133
-
 
134
}
106
}