List of usage examples for org.springframework.batch.core.step.factory SimpleStepFactoryBean setListeners
public void setListeners(StepListener[] listeners)
From source file:org.duracloud.snapshot.service.impl.RestoreJobBuilder.java
/** * @param restoration /*from w ww . ja v a 2 s .c om*/ * @param jobManagerConfig * @param reader * @param writer * @return * @throws Exception */ private Step buildRestoreContentStep(String restorationId, String destinationSpaceId, ContentStore contentStore, SnapshotJobManagerConfig jobManagerConfig) throws Exception { SyncEndpoint endpoint = new DuraStoreSyncEndpoint(contentStore, jobManagerConfig.getDuracloudUsername(), destinationSpaceId, false, false); File watchDir = new File(ContentDirUtils.getSourcePath(restorationId, jobManagerConfig.getContentRootDir()) + File.separator + "data"); if (!watchDir.exists()) { throw new RuntimeException("The content directory for the restored snapshot " + "does not exist in bridge storage: missing watchDir: " + watchDir.getAbsolutePath()); } FileSystemReader reader = new FileSystemReader(watchDir); SyncWriter writer = new SyncWriter(restorationId, watchDir, endpoint, contentStore, destinationSpaceId, restoreManager); SimpleStepFactoryBean<File, File> stepFactory = new SimpleStepFactoryBean<>(); stepFactory.setJobRepository(jobRepository); stepFactory.setTransactionManager(transactionManager); stepFactory.setBeanName("restoreContentStep"); stepFactory.setItemReader(reader); stepFactory.setItemWriter(writer); stepFactory.setCommitInterval(1); stepFactory.setThrottleLimit(20); stepFactory.setTaskExecutor(taskExecutor); stepFactory.setListeners(new StepListener[] { writer }); return stepFactory.getObject(); }
From source file:org.duracloud.snapshot.service.impl.RestoreJobBuilder.java
/** * @param jobManagerConfig /* w ww .java 2s. c om*/ * @param restoration * @return */ private Step buildRestoreContentPropertiesStep(String restorationId, String destinationSpaceId, ContentStore contentStore, SnapshotJobManagerConfig jobManagerConfig) throws Exception { File contentPropertiesJsonFile = new File( ContentDirUtils.getSourcePath(restorationId, jobManagerConfig.getContentRootDir()), SnapshotServiceConstants.CONTENT_PROPERTIES_JSON_FILENAME); if (!contentPropertiesJsonFile.exists()) { throw new RuntimeException("The restored content properties file is missing : " + contentPropertiesJsonFile.getAbsolutePath()); } ContentPropertiesFileReader reader = new ContentPropertiesFileReader(contentPropertiesJsonFile); ContentPropertiesWriter writer = new ContentPropertiesWriter(contentStore, destinationSpaceId); SimpleStepFactoryBean<ContentProperties, ContentProperties> stepFactory = new SimpleStepFactoryBean<ContentProperties, ContentProperties>(); stepFactory.setJobRepository(jobRepository); stepFactory.setTransactionManager(transactionManager); stepFactory.setBeanName("restoreContentPropertiesStep"); stepFactory.setItemReader(reader); stepFactory.setItemWriter(writer); stepFactory.setCommitInterval(1); stepFactory.setThrottleLimit(20); stepFactory.setTaskExecutor(taskExecutor); stepFactory.setListeners(new StepListener[] { writer }); return stepFactory.getObject(); }