1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package net.sf.pmr.core;
37
38 import net.sf.pmr.core.data.basicProject.BasicProjectMapper;
39 import net.sf.pmr.core.data.reference.CountryMapper;
40 import net.sf.pmr.core.data.user.UserMapper;
41 import net.sf.pmr.core.data.user.company.CompanyMapper;
42 import net.sf.pmr.core.domain.basicProject.BasicProject;
43 import net.sf.pmr.core.domain.basicProject.BasicProjectRepository;
44 import net.sf.pmr.core.domain.basicProject.DomainCollectionLasyLoadingInterceptor;
45 import net.sf.pmr.core.domain.reference.Country;
46 import net.sf.pmr.core.domain.user.User;
47 import net.sf.pmr.core.domain.user.UserRepository;
48 import net.sf.pmr.core.domain.user.company.Address;
49 import net.sf.pmr.core.domain.user.company.Company;
50 import net.sf.pmr.core.service.BasicProjectService;
51 import net.sf.pmr.core.service.SecurityService;
52 import net.sf.pmr.core.service.UserService;
53 import net.sf.pmr.keopsframework.domain.validation.Errors;
54 import net.sf.pmr.keopsframework.domain.validation.Validator;
55
56 import org.springframework.beans.factory.BeanFactory;
57 import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
58
59
60 /***
61 * @author Arnaud
62 */
63 public final class CoreObjectFactory {
64
65 private CoreObjectFactory() {
66 super();
67 }
68
69 /***
70 * get an object from the Spring application context
71 * @param objectName
72 * @return object
73 */
74 private static Object getObject(final String objectName) {
75
76 return ContextSingletonBeanFactoryLocator.getInstance().useBeanFactory(
77 "net.sf.pmr.core").getFactory().getBean(objectName);
78
79 }
80
81 /***
82 * get the bean factory
83 * @return beanFactory
84 */
85 private static BeanFactory getBeanFactory() {
86
87 return ContextSingletonBeanFactoryLocator.getInstance().useBeanFactory(
88 "net.sf.pmr.core").getFactory();
89 }
90
91 /***
92 * is an object singleton ?
93 * @param object
94 * @return boolean
95 */
96 public static boolean isSingleton(final String object) {
97
98 return CoreObjectFactory.getBeanFactory().isSingleton(object);
99
100 }
101
102
103 /***
104 * get the address
105 * @return address
106 */
107 public static Errors getErrors() {
108
109 return (Errors) CoreObjectFactory.getObject("coreErrors");
110 }
111
112
113 /***
114 * get the address
115 * @return address
116 */
117 public static Address getAddress() {
118
119 return (Address) CoreObjectFactory.getObject("address");
120 }
121
122
123 /***
124 * get Company validator
125 * @return validator
126 */
127 public static Validator getAddressValidator() {
128
129 return (Validator) CoreObjectFactory.getObject("addressValidator");
130
131 }
132
133
134 /***
135 * get the company
136 * @return company
137 */
138 public static Company getCompany() {
139
140 return (Company) CoreObjectFactory.getObject("company");
141 }
142
143 /***
144 * get Company validator
145 * @return validator
146 */
147 public static Validator getCompanyValidator() {
148
149 return (Validator) CoreObjectFactory.getObject("companyValidator");
150
151 }
152
153
154
155 /***
156 * get the companyMapper
157 * @return companyMapper
158 */
159 public static CompanyMapper getCompanyMapper() {
160
161 return (CompanyMapper) CoreObjectFactory.getObject("companyMapper");
162 }
163
164 /***
165 * get the user
166 * @return user
167 */
168 public static User getUser() {
169
170 return (User) CoreObjectFactory.getObject("user");
171 }
172
173
174 public static Validator getUserValidator() {
175
176 return (Validator) CoreObjectFactory.getObject("userValidator");
177
178 }
179
180 /***
181 * get the userService
182 * @return userService
183 */
184 public static UserService getUserService() {
185
186 return (UserService) CoreObjectFactory.getObject("userService");
187
188 }
189
190
191 /***
192 * get the userMapper
193 * @return userMapper
194 */
195 public static UserMapper getUserMapper() {
196
197 return (UserMapper) CoreObjectFactory.getObject("userMapper");
198 }
199
200
201 /***
202 * get the basicProject
203 * @return basicProject
204 */
205 public static BasicProject getBasicProject() {
206
207 return (BasicProject) CoreObjectFactory.getObject("basicProject");
208 }
209
210
211 /***
212 * get the basicProjectMapper
213 * @return basicProject
214 */
215 public static BasicProjectMapper getBasicProjectMapper() {
216
217 return (BasicProjectMapper) CoreObjectFactory.getObject("basicProjectMapper");
218 }
219
220
221 /***
222 * get the basicProjectRepository
223 * @return basicProjectRepository
224 */
225 public static BasicProjectRepository getBasicProjectRepository() {
226
227 return (BasicProjectRepository) CoreObjectFactory.getObject("basicProjectRepository");
228 }
229
230 /***
231 * get the basicProjectValidator
232 * @return basicProjectValidator
233 */
234 public static Validator getBasicProjectValidator() {
235
236 return (Validator) CoreObjectFactory.getObject("basicProjectValidator");
237 }
238
239 /***
240 * get the basicProjectService
241 * @return basicProjectService
242 */
243 public static BasicProjectService getBasicProjectService() {
244
245 return (BasicProjectService) CoreObjectFactory.getObject("basicProjectService");
246 }
247
248
249
250 public static DomainCollectionLasyLoadingInterceptor getMembersLasyLoadingAdvice() {
251
252 return (DomainCollectionLasyLoadingInterceptor) CoreObjectFactory.getObject("membersLasyLoadingAdvice");
253
254 }
255
256
257 /***
258 * get the country
259 * @return country
260 */
261 public static Country getCountry() {
262
263 return (Country) CoreObjectFactory.getObject("country");
264 }
265
266
267 /***
268 * get the countryMapper
269 * @return countryMapper
270 */
271 public static CountryMapper getCountryMapper() {
272
273 return (CountryMapper) CoreObjectFactory.getObject("countryMapper");
274 }
275
276 /***
277 * get the securityService
278 * @return securityService
279 */
280 public static SecurityService getSecurityService() {
281
282 return (SecurityService) CoreObjectFactory.getObject("securityService");
283 }
284
285
286 /***
287 * get the userRepository
288 * @return userRepository
289 */
290 public static UserRepository getUserRepository() {
291
292 return (UserRepository) CoreObjectFactory.getObject("userRepository");
293 }
294
295 }