1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service;
17
18 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
19 import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform;
20 import org.kuali.rice.krad.data.DataObjectService;
21 import org.kuali.rice.krad.data.metadata.MetadataRepository;
22 import org.kuali.rice.krad.data.provider.ProviderRegistry;
23
24 import javax.persistence.EntityManagerFactory;
25 import javax.sql.DataSource;
26
27
28
29
30
31
32 public class KRADServiceLocator {
33 public static final String ATTACHMENT_SERVICE = "attachmentService";
34 public static final String NOTE_SERVICE = "noteService";
35 public static final String ENTITY_MANAGER_FACTORY = "entityManagerFactory";
36 public static final String APPLICATION_ENTITY_MANAGER_FACTORY = "kradApplicationEntityManagerFactory";
37 public static final String XML_OBJECT_SERIALIZER_SERVICE = "xmlObjectSerializerService";
38 public static final String XML_OBJECT_SERIALIZER_IGNORE_MISSING_FIELDS_SERVICE =
39 "xmlObjectSerializerIgnoreMissingFieldsService";
40 public static final String KNS_SERIALIZER_SERVICE = "businessObjectSerializerService";
41 public static final String KRAD_SERIALIZER_SERVICE = "dataObjectSerializerService";
42 public static final String MAIL_SERVICE = "mailService";
43 public static final String DB_PLATFORM = "dbPlatform";
44 public static final String INACTIVATEABLE_FROM_TO_SERVICE = "inactivateableFromToService";
45 public static final String KD_DATA_OBJECT_SERVICE = "kd-dataObjectService";
46 public static final String KD_METADATA_REPOSITORY = "kd-metadataRepository";
47 public static final String KD_PROVIDER_REGISTRY = "kd-providerRegistry";
48 public static final String LEGACY_DATA_ADAPTER_FRAMEWORK = "legacyAppFrameworkAdapter";
49 public static final String KRAD_APPLICATION_DATA_SOURCE = "kradApplicationDataSource";
50
51 static <T> T getService(String serviceName) {
52 return GlobalResourceLoader.<T>getService(serviceName);
53 }
54
55 public static AttachmentService getAttachmentService() {
56 return getService(ATTACHMENT_SERVICE);
57 }
58
59
60 public static NoteService getNoteService() {
61 return getService(NOTE_SERVICE);
62 }
63
64 public static EntityManagerFactory getEntityManagerFactory() {
65 return getService(ENTITY_MANAGER_FACTORY);
66 }
67
68 public static EntityManagerFactory getApplicationEntityManagerFactory() {
69 return getService(APPLICATION_ENTITY_MANAGER_FACTORY);
70 }
71
72 public static XmlObjectSerializerService getXmlObjectSerializerService() {
73 return getService(XML_OBJECT_SERIALIZER_SERVICE);
74 }
75
76 public static XmlObjectSerializerService getXmlObjectSerializerIgnoreMissingFieldsService() {
77 return getService(XML_OBJECT_SERIALIZER_IGNORE_MISSING_FIELDS_SERVICE);
78 }
79
80 public static BusinessObjectSerializerService getBusinessObjectSerializerService() {
81 return getService(KNS_SERIALIZER_SERVICE);
82 }
83
84 public static BusinessObjectSerializerService getDataObjectSerializerService() {
85 return getService(KRAD_SERIALIZER_SERVICE);
86 }
87
88 public static final MailService getMailService() {
89 return (MailService) getService(MAIL_SERVICE);
90 }
91
92 public static DatabasePlatform getDatabasePlatform() {
93 return (DatabasePlatform) getService(DB_PLATFORM);
94 }
95
96 public static InactivateableFromToService getInactivateableFromToService() {
97 return (InactivateableFromToService) getService(INACTIVATEABLE_FROM_TO_SERVICE);
98 }
99
100 public static LegacyAppFrameworkAdapterService getLegacyAppFrameworkAdapterService(){
101 return (LegacyAppFrameworkAdapterService) getService(LEGACY_DATA_ADAPTER_FRAMEWORK);
102 }
103
104
105 public static DataObjectService getDataObjectService() {
106 return getService(KD_DATA_OBJECT_SERVICE);
107 }
108
109 public static MetadataRepository getMetadataRepository() {
110 return getService(KD_METADATA_REPOSITORY);
111 }
112
113 public static ProviderRegistry getProviderRegistry() {
114 return getService(KD_PROVIDER_REGISTRY);
115 }
116
117 public static DataSource getKradApplicationDataSource() {
118 return getService(KRAD_APPLICATION_DATA_SOURCE);
119 }
120
121 }