For a basic scheduler we need following files :
2.TaskScheduler.java
This scheduler runs every 2 minutes.
- schedular-context.xml
- TaskScheduler.java
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <beans> <bean id="TaskTrigger" class="org.alfresco.util.CronTriggerBean"> <property name="jobDetail"> <bean id="completeTaskTriggerJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass"> <value> org.alfresco.repo.importer.ImporterJob </value> </property> <property name="jobDataAsMap"> <map> <entry key="bean"> <ref bean="TaskScheduler" /> </entry> </map> </property> </bean> </property> <property name="cronExpression"> <value>0 0/2 * * * ?</value> </property> <property name="scheduler"> <ref bean="schedulerFactory" /> </property> </bean> <bean id="TaskScheduler" class="com.company.core.scheduler.TaskScheduler"> <property name="serviceRegistry"> <ref bean="ServiceRegistry" /> </property> </bean> </beans>==============================
2.TaskScheduler.java
package com.company.core.scheduler; import org.alfresco.repo.importer.ImporterJobSPI; import org.alfresco.service.ServiceRegistry; public class TaskScheduler implements ImporterJobSPI { ServiceRegistry serviceRegistry; public ServiceRegistry getServiceRegistry() { return serviceRegistry; } public void setServiceRegistry(ServiceRegistry serviceRegistry) { this.serviceRegistry = serviceRegistry; } public void doImport() { // Do your task here } }You need to place these two files in tomcat/shared/classes/alfresco/extension
This scheduler runs every 2 minutes.
good Ghanshyam... keep it up...
ReplyDelete