1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.batch.service.impl;
17
18 import java.util.List;
19
20 import org.apache.log4j.Logger;
21 import org.kuali.ole.sys.batch.service.WrappedBatchExecutorService;
22 import org.kuali.ole.sys.batch.service.WrappingBatchService;
23 import org.springframework.transaction.annotation.Transactional;
24
25 public class WrappedBatchExecutorServiceImpl implements WrappedBatchExecutorService {
26 private static final Logger LOG = Logger.getLogger(WrappedBatchExecutorServiceImpl.class);
27
28 @Transactional
29 public boolean execute(List<WrappingBatchService> wrappingBatchServices, CustomBatchExecutor customBatchExecutor) {
30 boolean continueJob;
31 try {
32 for (WrappingBatchService wrappingBatchService : wrappingBatchServices) {
33 wrappingBatchService.initialize();
34 }
35 continueJob = customBatchExecutor.execute();
36 }
37 finally {
38 for (WrappingBatchService wrappingBatchService : wrappingBatchServices) {
39 try {
40 wrappingBatchService.destroy();
41 }
42 catch (Exception e) {
43 LOG.error("Caught exception while destroying service: " + wrappingBatchService.getClass(), e);
44 }
45 }
46 }
47 return continueJob;
48 }
49 }