1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.framework.services;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20 import org.kuali.rice.kim.api.type.KimType;
21 import org.kuali.rice.kim.api.type.KimTypeUtils;
22 import org.kuali.rice.kim.framework.type.KimTypeService;
23
24 import javax.xml.namespace.QName;
25
26 public class KimFrameworkServiceLocator {
27 private static final Logger LOG = Logger.getLogger(KimFrameworkServiceLocator.class);
28
29 static <T> T getService(String serviceName) {
30 return GlobalResourceLoader.<T>getService(serviceName);
31 }
32
33
34
35
36
37
38 public static KimTypeService getKimTypeService(KimType kimType) {
39 if( kimType == null ) {
40 throw new IllegalArgumentException("Invalid service name passed, value was null.");
41 }
42 return getKimTypeService(KimTypeUtils.resolveKimTypeServiceName(kimType.getServiceName()));
43 }
44
45
46
47
48
49
50
51 public static KimTypeService getKimTypeService(QName kimTypeServiceName) {
52 if (kimTypeServiceName == null) {
53 throw new IllegalArgumentException("Invalid service name passed, value was null.");
54 }
55 try {
56 return (KimTypeService) GlobalResourceLoader.getService(kimTypeServiceName);
57 } catch (Exception exception) {
58
59
60
61
62 LOG.error("Unable to find KIM type service with name: " + kimTypeServiceName, exception);
63 return null;
64 }
65 }
66 }