1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.scheduler;
16  
17  import com.liferay.portal.kernel.scheduler.messaging.SchedulerRequest;
18  
19  import java.util.Date;
20  import java.util.List;
21  
22  /**
23   * <a href="SchedulerEngineUtil.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Bruno Farache
26   */
27  public class SchedulerEngineUtil {
28  
29      public static List<SchedulerRequest> getScheduledJobs(String groupName)
30          throws SchedulerException {
31  
32          return _instance._getScheduledJobs(groupName);
33      }
34  
35      public static void init(SchedulerEngine defaultScheduler) {
36          _instance._init(defaultScheduler);
37      }
38  
39      public static void schedule(
40              String groupName, long interval, Date startDate, Date endDate,
41              String description, String destinationName, String messageBody)
42          throws SchedulerException {
43  
44          _instance._schedule(
45              groupName, interval, startDate, endDate, description,
46              destinationName, messageBody);
47      }
48  
49      public static void schedule(
50              String groupName, String cronText, Date startDate, Date endDate,
51              String description, String destinationName, String messageBody)
52          throws SchedulerException {
53  
54          _instance._schedule(
55              groupName, cronText, startDate, endDate, description,
56              destinationName, messageBody);
57      }
58  
59      public static void schedule(
60              String jobName, String groupName, long interval, Date startDate,
61              Date endDate, String description, String destinationName,
62              String messageBody)
63          throws SchedulerException {
64  
65          _instance._schedule(
66              jobName, groupName, interval, startDate, endDate, description,
67              destinationName, messageBody);
68      }
69  
70      public static void schedule(
71              String jobName, String groupName, String cronText, Date startDate,
72              Date endDate, String description, String destinationName,
73              String messageBody)
74          throws SchedulerException {
75  
76          _instance._schedule(
77              jobName, groupName, cronText, startDate, endDate, description,
78              destinationName, messageBody);
79      }
80  
81      public static void shutdown() throws SchedulerException {
82          _instance._shutdown();
83      }
84  
85      public static void start() throws SchedulerException {
86          _instance._start();
87      }
88  
89      public static void unschedule(String jobName, String groupName)
90          throws SchedulerException {
91  
92          _instance._unschedule(jobName, groupName);
93      }
94  
95      private SchedulerEngine _schedulerEngine;
96  
97      private List<SchedulerRequest> _getScheduledJobs(String groupName)
98          throws SchedulerException {
99  
100         return _schedulerEngine.getScheduledJobs(groupName);
101     }
102 
103     private void _init(SchedulerEngine schedulerEngine) {
104         _schedulerEngine = schedulerEngine;
105     }
106 
107     private void _schedule(
108             String groupName, long interval, Date startDate, Date endDate,
109             String description, String destinationName, String messageBody)
110         throws SchedulerException {
111 
112         _schedulerEngine.schedule(
113             groupName, interval, startDate, endDate, description,
114             destinationName, messageBody);
115     }
116 
117     private void _schedule(
118             String groupName, String cronText, Date startDate, Date endDate,
119             String description, String destinationName, String messageBody)
120         throws SchedulerException {
121 
122         _schedulerEngine.schedule(
123             groupName, cronText, startDate, endDate, description,
124             destinationName, messageBody);
125     }
126 
127     private void _schedule(
128             String jobName, String groupName, long interval, Date startDate,
129             Date endDate, String description, String destinationName,
130             String messageBody)
131         throws SchedulerException {
132 
133         _schedulerEngine.schedule(
134             jobName, groupName, interval, startDate, endDate, description,
135             destinationName, messageBody);
136     }
137 
138     private void _schedule(
139             String jobName, String groupName, String cronText, Date startDate,
140             Date endDate, String description, String destinationName,
141             String messageBody)
142         throws SchedulerException {
143 
144         _schedulerEngine.schedule(
145             jobName, groupName, cronText, startDate, endDate, description,
146             destinationName, messageBody);
147     }
148 
149     private void _shutdown() throws SchedulerException {
150         _schedulerEngine.shutdown();
151     }
152 
153     private void _start() throws SchedulerException {
154         _schedulerEngine.start();
155     }
156 
157     private void _unschedule(String jobName, String groupName)
158         throws SchedulerException {
159 
160         _schedulerEngine.unschedule(jobName, groupName);
161     }
162 
163     private static SchedulerEngineUtil _instance = new SchedulerEngineUtil();
164 
165 }