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 ; 9 10 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 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 ServicesRegistry.getInstance().getJahiaSearchService() 38 .addScheduledDocumentToSearchEngine(doc); 39 } catch ( Throwable t ) { 40 } 41 job.decrementNbDocs(); 42 } 43 try { 44 Thread.sleep(job.getSleepInterval()); 45 ServicesRegistry.getInstance().getJahiaSearchService() 46 .notifyMainIndexThread(); 47 } catch ( InterruptedException ie ){ 48 logger.debug("Exception occurred in job pause ", ie); 49 } 50 } 51 } 52 53 } 54 | Popular Tags |