Code review cleanup
This commit is contained in:
@@ -16,7 +16,8 @@
|
||||
|
||||
package configuration;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.Step;
|
||||
@@ -68,17 +69,17 @@ public class JobConfiguration {
|
||||
|
||||
@Bean
|
||||
public Step step2() {
|
||||
return stepBuilderFactory.get("step2").chunk(3)
|
||||
return stepBuilderFactory.get("step2").<String, String>chunk(3)
|
||||
.reader(new ListItemReader<>(Arrays.asList("1", "2", "3", "4", "5", "6")))
|
||||
.processor(new ItemProcessor<Object, Object>() {
|
||||
.processor(new ItemProcessor<String, String>() {
|
||||
@Override
|
||||
public String process(Object item) throws Exception {
|
||||
public String process(String item) throws Exception {
|
||||
return String.valueOf(Integer.parseInt((String) item) * -1);
|
||||
}
|
||||
})
|
||||
.writer(new ItemWriter<Object>() {
|
||||
.writer(new ItemWriter<String>() {
|
||||
@Override
|
||||
public void write(List<? extends Object> items) throws Exception {
|
||||
public void write(List<? extends String> items) throws Exception {
|
||||
for (Object item : items) {
|
||||
System.out.println(">> " + item);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package configuration;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
@@ -27,7 +25,6 @@ import org.springframework.batch.core.configuration.annotation.StepBuilderFactor
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
import org.springframework.batch.item.ItemProcessor;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.task.configuration.EnableTask;
|
||||
|
||||
@@ -16,13 +16,9 @@
|
||||
|
||||
package configuration;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.NonTransientResourceException;
|
||||
import org.springframework.batch.item.ParseException;
|
||||
import org.springframework.batch.item.UnexpectedInputException;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
@@ -30,11 +26,9 @@ import org.springframework.batch.item.UnexpectedInputException;
|
||||
public class SkipItemWriter implements ItemWriter {
|
||||
|
||||
int failCount = 0;
|
||||
boolean finished = false;
|
||||
|
||||
@Override
|
||||
public void write(List items) throws Exception {
|
||||
String result = "1";
|
||||
if(failCount < 2) {
|
||||
failCount++;
|
||||
throw new IllegalStateException("Writer FOOBAR");
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
|
||||
package org.springframework.cloud.task.listener;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import configuration.JobConfiguration;
|
||||
import configuration.JobSkipConfiguration;
|
||||
|
||||
Reference in New Issue
Block a user