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.config.property.ConfigurationService;
019import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
020
021import javax.persistence.EntityManagerFactory;
022
023public class KRADServiceLocator {
024    public static final String ATTACHMENT_SERVICE = "attachmentService";
025    public static final String PERSISTENCE_SERVICE = "persistenceService";
026    public static final String PERSISTENCE_STRUCTURE_SERVICE = "persistenceStructureService";
027    public static final String NOTE_SERVICE = "noteService";
028    public static final String BUSINESS_OBJECT_SERVICE = "businessObjectService";
029    public static final String KUALI_CONFIGURATION_SERVICE = "kualiConfigurationService";
030    public static final String ENTITY_MANAGER_FACTORY = "entityManagerFactory";
031    public static final String APPLICATION_ENTITY_MANAGER_FACTORY = "kradApplicationEntityManagerFactory";
032    public static final String XML_OBJECT_SERIALIZER_SERVICE = "xmlObjectSerializerService";
033    public static final String XML_OBJECT_SERIALIZER_IGNORE_MISSING_FIELDS_SERVICE = "xmlObjectSerializerIgnoreMissingFieldsService";
034    public static final String SERIALIZER_SERVICE = "businessObjectSerializerService";
035    public static final String SEQUENCE_ACCESSOR_SERVICE = "sequenceAccessorService";
036    public static final String KEY_VALUES_SERVICE = "keyValuesService";
037
038
039    static <T> T getService(String serviceName) {
040        return GlobalResourceLoader.<T>getService(serviceName);
041    }
042
043    public static AttachmentService getAttachmentService() {
044        return getService(ATTACHMENT_SERVICE);
045    }
046
047    public static PersistenceService getPersistenceService() {
048        return getService(PERSISTENCE_SERVICE);
049    }
050
051    public static PersistenceStructureService getPersistenceStructureService() {
052        return getService(PERSISTENCE_STRUCTURE_SERVICE);
053    }
054
055    public static NoteService getNoteService() {
056        return getService(NOTE_SERVICE);
057    }
058
059    public static BusinessObjectService getBusinessObjectService() {
060        return getService(BUSINESS_OBJECT_SERVICE);
061    }
062
063    public static ConfigurationService getKualiConfigurationService() {
064        return getService(KUALI_CONFIGURATION_SERVICE);
065    }
066
067    public static EntityManagerFactory getEntityManagerFactory() {
068        return getService(ENTITY_MANAGER_FACTORY);
069    }
070
071    public static EntityManagerFactory getApplicationEntityManagerFactory() {
072        return getService(APPLICATION_ENTITY_MANAGER_FACTORY);
073    }
074
075    public static XmlObjectSerializerService getXmlObjectSerializerService() {
076        return getService(XML_OBJECT_SERIALIZER_SERVICE);
077    }
078
079    public static XmlObjectSerializerService getXmlObjectSerializerIgnoreMissingFieldsService() {
080        return getService(XML_OBJECT_SERIALIZER_IGNORE_MISSING_FIELDS_SERVICE);
081    }
082
083    public static BusinessObjectSerializerService getBusinessObjectSerializerService() {
084        return getService(SERIALIZER_SERVICE);
085    }
086
087    public static SequenceAccessorService getSequenceAccessorService() {
088        return getService(SEQUENCE_ACCESSOR_SERVICE);
089    }
090
091    public static KeyValuesService getKeyValuesService() {
092        return getService(KEY_VALUES_SERVICE);
093    }
094}