KickJava   Java API By Example, From Geeks To Geeks.

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


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.Index;
15 import org.enhydra.snapper.spec.IndexAll;
16 import org.enhydra.snapper.spec.IndexFactory;
17
18 import com.lutris.appserver.server.sql.DatabaseManager;
19
20
21 // Enhydra SuperServlet specification imports
22

23     /**
24      * @author Igor Smirnov
25      * IndexAllImpl class starts indexing threads for all sites by
26      * starting indexing threads one-by-one.
27      * Start-waitToFinish-StartNext
28      */

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