View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.service;
17  
18  import org.kuali.rice.core.api.config.property.ConfigurationService;
19  import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20  
21  import javax.persistence.EntityManagerFactory;
22  
23  public class KRADServiceLocator {
24      public static final String ATTACHMENT_SERVICE = "attachmentService";
25      public static final String PERSISTENCE_SERVICE = "persistenceService";
26      public static final String PERSISTENCE_STRUCTURE_SERVICE = "persistenceStructureService";
27      public static final String NOTE_SERVICE = "noteService";
28      public static final String BUSINESS_OBJECT_SERVICE = "businessObjectService";
29      public static final String KUALI_CONFIGURATION_SERVICE = "kualiConfigurationService";
30      public static final String ENTITY_MANAGER_FACTORY = "entityManagerFactory";
31      public static final String APPLICATION_ENTITY_MANAGER_FACTORY = "kradApplicationEntityManagerFactory";
32      public static final String XML_OBJECT_SERIALIZER_SERVICE = "xmlObjectSerializerService";
33      public static final String SERIALIZER_SERVICE = "businessObjectSerializerService";
34      public static final String SEQUENCE_ACCESSOR_SERVICE = "sequenceAccessorService";
35      public static final String KEY_VALUES_SERVICE = "keyValuesService";
36  
37  
38      static <T> T getService(String serviceName) {
39          return GlobalResourceLoader.<T>getService(serviceName);
40      }
41  
42      public static AttachmentService getAttachmentService() {
43          return getService(ATTACHMENT_SERVICE);
44      }
45  
46      public static PersistenceService getPersistenceService() {
47          return getService(PERSISTENCE_SERVICE);
48      }
49  
50      public static PersistenceStructureService getPersistenceStructureService() {
51          return getService(PERSISTENCE_STRUCTURE_SERVICE);
52      }
53  
54      public static NoteService getNoteService() {
55          return getService(NOTE_SERVICE);
56      }
57  
58      public static BusinessObjectService getBusinessObjectService() {
59          return getService(BUSINESS_OBJECT_SERVICE);
60      }
61  
62      public static ConfigurationService getKualiConfigurationService() {
63          return getService(KUALI_CONFIGURATION_SERVICE);
64      }
65  
66      public static EntityManagerFactory getEntityManagerFactory() {
67          return getService(ENTITY_MANAGER_FACTORY);
68      }
69  
70      public static EntityManagerFactory getApplicationEntityManagerFactory() {
71          return getService(APPLICATION_ENTITY_MANAGER_FACTORY);
72      }
73  
74      public static XmlObjectSerializerService getXmlObjectSerializerService() {
75          return getService(XML_OBJECT_SERIALIZER_SERVICE);
76      }
77  
78      public static BusinessObjectSerializerService getBusinessObjectSerializerService() {
79          return getService(SERIALIZER_SERVICE);
80      }
81  
82      public static SequenceAccessorService getSequenceAccessorService() {
83          return getService(SEQUENCE_ACCESSOR_SERVICE);
84      }
85  
86      public static KeyValuesService getKeyValuesService() {
87          return getService(KEY_VALUES_SERVICE);
88      }
89  }