|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.hivemind.service.impl; |
|
16 |
| |
|
17 |
| import java.util.ArrayList; |
|
18 |
| import java.util.HashMap; |
|
19 |
| import java.util.Iterator; |
|
20 |
| import java.util.List; |
|
21 |
| import java.util.Map; |
|
22 |
| |
|
23 |
| import org.apache.hivemind.ServiceImplementationFactoryParameters; |
|
24 |
| import org.apache.hivemind.impl.BaseLocatable; |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| public class BuilderParameter extends BaseLocatable |
|
32 |
| { |
|
33 |
| private String _className; |
|
34 |
| |
|
35 |
| private List _properties = new ArrayList(); |
|
36 |
| |
|
37 |
| private List _parameters = new ArrayList(); |
|
38 |
| |
|
39 |
| |
|
40 |
| private Map _typeFacetMap = new HashMap(); |
|
41 |
| |
|
42 |
| private List _events = new ArrayList(); |
|
43 |
| |
|
44 |
| private String _initializeMethod; |
|
45 |
| |
|
46 |
| private boolean _autowireServices; |
|
47 |
| |
|
48 |
790
| public String getClassName()
|
|
49 |
| { |
|
50 |
790
| return _className;
|
|
51 |
| } |
|
52 |
| |
|
53 |
46
| public void addParameter(BuilderFacet facet)
|
|
54 |
| { |
|
55 |
46
| _parameters.add(facet);
|
|
56 |
| } |
|
57 |
| |
|
58 |
790
| public List getParameters()
|
|
59 |
| { |
|
60 |
790
| return _parameters;
|
|
61 |
| } |
|
62 |
| |
|
63 |
3314
| public void addProperty(BuilderFacet facet)
|
|
64 |
| { |
|
65 |
3314
| _properties.add(facet);
|
|
66 |
| } |
|
67 |
| |
|
68 |
789
| public List getProperties()
|
|
69 |
| { |
|
70 |
789
| return _properties;
|
|
71 |
| } |
|
72 |
| |
|
73 |
| |
|
74 |
11
| public BuilderFacet getFacetForType(ServiceImplementationFactoryParameters factoryParameters,
|
|
75 |
| Class targetType) |
|
76 |
| { |
|
77 |
11
| BuilderFacet result = (BuilderFacet) _typeFacetMap.get(targetType);
|
|
78 |
| |
|
79 |
11
| if (result == null)
|
|
80 |
| { |
|
81 |
11
| for (Iterator i = _properties.iterator(); i.hasNext();)
|
|
82 |
| { |
|
83 |
30
| BuilderFacet facet = (BuilderFacet) i.next();
|
|
84 |
| |
|
85 |
30
| if (facet.canAutowireConstructorParameter()
|
|
86 |
| && facet.isAssignableToType(factoryParameters, targetType)) |
|
87 |
| { |
|
88 |
3
| result = facet;
|
|
89 |
3
| break;
|
|
90 |
| } |
|
91 |
| } |
|
92 |
| |
|
93 |
11
| _typeFacetMap.put(targetType, result);
|
|
94 |
| } |
|
95 |
| |
|
96 |
11
| return result;
|
|
97 |
| } |
|
98 |
| |
|
99 |
490
| public void setClassName(String string)
|
|
100 |
| { |
|
101 |
490
| _className = string;
|
|
102 |
| } |
|
103 |
| |
|
104 |
3
| public void addEventRegistration(EventRegistration registration)
|
|
105 |
| { |
|
106 |
3
| _events.add(registration);
|
|
107 |
| } |
|
108 |
| |
|
109 |
789
| public List getEventRegistrations()
|
|
110 |
| { |
|
111 |
789
| return _events;
|
|
112 |
| } |
|
113 |
| |
|
114 |
789
| public String getInitializeMethod()
|
|
115 |
| { |
|
116 |
789
| return _initializeMethod;
|
|
117 |
| } |
|
118 |
| |
|
119 |
6
| public void setInitializeMethod(String string)
|
|
120 |
| { |
|
121 |
6
| _initializeMethod = string;
|
|
122 |
| } |
|
123 |
| |
|
124 |
1579
| public boolean getAutowireServices()
|
|
125 |
| { |
|
126 |
1579
| return _autowireServices;
|
|
127 |
| } |
|
128 |
| |
|
129 |
486
| public void setAutowireServices(boolean autowireServices)
|
|
130 |
| { |
|
131 |
486
| _autowireServices = autowireServices;
|
|
132 |
| } |
|
133 |
| |
|
134 |
| } |