View Javadoc
1   /**
2    * Copyright 2005-2015 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.kew.mail;
17  
18  
19  import org.kuali.rice.core.api.lifecycle.Lifecycle;
20  import org.kuali.rice.kew.api.exception.WorkflowException;
21  import org.kuali.rice.kew.service.KEWServiceLocator;
22  import org.kuali.rice.ksb.service.KSBServiceLocator;
23  import org.quartz.Scheduler;
24  
25  
26  /**
27   * A {@link Lifecycle} which is initialized on system startup that sets up
28   * the daily and weekly email reminders.
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class EmailReminderLifecycle implements Lifecycle {
33  
34  	private boolean started;
35  
36  	public boolean isStarted() {
37  		return started;
38  	}
39  
40  	public void start() throws Exception {
41  		// fetch scheduler here to initialize it outside of a transactional context, otherwise we get weird transaction errors
42  	    Scheduler scheduler = KSBServiceLocator.getScheduler();
43  	    if (scheduler == null) {
44  		throw new WorkflowException("Failed to locate Quartz Scheduler Service.");
45  	    }
46  	    KEWServiceLocator.getActionListEmailService().scheduleBatchEmailReminders();
47  	    started = true;
48  	}
49  
50  	public void stop() throws Exception {
51  		started = false;
52  	}
53  
54  }