KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > business > UpdateAllImpl


1 /*
2  * snapper
3  *
4  * Enhydra super-servlet business object
5  *
6  */

7
8 package org.enhydra.snapper.business;
9
10
11 import org.enhydra.dods.DODS;
12 import org.enhydra.dods.DODSException;
13 import org.enhydra.snapper.SnapperManager;
14 import org.enhydra.snapper.spec.Update;
15 import org.enhydra.snapper.spec.UpdateAll;
16 import org.enhydra.snapper.spec.UpdateThreadFactory;
17
18 import com.lutris.appserver.server.sql.DatabaseManager;
19
20
21 // Enhydra SuperServlet specification imports
22

23
24 // Standard imports
25
//import java.text.DateFormat;
26

27
28     public class UpdateAllImpl implements UpdateAll, Runnable JavaDoc {
29    
30     private String JavaDoc[] ids;
31     private DatabaseManager dbm;
32
33     public void run() {
34         try {
35             for (int numSites = 0; numSites < ids.length; numSites++) {
36                 try {
37                     Update update = UpdateThreadFactory.getUpdateThread("org.enhydra.snapper.business.UpdateThread");
38                     String JavaDoc id = ids[numSites];
39                     update.update(id, dbm);
40                     SnapperManager.getInstance().addThread(id, update);
41
42                     DatabaseManager tempDbManager = DODS.getDatabaseManager(Thread.currentThread());
43                     new Thread JavaDoc((Runnable JavaDoc) update, id).run();
44                     DODS.register(Thread.currentThread(), tempDbManager);
45
46                     // new Thread((Runnable) update, id).run();
47
} catch (Exception JavaDoc e) {
48                     SnapperManager.getInstance().getLoggingManager().error("Could not update site");
49                 }
50             }
51         } finally {
52             try {
53                 DODS.unregister(Thread.currentThread());
54             } catch (DODSException e) {
55                 e.printStackTrace();
56             }
57         }
58     }
59     
60     public void stop(){};
61
62     public UpdateAllImpl() {
63     }
64     
65     public void update(String JavaDoc[] ids, DatabaseManager dbm){
66         this.ids = ids;
67         this.dbm = dbm;
68     }
69
70 }
Popular Tags