MentaContainer

Rev

Rev 22 | Rev 40 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22 Rev 39
Line 106... Line 106...
106
106
107
                        throw new RuntimeException(e);
107
                        throw new RuntimeException(e);
108
                }
108
                }
109
        }
109
        }
110
110
111
        public Component ioc(Component component) {
-
 
-
 
111
        public Component ioc(String key, Component component) {
112
               
112
               
113
                String key = component.getName();
-
 
114
-
 
115
                if (beans.containsKey(key)) throw new RuntimeException("Container already set for the bean key: " + key);
113
                if (beans.containsKey(key)) throw new RuntimeException("Container already set for the bean key: " + key);
116
114
117
                beans.put(key, component);
115
                beans.put(key, component);
118
116
119
                return component;
117
                return component;
120
        }
118
        }
121
       
119
       
122
        public Component ioc(String key, Class<? extends Object> klass) {
120
        public Component ioc(String key, Class<? extends Object> klass) {
123
               
121
               
124
                return ioc(new MentaComponent(key, klass));
-
 
-
 
122
                return ioc(key, new MentaComponent(klass));
125
        }
123
        }
126
       
124
       
127
        public Component ioc(String key, Class<? extends Object> klass, boolean singleton) {
125
        public Component ioc(String key, Class<? extends Object> klass, boolean singleton) {
128
               
126
               
129
                return ioc(new MentaComponent(key, klass, singleton));
-
 
-
 
127
                return ioc(key, new MentaComponent(klass, singleton));
130
        }
128
        }
131
129
132
        public Dependency autowire(Dependency d) {
130
        public Dependency autowire(Dependency d) {
133
131
134
                if (dependencies.contains(d)) throw new RuntimeException("Dependency is already set: " + d.getTarget());
132
                if (dependencies.contains(d)) throw new RuntimeException("Dependency is already set: " + d.getTarget());