Rev 103 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 103 | Rev 105 | ||
---|---|---|---|
Line 17... | Line 17... | ||
17 | case5(); |
17 | case5(); |
18 | case6(); |
18 | case6(); |
19 | case7(); |
19 | case7(); |
20 | case8(); |
20 | case8(); |
21 | case9(); |
21 | case9(); |
- | 22 | case10(); |
|
22 | }
|
23 | }
|
23 | 24 | ||
24 | public static class Connection { |
25 | public static class Connection { |
25 | 26 | ||
26 | }
|
27 | }
|
Line 239... | Line 240... | ||
239 | c.inject(service); // populate (inject) all properties of SomeService with |
240 | c.inject(service); // populate (inject) all properties of SomeService with |
240 | // beans from the container
|
241 | // beans from the container
|
241 | 242 | ||
242 | service.doSomething(); // ==> "saoj" |
243 | service.doSomething(); // ==> "saoj" |
243 | }
|
244 | }
|
- | 245 | ||
- | 246 | public static class SomeService2 { |
|
- | 247 | ||
- | 248 | private final UserDAO userDAO; |
|
- | 249 | ||
- | 250 | public SomeService2(UserDAO userDAO) { |
|
- | 251 | this.userDAO = userDAO; |
|
- | 252 | }
|
|
- | 253 | ||
- | 254 | public void doSomething() { |
|
- | 255 | System.out.println(userDAO.getUsername(11)); |
|
- | 256 | }
|
|
- | 257 | }
|
|
- | 258 | ||
- | 259 | private static void case10() { |
|
- | 260 | ||
- | 261 | Container c = new MentaContainer(); |
|
- | 262 | ||
- | 263 | c.ioc("userDAO", JdbcUserDAO.class); |
|
- | 264 | ||
- | 265 | c.ioc("connection", Connection.class); |
|
- | 266 | ||
- | 267 | c.autowire("connection"); |
|
- | 268 | ||
- | 269 | SomeService2 service = c.construct(SomeService2.class); |
|
- | 270 | ||
- | 271 | service.doSomething(); // ==> "saoj" |
|
- | 272 | }
|
|
244 | 273 | ||
245 | }
|
274 | }
|