Hello All,
I need to override the perform method in the ImportCockpitJob and write my own logic. Since the ImportCockpitJob class is not registered as a spring bean, I couldn't do the bean overriding. And hence, I created an item type which extends the item ImportCockpitJob and then defined a jalo class ImportCockpitJobSession. In this class I had to override the performCronJob method. But my job's code doesn't get executed! Any help highly appreciated. Thanks!!!!!
Itemtype definition:
itemtype code="ImportCockpitJobSession" autocreate="true" generate="true" jaloclass="de.valtech.henkel.cronjob.jalo.ImportCockpitJobSession" extends="ImportCockpitCronJob">
Overriding the method:
public class ImportCockpitJobSession extends ImportCockpitJob
{
public ImportCockpitJobSession()
{
//
}
public static final String INSTANCE_NAME = "ImportCockpit-ImportJob";
private static final Logger LOG = Logger.getLogger(ImportCockpitJob.class);
private final transient ModelService modelService = (ModelService) Registry.getApplicationContext().getBean("modelService");
private final transient ImportCockpitCronJobService importCockpitService = (ImportCockpitCronJobService) Registry
.getApplicationContext().getBean("importCockpitCronJobService");
@Override
public CronJob.CronJobResult performCronJob(final CronJob cronJob) throws AbortCronJobException
{
super.performCronJob(cronJob);
System.out.println("!!!!!!!!!!!!!Inside my class!!!!!!!!!!!!!");
final CronJob.CronJobResult result = null;
final ImportCockpitCronJobModel cronJobModel = (ImportCockpitCronJobModel) this.modelService.get(cronJob);
final String mySession = cronJobModel.getSessionUser().getUid();
System.out.println("!!!!!!!!!!!!!!!!!Inside my overriden class!!!!!!!!!!!!!" + mySession);
cronJobModel.setLastRun(mySession);
cronJobModel.setSessionUser(cronJobModel.getSessionUser());
return result;
}
}
I have also declared a bean for this class:
<bean id="ImportCockpitJobSession" class="de.valtech.henkel.cronjob.jalo.ImportCockpitJobSession" scope="prototype"/>