当前位置: 首页>>代码示例>>Java>>正文


Java StepScope类代码示例

本文整理汇总了Java中org.springframework.batch.core.configuration.annotation.StepScope的典型用法代码示例。如果您正苦于以下问题:Java StepScope类的具体用法?Java StepScope怎么用?Java StepScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StepScope类属于org.springframework.batch.core.configuration.annotation包,在下文中一共展示了StepScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hdfsFileReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
ItemReader<Map<String, Object>> hdfsFileReader(HdfsResourceLoader resourceLoader, LineMapper<Map<String, Object>> lineMapper) throws IOException {
	MultiResourceItemReader<Map<String, Object>> multiReader = new MultiResourceItemReader<>();
	Resource[] resources = resourceLoader.getResources("/demo/influencers/*");
	multiReader.setResources(resources);	
	FlatFileItemReader<Map<String, Object>> itemReader = new FlatFileItemReader<>();
	itemReader.setLineMapper(lineMapper);
	multiReader.setDelegate(itemReader);
	return multiReader;
}
 
开发者ID:trisberg,项目名称:springone-2015,代码行数:12,代码来源:BatchHive2Configuration.java

示例2: innofactorReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
@Qualifier(STEP_NAME)
public FlatFileItemReader<InnofactorImportFileLine> innofactorReader(
        @Value("#{jobParameters['inputFile']}") String inputFile) {

    FlatFileItemReader<InnofactorImportFileLine> reader = new FlatFileItemReader<>();

    reader.setEncoding(StandardCharsets.UTF_8.name());
    reader.setLineMapper(innofactorImportLineMapper());
    reader.setStrict(true);
    reader.setResource(new FileSystemResource(inputFile));
    reader.setLinesToSkip(0);
    reader.setBufferedReaderFactory(bufferedReaderFactory);

    return reader;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:18,代码来源:InnofactorImportConfig.java

示例3: customerItemWriter

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
public JdbcBatchItemWriter<Customer> customerItemWriter() {
	JdbcBatchItemWriter<Customer> itemWriter = new JdbcBatchItemWriter<>();

	itemWriter.setDataSource(this.dataSource);
	itemWriter.setSql("INSERT INTO NEW_CUSTOMER VALUES (:id, :firstName, :lastName, :birthdate)");
	itemWriter.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider());
	itemWriter.afterPropertiesSet();

	return itemWriter;
}
 
开发者ID:mminella,项目名称:java-remote-partitioning,代码行数:13,代码来源:JobConfiguration.java

