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