本文整理汇总了Java中org.springframework.batch.item.ItemStreamReader类的典型用法代码示例。如果您正苦于以下问题:Java ItemStreamReader类的具体用法?Java ItemStreamReader怎么用?Java ItemStreamReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemStreamReader类属于org.springframework.batch.item包,在下文中一共展示了ItemStreamReader类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createReader
import org.springframework.batch.item.ItemStreamReader; //导入依赖的package包/类
public ItemStreamReader<Ticket> createReader(final Resource source) {
final FlatFileItemReader<Ticket> reader = new FlatFileItemReader<>();
reader.setResource(source);
final DefaultLineMapper<Ticket> lineMapper = new DefaultLineMapper<>();
final DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
lineTokenizer.setNames(TICKET_FILE_CSV_FIELDS);
lineMapper.setLineTokenizer(lineTokenizer);
final BeanWrapperFieldSetMapper<Ticket> fieldMapper = new BeanWrapperFieldSetMapper<>();
fieldMapper.setTargetType(Ticket.class);
final DateFormat df = new SimpleDateFormat(DATE_FORMAT);
final Map<Class, PropertyEditor> customEditors = Stream.of(
new AbstractMap.SimpleEntry<>(Date.class, new CustomDateEditor(df, false)))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
fieldMapper.setCustomEditors(customEditors);
lineMapper.setFieldSetMapper(fieldMapper);
reader.setLineMapper(lineMapper);
return reader;
}
开发者ID:create1st,项目名称:spring-batch,代码行数:20,代码来源:TicketReaderFactory.java
示例2: testCreateReaderAndFailToRead
import org.springframework.batch.item.ItemStreamReader; //导入依赖的package包/类
@Test(expected = FlatFileParseException.class)
public void testCreateReaderAndFailToRead() throws Exception {
// given
final ExecutionContext executionContext = mock(ExecutionContext.class);
// when
final ItemStreamReader<Ticket> reader = factory.createReader(new ClassPathResource("tickets-fail.csv"));
try {
reader.open(executionContext);
System.out.println(reader.read());
} finally {
reader.close();
}
// then
}
开发者ID:create1st,项目名称:spring-batch,代码行数:18,代码来源:TicketReaderFactoryTest.java
示例3: testCreateReaderAndReadCorrectData
import org.springframework.batch.item.ItemStreamReader; //导入依赖的package包/类
@Test
public void testCreateReaderAndReadCorrectData() throws Exception {
// given
final ExecutionContext executionContext = mock(ExecutionContext.class);
final LocalDate date = LocalDate.of(2015, 12, 20);
// when
final ItemStreamReader<Ticket> reader = factory.createReader(new ClassPathResource("tickets.csv"));
final Ticket ticket;
try {
reader.open(executionContext);
ticket = reader.read();
} finally {
reader.close();
}
// then
assertThat(ticket, notNullValue());
assertThat(ticket.getTag(), equalTo("Ticket_0"));
assertThat(ticket.getDate(), equalTo(Date.valueOf(date)));
assertThat(ticket.getContent(), equalTo("Test ticket"));
}
开发者ID:create1st,项目名称:spring-batch,代码行数:24,代码来源:TicketReaderFactoryTest.java
示例4: ticketReader
import org.springframework.batch.item.ItemStreamReader; //导入依赖的package包/类
@Bean
@StepScope
public ItemStreamReader<Ticket> ticketReader(final TicketReaderFactory ticketReaderFactory,
final @Value("file:#{jobParameters['input.file.name']}") Resource resource) {
return new FilterItemReaderAdapter<>(ticketReaderFactory.createReader(resource), TicketPredicate.hasTodayDate());
}
开发者ID:create1st,项目名称:spring-batch,代码行数:7,代码来源:BatchConfiguration.java
示例5: FilterItemReaderAdapter
import org.springframework.batch.item.ItemStreamReader; //导入依赖的package包/类
/**
* @param reader the {@link ItemStreamReader} implementation to delegate to
* @param filterCondition Condition predicate.
*/
public FilterItemReaderAdapter(final ItemStreamReader<T> reader, final Predicate<T> filterCondition) {
this.reader = reader;
this.filterCondition = filterCondition;
}
开发者ID:create1st,项目名称:spring-batch,代码行数:9,代码来源:FilterItemReaderAdapter.java
示例6: productsReader
import org.springframework.batch.item.ItemStreamReader; //导入依赖的package包/类
private SynchronizedItemStreamReader<Product> productsReader(final BlockingSphereClient sphereClient) {
final ItemStreamReader<Product> productItemStreamReader = ItemReaderFactory.sortedByIdQueryReader(sphereClient, ProductQuery.of());
final SynchronizedItemStreamReader<Product> objectSynchronizedItemStreamReader = new SynchronizedItemStreamReader<>();
objectSynchronizedItemStreamReader.setDelegate(productItemStreamReader);
return objectSynchronizedItemStreamReader;
}
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:7,代码来源:SuggestKeywordsFromNameJobConfiguration.java
示例7: MetricsTestItemReader
import org.springframework.batch.item.ItemStreamReader; //导入依赖的package包/类
public MetricsTestItemReader(ItemStreamReader<Item> delegate,
BatchMetrics businessMetrics, boolean readerTransactional) {
this.delegate = delegate;
this.businessMetrics = businessMetrics;
this.readerTransactional = readerTransactional;
}
开发者ID:codecentric,项目名称:spring-boot-starter-batch-web,代码行数:7,代码来源:MetricsTestItemReader.java
示例8: setItemReaderList
import org.springframework.batch.item.ItemStreamReader; //导入依赖的package包/类
/**
* 설정파일에서 ItemReaderList에 등록한 값을 Setting
*
* @param itemReaderList
*/
public void setItemReaderList(List<ItemStreamReader<?>> itemReaderList) {
this.itemReaderList = itemReaderList;
}
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:9,代码来源:EgovCompositeFileReader.java
注:本文中的org.springframework.batch.item.ItemStreamReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论