示例4: orderReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
protected OrderImportItemReader orderReader(@Value("#{jobParameters['resource']}") final Resource orderCsvResource) {

    FlatFileItemReader flatFileItemReader = new FlatFileItemReader<>();
    flatFileItemReader.setLineMapper(new DefaultLineMapper<OrderCsvLineValue>() {{
        setLineTokenizer(new DelimitedLineTokenizer() {{
            setNames(ORDER_CSV_HEADER_NAMES);

        }});
        setFieldSetMapper(new BeanWrapperFieldSetMapper<OrderCsvLineValue>() {{
            setTargetType(OrderCsvLineValue.class);
        }});
    }});
    flatFileItemReader.setLinesToSkip(1);
    flatFileItemReader.setResource(orderCsvResource);

    SingleItemPeekableItemReader singleItemPeekableItemReader = new SingleItemPeekableItemReader();
    singleItemPeekableItemReader.setDelegate(flatFileItemReader);

    OrderImportItemReader reader = new OrderImportItemReader();
    reader.setDelegate(singleItemPeekableItemReader);

    return reader;
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:26,代码来源:OrdersImportJobConfiguration.java

示例5: transcriptSignatureItemReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
/**
 * @return reader of signatures from transcript files in inbox directory
 */
@Bean
@StepScope
public MultiResourceItemReader<Signature> transcriptSignatureItemReader() {

    /* Get transcript resources */
    Resource[] resources = listIdsStore()
        .stream()
        . <Resource> map(listId ->
                new FileSystemResource(INBOX_DIR + listId + ".txt"))
        .toArray(size -> new Resource[size]);

    /* Create MultiResourceItemReader */
    MultiResourceItemReader<Signature> multiResourceReader =
            new MultiResourceItemReader<>();
    multiResourceReader.setResources(resources);
    multiResourceReader.setDelegate(trascriptSignatureReader());

    return multiResourceReader;
}
 
开发者ID:hosuaby,项目名称:signature-processing,代码行数:23,代码来源:BatchConfig.java

示例6: flatFileItemReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
FlatFileItemReader<Person> flatFileItemReader(@Value("#{jobParameters[file]}") File file) {
    FlatFileItemReader<Person> r = new FlatFileItemReader<>();
    r.setResource(new FileSystemResource(file));
    r.setLineMapper(new DefaultLineMapper<Person>() {
        {
            this.setLineTokenizer(new DelimitedLineTokenizer(",") {
                {
                    this.setNames(new String[]{"first", "last", "email"});
                }
            });
            this.setFieldSetMapper(new BeanWrapperFieldSetMapper<Person>() {
                {
                    this.setTargetType(Person.class);
                }
            });
        }
    });
    return r;
}
 
开发者ID:livelessons-spring,项目名称:building-microservices,代码行数:22,代码来源:BatchConfiguration.java

示例7: process

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean(name = "sendSystemMessageJobUserAnonymizedProcessor", destroyMethod = "")
@StepScope
private ItemProcessor<UUID, MessageDestination> userAnonymizedProcessor()
{
	return new ItemProcessor<UUID, MessageDestination>() {
		@Value("#{jobParameters['messageText']}")
		private String messageText;

		@Override
		public MessageDestination process(UUID userAnonymizedId) throws Exception
		{
			logger.debug("Processing user anonymized with id {}", userAnonymizedId);
			UserAnonymizedDto userAnonymized = userAnonymizedService.getUserAnonymized(userAnonymizedId);

			MessageDestination messageDestination = messageDestinationRepository
					.findOne(userAnonymized.getAnonymousDestination().getId());
			messageDestination.send(SystemMessage.createInstance(messageText));

			return messageDestination;
		}
	};
}
 
开发者ID:yonadev,项目名称:yona-server,代码行数:23,代码来源:SendSystemMessageBatchJob.java

示例8: itemReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
public ItemReader<String> itemReader() {
	final List<String> items = IntStream.range(0, 1000).mapToObj(String::valueOf).collect(toList());

	return new ListItemReader<String>(items);
}
 
开发者ID:phjardas,项目名称:spring-batch-tools,代码行数:8,代码来源:TestJobConfig.java

示例9: reader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
/**
 * maps CSV data into rows of fields, which are then
 * mapped to Customer.class instances based on conventions:
 * <p/>
 * <CODE>col 1 => firstName => customer.setFirstName(String)</CODE>
 */
@Bean(name = readCsvFileIntoTableStepReader)
@StepScope
public FlatFileItemReader<Customer> reader(@Value("#{jobParameters['input.file']}") Resource resource) throws Exception {

    log.debug(String.format("building FlatFileItemReader to read in the file %s", resource.getFile().getAbsolutePath()));

    FlatFileItemReader<Customer> csvFileReader = new FlatFileItemReader<Customer>();
    csvFileReader.setResource(resource);

    DelimitedLineTokenizer delimitedLineTokenizer = new DelimitedLineTokenizer(DelimitedLineTokenizer.DELIMITER_COMMA);
    delimitedLineTokenizer.setNames(new String[]{"lastName", "firstName"});

    BeanWrapperFieldSetMapper<Customer> beanWrapperFieldSetMapper = new BeanWrapperFieldSetMapper<Customer>();
    beanWrapperFieldSetMapper.setTargetType(Customer.class);

    DefaultLineMapper<Customer> defaultLineMapper = new DefaultLineMapper<Customer>();
    defaultLineMapper.setLineTokenizer(delimitedLineTokenizer);
    defaultLineMapper.setFieldSetMapper(beanWrapperFieldSetMapper);

    csvFileReader.setLineMapper(defaultLineMapper);
    return csvFileReader;
}
 
开发者ID:joshlong,项目名称:javaconfig-ftw,代码行数:29,代码来源:BatchConfiguration.java

示例10: productReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
public FlatFileItemReader<Product> productReader(@Value("#{jobParameters['inputFile']}") String inputFile) {

	DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer(",");
	tokenizer.setNames(new String[] { "PRODUCT_ID", "NAME", "DESCRIPTION", "PRICE" });

	DefaultLineMapper<Product> lineMapper = new DefaultLineMapper<Product>();
	lineMapper.setLineTokenizer(tokenizer);
	lineMapper.setFieldSetMapper(new ProductFieldSetMapper());

	FlatFileItemReader<Product> reader = new FlatFileItemReader<Product>();

	try {
		reader.setResource(new FileSystemResource(ResourceUtils.getFile(inputFile)));
	} catch (FileNotFoundException e) {
		log.error("파일을 찾을 수 없습니다. inputFile=" + inputFile, e);
		throw new RuntimeException(e);
	}
	reader.setLinesToSkip(1);
	reader.setLineMapper(lineMapper);

	return reader;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:25,代码来源:SkipConfiguration.java

示例11: lhClubImportReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
@Qualifier(IMPORT_STEP)
public FlatFileItemReader<LHHuntingClubCSVRow> lhClubImportReader(
        @Value("#{jobExecutionContext['inputFile']}") String inputFile) {
    final FlatFileItemReader<LHHuntingClubCSVRow> reader = new FlatFileItemReader<>();

    reader.setEncoding(StandardCharsets.ISO_8859_1.name());
    reader.setLineMapper(inputLineMapper());
    reader.setStrict(true);
    reader.setResource(new FileSystemResource(inputFile));
    reader.setLinesToSkip(1);

    return reader;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:16,代码来源:LHHuntingClubBatchConfig.java

示例12: innofactorWriter

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
@Qualifier(STEP_NAME)
public MetsastajaRekisteriPersonItemWriter innofactorWriter(
        @Value("#{jobParameters['importTimestamp']}") long importTimestamp) {
    return new MetsastajaRekisteriPersonItemWriter(importService, importTimestamp);
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:8,代码来源:InnofactorImportConfig.java

示例13: pagingItemReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
public JdbcPagingItemReader<Customer> pagingItemReader(
		@Value("#{stepExecutionContext['minValue']}")Long minValue,
		@Value("#{stepExecutionContext['maxValue']}")Long maxValue) {
	System.out.println("reading " + minValue + " to " + maxValue);
	JdbcPagingItemReader<Customer> reader = new JdbcPagingItemReader<>();

	reader.setDataSource(this.dataSource);
	reader.setFetchSize(1000);
	reader.setRowMapper(new CustomerRowMapper());

	MySqlPagingQueryProvider queryProvider = new MySqlPagingQueryProvider();
	queryProvider.setSelectClause("id, firstName, lastName, birthdate");
	queryProvider.setFromClause("from customer");
	queryProvider.setWhereClause("where id >= " + minValue + " and id <= " + maxValue);

	Map<String, Order> sortKeys = new HashMap<>(1);

	sortKeys.put("id", Order.ASCENDING);

	queryProvider.setSortKeys(sortKeys);

	reader.setQueryProvider(queryProvider);

	return reader;
}
 
开发者ID:mminella,项目名称:java-remote-partitioning,代码行数:28,代码来源:JobConfiguration.java

示例14: firstReader

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
public ItemReader<String> firstReader(@Value("#{jobParameters[message]}") String text) {
    log.info("+++ r-r-r  {} ", text);
  return new ListItemReader<>(Lists.newArrayList(text));
}
 
开发者ID:przodownikR1,项目名称:springBatchBootJavaConfigkata,代码行数:7,代码来源:JobConfig.java

示例15: processor

import org.springframework.batch.core.configuration.annotation.StepScope; //导入依赖的package包/类
@Bean
@StepScope
public ItemProcessor<Path, NamedBytes> processor(@Value("#{jobParameters[globalParams]}") String globalParams) {
    CompositeItemProcessor<Path, NamedBytes> processors = new CompositeItemProcessor<>();
    FileContentItemProcessor fileContentProcessor = new FileContentItemProcessor();
    GlobalParametersEnricherProcessor paramsEnricherProcessor = new GlobalParametersEnricherProcessor(globalParams);
    FileExtensionStripperProcessor fileExtensionStripperProcessor = new FileExtensionStripperProcessor();
    PlantUmlItemProcessor plantUmlProcessor = new PlantUmlItemProcessor(settings);
    processors.setDelegates(Arrays.asList(fileContentProcessor, paramsEnricherProcessor, fileExtensionStripperProcessor,
        plantUmlProcessor));
    return processors;
}
 
开发者ID:nfrankel,项目名称:jplantuml,代码行数:13,代码来源:PlantUmlConfig.java


注:本文中的org.springframework.batch.core.configuration.annotation.StepScope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。