001/**
002 * Copyright 2005-2017 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.ken.core;
017
018import org.kuali.rice.ken.dao.NotificationDao;
019import org.kuali.rice.ken.api.service.KENAPIService;
020import org.kuali.rice.ken.dao.NotificationMessegeDeliveryDao;
021import org.kuali.rice.ken.service.NotificationAuthorizationService;
022import org.kuali.rice.ken.service.NotificationChannelService;
023import org.kuali.rice.ken.service.NotificationContentTypeService;
024import org.kuali.rice.ken.service.NotificationMessageContentService;
025import org.kuali.rice.ken.service.NotificationMessageDeliveryAutoRemovalService;
026import org.kuali.rice.ken.service.NotificationMessageDeliveryResolverService;
027import org.kuali.rice.ken.service.NotificationMessageDeliveryService;
028import org.kuali.rice.ken.service.NotificationRecipientService;
029import org.kuali.rice.ken.service.NotificationService;
030import org.kuali.rice.ken.service.NotificationWorkflowDocumentService;
031import org.kuali.rice.ken.service.UserPreferenceService;
032import org.quartz.Scheduler;
033import org.springframework.beans.factory.BeanFactory;
034
035/**
036 * NotificationServiceLocator backed by a Spring Bean Factory - responsible for returning instances of services instantiated by the Spring context loader.
037 * @author Kuali Rice Team (rice.collab@kuali.org)
038 */
039public class SpringNotificationServiceLocator implements NotificationServiceLocator {
040    // Spring bean names
041    private static final String KENAPI_SERVICE = "kenApiService";
042    private static final String NOTIFICATION_SERVICE = "notificationService";
043    private static final String NOTIFICATION_CONTENT_TYPE_SERVICE = "notificationContentTypeService";
044    private static final String MESSAGE_CONTENT_SERVICE = "messageContentService";
045    private static final String NOTIFICATION_DAO = "kenNotificationDao";
046    private static final String NOTIFICATION_MESSEGE_DELIVERY_DAO = "kenNotificationMessegeDeliveryDao";
047    
048    private static final String NOTIFICATION_AUTHORIZATION_SERVICE = "notificationAuthorizationService";
049    private static final String NOTIFICATION_WORKFLOW_DOCUMENT_SERVICE = "notificationWorkflowDocumentService";
050    private static final String NOTIFICATION_MESSAGE_DELIVERY_DISPATCH_SERVICE = "notificationMessageDeliveryDispatchService";
051    private static final String NOTIFICATION_MESSAGE_DELIVERY_RESOLVER_SERVICE = "notificationMessageDeliveryResolverService";
052    private static final String NOTIFICATION_MESSAGE_DELIVERY_AUTOREMOVAL_SERVICE = "notificationMessageDeliveryAutoRemovalService";
053    private static final String NOTIFICATION_RECIPIENT_SERVICE = "notificationRecipientService";
054    private static final String NOTIFICATION_MESSAGE_DELIVERY_SERVICE = "notificationMessageDeliveryService";
055    private static final String NOTIFICATION_MESSAGE_DELIVERER_REGISTRY_SERVICE = "notificationMessageDelivererRegistryService";
056    private static final String USER_PREFERENCE_SERVICE = "userPreferenceService";
057    private static final String NOTIFICATION_CHANNEL_SERVICE = "notificationChannelService";
058    private static final String NOTIFICATION_EMAIL_SERVICE = "notificationEmailService";
059    private static final String NOTIFICATION_CONFIG = "notificationConfig";
060    private static final String NOTIFICATION_SCHEDULER = "notificationScheduler";
061
062    private BeanFactory beanFactory;
063
064    /**
065     * Constructs a SpringNotificationServiceLocator.java.
066     * @param beanFactory
067     */
068    public SpringNotificationServiceLocator(BeanFactory beanFactory) {
069        this.beanFactory = beanFactory;
070    }
071    
072    public KENAPIService getKENAPIService() {
073        return (KENAPIService) beanFactory.getBean(KENAPI_SERVICE);
074    }
075
076
077    /**
078     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationService()
079     */
080    public NotificationService getNotificationService() {
081        return (NotificationService) beanFactory.getBean(NOTIFICATION_SERVICE);
082    }
083
084    /**
085     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationContentTypeService()
086     */
087    public NotificationContentTypeService getNotificationContentTypeService() {
088        return (NotificationContentTypeService) beanFactory.getBean(NOTIFICATION_CONTENT_TYPE_SERVICE);
089    }
090
091    /**
092     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationMessageContentService()
093     */
094    public NotificationMessageContentService getNotificationMessageContentService() {
095        return (NotificationMessageContentService) beanFactory.getBean(MESSAGE_CONTENT_SERVICE);
096    }
097
098    public NotificationDao getNotificationDao() {
099        return (NotificationDao) beanFactory.getBean(NOTIFICATION_DAO);
100    }
101    
102    public NotificationMessegeDeliveryDao getNotificationMessegDeliveryDao() {
103        return (NotificationMessegeDeliveryDao) beanFactory.getBean(NOTIFICATION_MESSEGE_DELIVERY_DAO);
104    }
105
106    /**
107     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationAuthorizationService()
108     */
109    public NotificationAuthorizationService getNotificationAuthorizationService() {
110        return (NotificationAuthorizationService) beanFactory.getBean(NOTIFICATION_AUTHORIZATION_SERVICE);
111    }
112    
113    /**
114     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationWorkflowDocumentService()
115     */
116    public NotificationWorkflowDocumentService getNotificationWorkflowDocumentService() {
117        return (NotificationWorkflowDocumentService) beanFactory.getBean(NOTIFICATION_WORKFLOW_DOCUMENT_SERVICE);
118    }
119    
120    /**
121     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationMessageDeliveryAutoRemovalService()
122     */
123    public NotificationMessageDeliveryAutoRemovalService getNotificationMessageDeliveryAutoRemovalService() {
124        return (NotificationMessageDeliveryAutoRemovalService) beanFactory.getBean(NOTIFICATION_MESSAGE_DELIVERY_AUTOREMOVAL_SERVICE);
125    }
126
127    /**
128     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationMessageDeliveryResolverService()
129     */
130    public NotificationMessageDeliveryResolverService getNotificationMessageDeliveryResolverService() {
131        return (NotificationMessageDeliveryResolverService) beanFactory.getBean(NOTIFICATION_MESSAGE_DELIVERY_RESOLVER_SERVICE);
132    }
133    
134    /**
135     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationRecipientService()
136     */
137    public NotificationRecipientService getNotificationRecipientService() {
138        return (NotificationRecipientService) beanFactory.getBean(NOTIFICATION_RECIPIENT_SERVICE);
139    }
140    
141    /**
142     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationMessageDeliveryService()
143     */
144    public NotificationMessageDeliveryService getNotificationMessageDeliveryService() {
145        return (NotificationMessageDeliveryService) beanFactory.getBean(NOTIFICATION_MESSAGE_DELIVERY_SERVICE);
146    }
147    
148    /**
149     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getUserPreferenceService()
150     */
151    public UserPreferenceService getUserPreferenceService() {
152        return (UserPreferenceService) beanFactory.getBean(USER_PREFERENCE_SERVICE);
153    }
154    
155    /**
156     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getNotificationChannelService()
157     */
158    public NotificationChannelService getNotificationChannelService() {
159        return (NotificationChannelService) beanFactory.getBean(NOTIFICATION_CHANNEL_SERVICE);
160    }
161
162    /**
163     * @see org.kuali.rice.ken.core.NotificationServiceLocator#getScheduler()
164     */
165    public Scheduler getScheduler() {
166        return (Scheduler) beanFactory.getBean(NOTIFICATION_SCHEDULER);
167    }
168}