KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > sync > SyncScheduler


1 package de.webman.sync;
2
3 import de.webman.util.registry.Registry;
4 import de.webman.util.registry.RegistryConstants;
5 import de.webman.util.registry.RegistryException;
6 import de.webman.util.scheduler.SchedulerService;
7 import de.webman.util.scheduler.SchedulerException;
8 import org.apache.log4j.Category;
9
10
11 /**
12  * This scheduler service starts a synchronization of an external access
13  * control system
14  *
15  * @author <a HREF="mailto:gregor@webman.de">Gregor Klinke</a>
16  * @version $Revision: 1.2 $
17  **/

18 public class SyncScheduler
19     implements SchedulerService
20 {
21     /* $Id: SyncScheduler.java,v 1.2 2002/04/12 14:56:01 gregor Exp $ */
22     /**
23      * logging facility
24      **/

25     private static Category cat = Category.getInstance(SyncScheduler.class);
26
27     /**
28      * starts a new process cycle. The process is run in a thread on its
29      * one, so that access to class wide data has to be synchronized and
30      * locked properly.
31      *
32      * @throws SchedulerException may be thrown by the implementation if
33      * anything failed during service execution
34      **/

35     public void execute()
36         throws SchedulerException
37     {
38         SyncMgr reg = null;
39
40         try {
41             reg = (SyncMgr)Registry.getInstance().lookup(RegistryConstants.SYNC_MANAGER);
42         }
43         catch (RegistryException re) {
44             throw new SchedulerException(re);
45         }
46         
47         if (reg != null) {
48             try {
49                 reg.runSynchronization();
50             }
51             catch (SyncBusyException sbe) {
52                 cat.warn("Synchronization is still busy. This sync cycle is ignored");
53             }
54             catch (SyncException se) {
55                 cat.error("Synchronization exception: " + se);
56             }
57         }
58     }
59     
60 }
61
Popular Tags