KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > search > ScheduledIndexationJob


1 package org.jahia.services.search;
2
3 import org.quartz.StatefulJob;
4 import org.quartz.JobExecutionContext;
5 import org.quartz.JobExecutionException;
6 import org.jahia.registries.ServicesRegistry;
7
8 import java.util.Vector JavaDoc;
9
10 /**
11  * Created by IntelliJ IDEA.
12  * User: hollis
13  * Date: 26 avr. 2005
14  * Time: 16:08:05
15  * To change this template use File | Settings | File Templates.
16  */

17 public class ScheduledIndexationJob implements StatefulJob {
18
19     private static org.apache.log4j.Logger logger =
20         org.apache.log4j.Logger.getLogger(ScheduledIndexationJob.class);
21
22     public ScheduledIndexationJob () {
23     }
24
25     public void execute (JobExecutionContext context)
26         throws JobExecutionException {
27
28         IndexationJobDetail job = (IndexationJobDetail)context.getJobDetail();
29         while ( true ) {
30             Vector JavaDoc v = job.getAllDocuments();
31             JahiaIndexableDocument doc = null;
32             for ( int i=0; i<v.size(); i++ ){
33                 doc = (JahiaIndexableDocument)v.get(i);
34                 try {
35                     doc.doScheduledLoad();
36                     // put it back in the search indexation queue
37
ServicesRegistry.getInstance().getJahiaSearchService()
38                         .addScheduledDocumentToSearchEngine(doc);
39                 } catch ( Throwable JavaDoc t ) {
40                 }
41                 job.decrementNbDocs();
42             }
43             try {
44                 Thread.sleep(job.getSleepInterval());
45                 ServicesRegistry.getInstance().getJahiaSearchService()
46                         .notifyMainIndexThread();
47             } catch ( InterruptedException JavaDoc ie ){
48                 logger.debug("Exception occurred in job pause ", ie);
49             }
50         }
51     }
52
53 }
54
Popular Tags