當前位置: 首頁>>代碼示例>>Java>>正文


Java Step類代碼示例

本文整理匯總了Java中org.springframework.batch.core.Step的典型用法代碼示例。如果您正苦於以下問題:Java Step類的具體用法?Java Step怎麽用?Java Step使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Step類屬於org.springframework.batch.core包,在下文中一共展示了Step類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: personEtl

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Bean
Job personEtl(JobBuilderFactory jobBuilderFactory,
        StepBuilderFactory stepBuilderFactory,
        FlatFileItemReader<Person> reader,
        JdbcBatchItemWriter<Person> writer
) {

    Step step = stepBuilderFactory.get("file-to-database")
            .<Person, Person>chunk(5)
            .reader(reader)
            .writer(writer)
            .build();

    return jobBuilderFactory.get("etl")
            .start(step)
            .build();
}
 
開發者ID:livelessons-spring,項目名稱:building-microservices,代碼行數:18,代碼來源:BatchConfiguration.java

示例2: importTicketStep

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Bean
public Step importTicketStep(final StepBuilderFactory stepBuilderFactory,
                             @Qualifier("jpaTransactionManagerForBatch")
                             final PlatformTransactionManager jpaTransactionManager,
                             final @Value("${ticket.chunk.size}") int chunkSize,
                             final ItemReader<Ticket> ticketReader,
                             final ItemWriter<Ticket> ticketWriter,
                             final ItemProcessor<Ticket, Ticket> importTicketProcessor) {
    return stepBuilderFactory.get("importTicketStep")
            .<Ticket, Ticket>chunk(chunkSize)
            .reader(ticketReader)
            .processor(importTicketProcessor)
            .writer(ticketWriter)
            .transactionManager(jpaTransactionManager)
            .build();
}
 
開發者ID:create1st,項目名稱:spring-batch,代碼行數:17,代碼來源:BatchConfiguration.java

示例3: chunkStep

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Bean
public Step chunkStep() {
    return stepCreators.get("chunkStep")
        .<Department, Department>chunk(5)
        .reader(reader())
        .processor(processor())
        .writer(writer())
        .build();
}
 
開發者ID:PacktPublishing,項目名稱:Spring-5.0-Cookbook,代碼行數:10,代碼來源:BatchConfig.java

示例4: handleTransition

import org.springframework.batch.core.Step; //導入依賴的package包/類
private void handleTransition(Deque<Flow> executionDeque,
		TaskAppNode taskAppNode) {
	String beanName = getBeanName(taskAppNode);
	Step currentStep = this.context.getBean(beanName, Step.class);
	FlowBuilder<Flow> builder = new FlowBuilder<Flow>(beanName)
			.from(currentStep);

	boolean wildCardPresent = false;

	for (TransitionNode transitionNode : taskAppNode.getTransitions()) {
		String transitionBeanName = getBeanName(transitionNode);

		wildCardPresent = transitionNode.getStatusToCheck().equals(WILD_CARD);

		Step transitionStep = this.context.getBean(transitionBeanName,
				Step.class);
		builder.on(transitionNode.getStatusToCheck()).to(transitionStep)
				.from(currentStep);
	}

	if (wildCardPresent && !executionDeque.isEmpty()) {
		throw new IllegalStateException(
				"Invalid flow following '*' specifier.");
	}
	else {
		//if there are nodes are in the execution Deque.  Make sure that
		//they are processed as a target of the wildcard instead of the
		//whole transition.
		if (!executionDeque.isEmpty()) {
			Deque<Flow> resultDeque = new LinkedList<>();
			handleFlowForSegment(executionDeque, resultDeque);
			builder.on(WILD_CARD).to(resultDeque.pop()).from(currentStep);
		}
	}

	executionDeque.push(builder.end());
}
 
開發者ID:spring-cloud-task-app-starters,項目名稱:composed-task-runner,代碼行數:38,代碼來源:ComposedRunnerJobFactory.java

示例5: getObject

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Override
public Step getObject() throws Exception {
	TaskLauncherTasklet taskLauncherTasklet = new TaskLauncherTasklet(
			this.taskOperations, taskConfigurer.getTaskExplorer(),
			this.composedTaskProperties, this.taskName);

	taskLauncherTasklet.setArguments(this.arguments);
	taskLauncherTasklet.setProperties(this.taskSpecificProps);

	String stepName = this.taskName;

	return this.steps.get(stepName)
			.tasklet(taskLauncherTasklet)
			.transactionAttribute(getTransactionAttribute())
			.listener(this.composedTaskStepExecutionListener)
			.build();
}
 
開發者ID:spring-cloud-task-app-starters,項目名稱:composed-task-runner,代碼行數:18,代碼來源:ComposedTaskRunnerStepFactory.java

示例6: step1

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Bean
public Step step1() {
    return stepBuilderFactory.get("step1")
            .tasklet(new Tasklet() {
                @Override
                public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
                    
                    // get path of file in src/main/resources
                    Path xmlDocPath =  Paths.get(getFilePath());
                    
                    // process the file to json
                     String json = processXML2JSON(xmlDocPath);
                     
                     // insert json into mongodb
                     insertToMongo(json);
                    return RepeatStatus.FINISHED;
                }
            }).build();
}
 
開發者ID:michaelcgood,項目名稱:XML-JSON-MongoDB-Spring-Batch-Example,代碼行數:20,代碼來源:JobConfiguration.java

