Java 类org.springframework.batch.core.configuration.annotation.JobScope 实例源码

项目:marklogic-spring-batch    文件:ImportRdfFromFileJob.java   
@Bean
@JobScope
public Step step1(
        StepBuilderFactory stepBuilderFactory,
        DatabaseClientProvider databaseClientProvider,
        @Value("#{jobParameters['input_file_path']}") String inputFilePath,
        @Value("#{jobParameters['graph_name']}") String graphName) {
    RdfTripleItemReader<Map<String, Object>> reader = new RdfTripleItemReader<Map<String, Object>>();
    reader.setFileName(inputFilePath);

    RdfTripleItemWriter writer = new RdfTripleItemWriter(databaseClientProvider.getDatabaseClient(), graphName);

    return stepBuilderFactory.get("step1")
            .<Map<String, Object>, Map<String, Object>>chunk(10)
            .reader(reader)
            .writer(writer)
            .build();
}
项目:signature-processing    文件:BatchConfig.java   
/**
 * @return store for scan images
 */
@Bean
@JobScope
public Map<String, BufferedImage> scanStore() {
    return Collections.synchronizedMap(
            new HashMap<String, BufferedImage>());
}
项目:spring4-sandbox    文件:JobConfig.java   
@Bean
@JobScope 
public Step step1() {
    return stepBuilderFactory
            .get("step1")
            .<Conference, Conference> chunk(5)
            .reader(itemReader())
            .writer(itemWriter())
            .build();
}
项目:Spring-Batch-en-Castellano    文件:JobConfiguration.java   
@Bean
@JobScope
public ExampleItemReader itemReader() {
    return new ExampleItemReader();
}
项目:signature-processing    文件:BatchConfig.java   
/**
 * @return store for IDs of processed lists
 */
@Bean
@JobScope
public ArrayList<String> listIdsStore() {
    return new ArrayList<String>();
}
项目:marklogic-spring-batch    文件:YourTwoStepJobConfig.java   
@Bean
@JobScope
public Step step2(StepBuilderFactory stepBuilderFactory) {
    ItemReader<String> reader = new ItemReader<String>() {
        int i = 0;

        @Override
        public String read() throws Exception {
            i++;
            return i == 1 ? "hello" : null;
        }
    };


    ItemWriter<String> writer = new ItemWriter<String>() {
        String someString;

        @BeforeStep
        public void beforeStep(StepExecution stepExecution) {
            JobExecution jobExecution = stepExecution.getJobExecution();
            ExecutionContext jobContext = jobExecution.getExecutionContext();
            this.someString = jobContext.getString("someKey");
        }

        @Override
        public void write(List<? extends String> items) throws Exception {
            logger.info("Step 2: " + someString);
            for (String item : items) {
                logger.info("step2: " + item);
            }
        }

    };


    return stepBuilderFactory.get("step2")
            .<String, String>chunk(10)
            .reader(reader)
            .writer(writer)
            .listener(writer)
            .build();
}
项目:commercetools-sunrise-data    文件:DefaultCommercetoolsJobConfiguration.java   
@Bean(destroyMethod = "close")
@JobScope
protected BlockingSphereClient sphereClient(
        @Value("#{jobParameters['commercetools.projectKey']}") final String projectKey,
        @Value("#{jobParameters['commercetools.clientId']}") final String clientId,
        @Value("#{jobParameters['commercetools.clientSecret']}") final String clientSecret,
        @Value("#{jobParameters['commercetools.authUrl']}") final String authUrl,
        @Value("#{jobParameters['commercetools.apiUrl']}") final String apiUrl
) throws IOException {
    final SphereClientConfig config = SphereClientConfig.of(projectKey, clientId, clientSecret, authUrl, apiUrl);
    final SphereClient asyncClient = SphereClientFactory.of().createClient(config);
    return BlockingSphereClient.of(asyncClient, 20, TimeUnit.SECONDS);
}
项目:spring4-sandbox    文件:JobConfig.java   
@Bean
@JobScope
public  ConferenceItemReader itemReader() {
    return new ConferenceItemReader(dataSource);
}