1 /*
2 * Copyright 2004-2005 OpenSymphony
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy
6 * of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
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, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 *
16 */
17
18 /*
19 * Previously Copyright (c) 2001-2004 James House
20 */
21 package org.quartz.simpl;
22
23 import java.util.Date;
24
25 import org.quartz.SchedulerConfigException;
26 import org.quartz.spi.TimeBroker;
27
28 /**
29 * <p>
30 * The interface to be implemented by classes that want to provide a mechanism
31 * by which the <code>{@link org.quartz.core.QuartzScheduler}</code> can
32 * reliably determine the current time.
33 * </p>
34 *
35 * <p>
36 * In general, the default implementation of this interface (<code>{@link org.quartz.simpl.SimpleTimeBroker}</code>-
37 * which simply uses <code>System.getCurrentTimeMillis()</code> )is
38 * sufficient. However situations may exist where this default scheme is
39 * lacking in its robustsness - especially when Quartz is used in a clustered
40 * configuration. For example, if one or more of the machines in the cluster
41 * has a system time that varies by more than a few seconds from the clocks on
42 * the other systems in the cluster, scheduling confusion will result.
43 * </p>
44 *
45 * @see org.quartz.core.QuartzScheduler
46 *
47 * @author James House
48 */
49 public class SimpleTimeBroker implements TimeBroker {
50
51 /*
52 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53 *
54 * Interface.
55 *
56 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57 */
58
59 /**
60 * <p>
61 * Get the current time, simply using <code>new Date()</code>.
62 * </p>
63 */
64 public Date getCurrentTime() {
65 return new Date();
66 }
67
68 public void initialize() throws SchedulerConfigException {
69 // do nothing...
70 }
71
72 public void shutdown() {
73 // do nothing...
74 }
75
76 }