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 SERIALIZER_SERVICE = "businessObjectSerializerService";
41 public static final String MAIL_SERVICE = "mailService";
42 public static final String DB_PLATFORM = "dbPlatform";
43 public static final String INACTIVATEABLE_FROM_TO_SERVICE = "inactivateableFromToService";
44 public static final String KD_DATA_OBJECT_SERVICE = "kd-dataObjectService";
45 public static final String KD_METADATA_REPOSITORY = "kd-metadataRepository";
46 public static final String KD_PROVIDER_REGISTRY = "kd-providerRegistry";
47 public static final String LEGACY_DATA_ADAPTER_FRAMEWORK = "legacyAppFrameworkAdapter";
48 public static final String KRAD_APPLICATION_DATA_SOURCE = "kradApplicationDataSource";
49
50 static <T> T getService(String serviceName) {
51 return GlobalResourceLoader.<T>getService(serviceName);
52 }
53
54 public static AttachmentService getAttachmentService() {
55 return getService(ATTACHMENT_SERVICE);
56 }
57
58
59 public static NoteService getNoteService() {
60 return getService(NOTE_SERVICE);
61 }
62
63 public static EntityManagerFactory getEntityManagerFactory() {
64 return getService(ENTITY_MANAGER_FACTORY);
65 }
66
67 public static EntityManagerFactory getApplicationEntityManagerFactory() {
68 return getService(APPLICATION_ENTITY_MANAGER_FACTORY);
69 }
70
71 public static XmlObjectSerializerService getXmlObjectSerializerService() {
72 return getService(XML_OBJECT_SERIALIZER_SERVICE);
73 }
74
75 public static XmlObjectSerializerService getXmlObjectSerializerIgnoreMissingFieldsService() {
76 return getService(XML_OBJECT_SERIALIZER_IGNORE_MISSING_FIELDS_SERVICE);
77 }
78
79 public static BusinessObjectSerializerService getBusinessObjectSerializerService() {
80 return getService(SERIALIZER_SERVICE);
81 }
82
83 public static final MailService getMailService() {
84 return (MailService) getService(MAIL_SERVICE);
85 }
86
87 public static DatabasePlatform getDatabasePlatform() {
88 return (DatabasePlatform) getService(DB_PLATFORM);
89 }
90
91 public static InactivateableFromToService getInactivateableFromToService() {
92 return (InactivateableFromToService) getService(INACTIVATEABLE_FROM_TO_SERVICE);
93 }
94
95 public static LegacyAppFrameworkAdapterService getLegacyAppFrameworkAdapterService(){
96 return (LegacyAppFrameworkAdapterService) getService(LEGACY_DATA_ADAPTER_FRAMEWORK);
97 }
98
99
100 public static DataObjectService getDataObjectService() {
101 return getService(KD_DATA_OBJECT_SERVICE);
102 }
103
104 public static MetadataRepository getMetadataRepository() {
105 return getService(KD_METADATA_REPOSITORY);
106 }
107
108 public static ProviderRegistry getProviderRegistry() {
109 return getService(KD_PROVIDER_REGISTRY);
110 }
111
112 public static DataSource getKradApplicationDataSource() {
113 return getService(KRAD_APPLICATION_DATA_SOURCE);
114 }
115
116 }