1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.hivemind.lib.factory; |
16 |
| |
17 |
| import org.apache.hivemind.ApplicationRuntimeException; |
18 |
| import org.apache.hivemind.HiveMind; |
19 |
| import org.apache.hivemind.Location; |
20 |
| import org.apache.hivemind.internal.Module; |
21 |
| import org.apache.hivemind.lib.BeanFactory; |
22 |
| import org.apache.hivemind.service.ObjectProvider; |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| public class BeanFactoryObjectProvider implements ObjectProvider |
34 |
| { |
35 |
4
| public Object provideObject(
|
36 |
| Module contributingModule, |
37 |
| Class propertyType, |
38 |
| String inputValue, |
39 |
| Location location) |
40 |
| { |
41 |
4
| if (HiveMind.isBlank(inputValue))
|
42 |
1
| return null;
|
43 |
| |
44 |
3
| int colonx = inputValue.indexOf(':');
|
45 |
| |
46 |
3
| if (colonx < 0)
|
47 |
1
| throw new ApplicationRuntimeException(
|
48 |
| FactoryMessages.invalidBeanTranslatorFormat(inputValue), |
49 |
| location, |
50 |
| null); |
51 |
| |
52 |
2
| String serviceId = inputValue.substring(0, colonx);
|
53 |
| |
54 |
2
| if (serviceId.length() == 0)
|
55 |
0
| throw new ApplicationRuntimeException(
|
56 |
| FactoryMessages.invalidBeanTranslatorFormat(inputValue), |
57 |
| location, |
58 |
| null); |
59 |
| |
60 |
2
| String locator = inputValue.substring(colonx + 1);
|
61 |
| |
62 |
2
| if (locator.length() == 0)
|
63 |
1
| throw new ApplicationRuntimeException(
|
64 |
| FactoryMessages.invalidBeanTranslatorFormat(inputValue), |
65 |
| location, |
66 |
| null); |
67 |
| |
68 |
1
| BeanFactory f = (BeanFactory) contributingModule.getService(serviceId, BeanFactory.class);
|
69 |
| |
70 |
1
| return f.get(locator);
|
71 |
| } |
72 |
| |
73 |
| } |