示例7: discreteJob

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Bean
public Job discreteJob() {
	AbstractJob job = new AbstractJob("discreteRegisteredJob") {

		@Override
		public Collection<String> getStepNames() {
			return Collections.emptySet();
		}

		@Override
		public Step getStep(String stepName) {
			return null;
		}

		@Override
		protected void doExecute(JobExecution execution)
				throws JobExecutionException {
			execution.setStatus(BatchStatus.COMPLETED);
		}
	};
	job.setJobRepository(this.jobRepository);
	return job;
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:24,代碼來源:BatchAutoConfigurationTests.java

示例8: step1

import org.springframework.batch.core.Step; //導入依賴的package包/類
@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();
}
 
開發者ID:marklogic-community,項目名稱:marklogic-spring-batch,代碼行數:19,代碼來源:ImportRdfFromFileJob.java

示例9: createInventoryEntryStep

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Bean
public Step createInventoryEntryStep(final BlockingSphereClient sphereClient,
                                     final ItemReader<ProductProjection> inventoryEntryReader,
                                     final ItemProcessor<ProductProjection, List<InventoryEntryDraft>> inventoryEntryProcessor,
                                     final ItemWriter<List<InventoryEntryDraft>> inventoryEntryWriter) {
    final StepBuilder stepBuilder = stepBuilderFactory.get("createInventoryEntryStep");
    return stepBuilder
            .<ProductProjection, List<InventoryEntryDraft>>chunk(1)
            .reader(inventoryEntryReader)
            .processor(inventoryEntryProcessor)
            .writer(inventoryEntryWriter)
            .faultTolerant()
            .skip(ErrorResponseException.class)
            .skipLimit(1)
            .build();
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-data,代碼行數:17,代碼來源:InventoryEntryCreationJobConfiguration.java

示例10: deleteProductsStep

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Bean
protected Step deleteProductsStep(final BlockingSphereClient sphereClient,
                                  final ItemWriter<Versioned<Product>> productDeleteWriter) {
    return stepBuilderFactory.get("deleteProductsStep")
            .<Product, Product>chunk(50)
            .reader(ItemReaderFactory.sortedByIdQueryReader(sphereClient, ProductQuery.of()))
            .writer(productDeleteWriter)
            .build();
}
 
開發者ID:commercetools,項目名稱:commercetools-sunrise-data,代碼行數:10,代碼來源:ProductDeleteJobConfiguration.java

示例11: testMissingStepExecution

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Test
public void testMissingStepExecution() throws Exception {
	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("foo");
	when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"foo", "bar", "baz"});
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");

	try {
		this.handler.run();
	}
	catch (NoSuchStepException nsse) {
		assertEquals("No StepExecution could be located for step execution id 2 within job execution 1", nsse.getMessage());
	}
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-task,代碼行數:18,代碼來源:DeployerStepExecutionHandlerTests.java

示例12: testRunSuccessful

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Test
public void testRunSuccessful() throws Exception {
	StepExecution workerStep = new StepExecution("workerStep", new JobExecution(1L), 2L);

	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
	when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"workerStep", "foo", "bar"});
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
	when(this.jobExplorer.getStepExecution(1L, 2L)).thenReturn(workerStep);
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
	when(this.beanFactory.getBean("workerStep", Step.class)).thenReturn(this.step);

	handler.run();

	verify(this.step).execute(workerStep);
	verifyZeroInteractions(this.jobRepository);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-task,代碼行數:21,代碼來源:DeployerStepExecutionHandlerTests.java

示例13: testJobInterruptedException

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Test
public void testJobInterruptedException() throws Exception {
	StepExecution workerStep = new StepExecution("workerStep", new JobExecution(1L), 2L);

	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
	when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"workerStep", "foo", "bar"});
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
	when(this.jobExplorer.getStepExecution(1L, 2L)).thenReturn(workerStep);
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
	when(this.beanFactory.getBean("workerStep", Step.class)).thenReturn(this.step);
	doThrow(new JobInterruptedException("expected")).when(this.step).execute(workerStep);

	handler.run();

	verify(this.jobRepository).update(this.stepExecutionArgumentCaptor.capture());

	assertEquals(BatchStatus.STOPPED, this.stepExecutionArgumentCaptor.getValue().getStatus());
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-task,代碼行數:23,代碼來源:DeployerStepExecutionHandlerTests.java

示例14: testRuntimeException

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Test
public void testRuntimeException() throws Exception {
	StepExecution workerStep = new StepExecution("workerStep", new JobExecution(1L), 2L);

	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
	when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
	when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"workerStep", "foo", "bar"});
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
	when(this.jobExplorer.getStepExecution(1L, 2L)).thenReturn(workerStep);
	when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
	when(this.beanFactory.getBean("workerStep", Step.class)).thenReturn(this.step);
	doThrow(new RuntimeException("expected")).when(this.step).execute(workerStep);

	handler.run();

	verify(this.jobRepository).update(this.stepExecutionArgumentCaptor.capture());

	assertEquals(BatchStatus.FAILED, this.stepExecutionArgumentCaptor.getValue().getStatus());
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-task,代碼行數:23,代碼來源:DeployerStepExecutionHandlerTests.java

示例15: chunkStep

import org.springframework.batch.core.Step; //導入依賴的package包/類
@Bean
public Step chunkStep() {
	final int chunkSize = 100;

	final ItemProcessor<String, String> processor = (item) -> {
		Thread.sleep(100);
		return item;
	};

	final ItemWriter<String> writer = (items) -> {
		Thread.sleep(1000);
	};

	return steps.get("Chunk Step") //
			.<String, String> chunk(chunkSize) //
			.reader(itemReader()) //
			.processor(processor) //
			.writer(writer) //
			.build();
}
 
開發者ID:phjardas,項目名稱:spring-batch-tools,代碼行數:21,代碼來源:TestJobConfig.java


注:本文中的org.springframework.batch.core.Step類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。