001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.service; 017 018import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; 019import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform; 020 021import javax.persistence.EntityManagerFactory; 022 023/** 024 * Service locator for the KRAD App Module 025 * 026 * @author Kuali Rice Team (rice.collab@kuali.org) 027 */ 028public class KRADServiceLocator { 029 public static final String ATTACHMENT_SERVICE = "attachmentService"; 030 public static final String PERSISTENCE_SERVICE = "persistenceService"; 031 public static final String PERSISTENCE_STRUCTURE_SERVICE = "persistenceStructureService"; 032 public static final String NOTE_SERVICE = "noteService"; 033 public static final String BUSINESS_OBJECT_SERVICE = "businessObjectService"; 034 public static final String ENTITY_MANAGER_FACTORY = "entityManagerFactory"; 035 public static final String APPLICATION_ENTITY_MANAGER_FACTORY = "kradApplicationEntityManagerFactory"; 036 public static final String XML_OBJECT_SERIALIZER_SERVICE = "xmlObjectSerializerService"; 037 public static final String XML_OBJECT_SERIALIZER_IGNORE_MISSING_FIELDS_SERVICE = 038 "xmlObjectSerializerIgnoreMissingFieldsService"; 039 public static final String SERIALIZER_SERVICE = "businessObjectSerializerService"; 040 public static final String SEQUENCE_ACCESSOR_SERVICE = "sequenceAccessorService"; 041 public static final String KEY_VALUES_SERVICE = "keyValuesService"; 042 public static final String MAIL_SERVICE = "mailService"; 043 public static final String DB_PLATFORM = "dbPlatform"; 044 public static final String INACTIVATEABLE_FROM_TO_SERVICE = "inactivateableFromToService"; 045 046 static <T> T getService(String serviceName) { 047 return GlobalResourceLoader.<T>getService(serviceName); 048 } 049 050 public static AttachmentService getAttachmentService() { 051 return getService(ATTACHMENT_SERVICE); 052 } 053 054 public static PersistenceService getPersistenceService() { 055 return getService(PERSISTENCE_SERVICE); 056 } 057 058 public static PersistenceStructureService getPersistenceStructureService() { 059 return getService(PERSISTENCE_STRUCTURE_SERVICE); 060 } 061 062 public static NoteService getNoteService() { 063 return getService(NOTE_SERVICE); 064 } 065 066 public static BusinessObjectService getBusinessObjectService() { 067 return getService(BUSINESS_OBJECT_SERVICE); 068 } 069 070 public static EntityManagerFactory getEntityManagerFactory() { 071 return getService(ENTITY_MANAGER_FACTORY); 072 } 073 074 public static EntityManagerFactory getApplicationEntityManagerFactory() { 075 return getService(APPLICATION_ENTITY_MANAGER_FACTORY); 076 } 077 078 public static XmlObjectSerializerService getXmlObjectSerializerService() { 079 return getService(XML_OBJECT_SERIALIZER_SERVICE); 080 } 081 082 public static XmlObjectSerializerService getXmlObjectSerializerIgnoreMissingFieldsService() { 083 return getService(XML_OBJECT_SERIALIZER_IGNORE_MISSING_FIELDS_SERVICE); 084 } 085 086 public static BusinessObjectSerializerService getBusinessObjectSerializerService() { 087 return getService(SERIALIZER_SERVICE); 088 } 089 090 public static SequenceAccessorService getSequenceAccessorService() { 091 return getService(SEQUENCE_ACCESSOR_SERVICE); 092 } 093 094 public static KeyValuesService getKeyValuesService() { 095 return getService(KEY_VALUES_SERVICE); 096 } 097 098 public static final MailService getMailService() { 099 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}