<bean id="customService" class="com.alfresco.ibrahim.services.impl.CustomServiceImpl">
<property name="customBeanDAO">
<ref bean="customBeanDAO" />
</property>
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="searchService">
<ref bean="searchService" />
</property>
</bean>
2. cron config bean
<bean id="customGenerator" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.alfresco.ibrahim.jobs.impl.customExecutorImpl"/>
<property name="jobDataAsMap">
<map>
<entry key="customService">
<ref bean="customService" />
</entry>
<entry key="transactionService">
<ref bean="transactionService" />
</entry>
</map>
</property>
</bean>
<bean id="regularUpdateTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="dailyReportGenerator"/>
<property name="cronExpression" value="30 * * * * ?"/>
</bean>
3. Job bean class
public class CustomExecutorImpl extends QuartzJobBean implements ReportExecutorJob{
private CustomService customService;
private TransactionService transactionService;
@Override
public void executeReportGeneration() {
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
customService.doSomeJob();
return null;
}
}, false, true);
return null;
}
},AuthenticationUtil.getAdminUserName());
}
No comments:
Post a Comment