View Javadoc

1   /**
2    * Copyright 2005-2013 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.resourceloader.GlobalResourceLoader;
19  import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform;
20  
21  import javax.persistence.EntityManagerFactory;
22  
23  /**
24   * Service locator for the KRAD App Module
25   *
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public class KRADServiceLocator {
29      public static final String ATTACHMENT_SERVICE = "attachmentService";
30      public static final String PERSISTENCE_SERVICE = "persistenceService";
31      public static final String PERSISTENCE_STRUCTURE_SERVICE = "persistenceStructureService";
32      public static final String NOTE_SERVICE = "noteService";
33      public static final String BUSINESS_OBJECT_SERVICE = "businessObjectService";
34      public static final String ENTITY_MANAGER_FACTORY = "entityManagerFactory";
35      public static final String APPLICATION_ENTITY_MANAGER_FACTORY = "kradApplicationEntityManagerFactory";
36      public static final String XML_OBJECT_SERIALIZER_SERVICE = "xmlObjectSerializerService";
37      public static final String XML_OBJECT_SERIALIZER_IGNORE_MISSING_FIELDS_SERVICE =
38              "xmlObjectSerializerIgnoreMissingFieldsService";
39      public static final String SERIALIZER_SERVICE = "businessObjectSerializerService";
40      public static final String SEQUENCE_ACCESSOR_SERVICE = "sequenceAccessorService";
41      public static final String KEY_VALUES_SERVICE = "keyValuesService";
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  
46      static <T> T getService(String serviceName) {
47          return GlobalResourceLoader.<T>getService(serviceName);
48      }
49  
50      public static AttachmentService getAttachmentService() {
51          return getService(ATTACHMENT_SERVICE);
52      }
53  
54      public static PersistenceService getPersistenceService() {
55          return getService(PERSISTENCE_SERVICE);
56      }
57  
58      public static PersistenceStructureService getPersistenceStructureService() {
59          return getService(PERSISTENCE_STRUCTURE_SERVICE);
60      }
61  
62      public static NoteService getNoteService() {
63          return getService(NOTE_SERVICE);
64      }
65  
66      public static BusinessObjectService getBusinessObjectService() {
67          return getService(BUSINESS_OBJECT_SERVICE);
68      }
69  
70      public static EntityManagerFactory getEntityManagerFactory() {
71          return getService(ENTITY_MANAGER_FACTORY);
72      }
73  
74      public static EntityManagerFactory getApplicationEntityManagerFactory() {
75          return getService(APPLICATION_ENTITY_MANAGER_FACTORY);
76      }
77  
78      public static XmlObjectSerializerService getXmlObjectSerializerService() {
79          return getService(XML_OBJECT_SERIALIZER_SERVICE);
80      }
81  
82      public static XmlObjectSerializerService getXmlObjectSerializerIgnoreMissingFieldsService() {
83          return getService(XML_OBJECT_SERIALIZER_IGNORE_MISSING_FIELDS_SERVICE);
84      }
85  
86      public static BusinessObjectSerializerService getBusinessObjectSerializerService() {
87          return getService(SERIALIZER_SERVICE);
88      }
89  
90      public static SequenceAccessorService getSequenceAccessorService() {
91          return getService(SEQUENCE_ACCESSOR_SERVICE);
92      }
93  
94      public static KeyValuesService getKeyValuesService() {
95          return getService(KEY_VALUES_SERVICE);
96      }
97  
98      public static final MailService getMailService() {
99          return (MailService) getService(MAIL_SERVICE);
100     }
101 
102     public static DatabasePlatform getDatabasePlatform() {
103         return (DatabasePlatform) getService(DB_PLATFORM);
104     }
105 
106     public static InactivateableFromToService getInactivateableFromToService() {
107         return (InactivateableFromToService) getService(INACTIVATEABLE_FROM_TO_SERVICE);
108     }
109 
110 }