org.springframework.batch.core.explore.JobExplorer Java Examples

The following examples show how to use org.springframework.batch.core.explore.JobExplorer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobDependencies.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Bean
public SimpleJobServiceFactoryBean simpleJobServiceFactoryBean(DataSource dataSource,
		JobRepositoryFactoryBean repositoryFactoryBean, JobExplorer jobExplorer,
		PlatformTransactionManager dataSourceTransactionManager) {
	SimpleJobServiceFactoryBean factoryBean = new SimpleJobServiceFactoryBean();
	factoryBean.setDataSource(dataSource);
	try {
		factoryBean.setJobRepository(repositoryFactoryBean.getObject());
		factoryBean.setJobLauncher(new SimpleJobLauncher());
		factoryBean.setJobExplorer(jobExplorer);
		factoryBean.setTransactionManager(dataSourceTransactionManager);
	}
	catch (Exception e) {
		throw new IllegalStateException(e);
	}
	return factoryBean;
}
 
Example #2
Source File: TaskJobLauncherCommandLineRunnerFactoryBean.java    From spring-cloud-task with Apache License 2.0 6 votes vote down vote up
public TaskJobLauncherCommandLineRunnerFactoryBean(JobLauncher jobLauncher,
		JobExplorer jobExplorer, List<Job> jobs,
		TaskBatchProperties taskBatchProperties, JobRegistry jobRegistry,
		JobRepository jobRepository, BatchProperties batchProperties) {
	Assert.notNull(taskBatchProperties, "taskBatchProperties must not be null");
	Assert.notNull(batchProperties, "batchProperties must not be null");
	this.jobLauncher = jobLauncher;
	this.jobExplorer = jobExplorer;
	Assert.notEmpty(jobs, "jobs must not be null nor empty");
	this.jobs = jobs;
	this.jobNames = taskBatchProperties.getJobNames();
	this.jobRegistry = jobRegistry;
	this.taskBatchProperties = taskBatchProperties;
	if (StringUtils.hasText(batchProperties.getJob().getNames())) {
		this.jobNames = batchProperties.getJob().getNames();
	}
	else {
		this.jobNames = taskBatchProperties.getJobNames();
	}
	this.order = taskBatchProperties.getCommandLineRunnerOrder();
	this.jobRepository = jobRepository;
}
 
Example #3
Source File: FlatFileItemReaderAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomMapping() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(CustomMappingConfiguration.class)
			.withConfiguration(AutoConfigurations.of(
					PropertyPlaceholderAutoConfiguration.class,
					BatchAutoConfiguration.class,
					SingleStepJobAutoConfiguration.class,
					FlatFileItemReaderAutoConfiguration.class, RangeConverter.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1", "spring.batch.job.chunkSize=5",
					"spring.batch.job.flatfilereader.name=fixedWidthConfiguration",
					"spring.batch.job.flatfilereader.resource=/test.txt",
					"spring.batch.job.flatfilereader.maxItemCount=1",
					"spring.batch.job.flatfilereader.strict=true");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		ListItemWriter itemWriter = context.getBean(ListItemWriter.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		List<Map<Object, Object>> writtenItems = itemWriter.getWrittenItems();

		assertThat(writtenItems.size()).isEqualTo(1);
		assertThat(writtenItems.get(0).get("one")).isEqualTo("1 2 3");
		assertThat(writtenItems.get(0).get("two")).isEqualTo("4 5 six");
	});
}
 
Example #4
Source File: DeployerPartitionHandlerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void validateConstructorValidation(TaskLauncher taskLauncher,
		JobExplorer jobExplorer, Resource resource, String stepName,
		TaskRepository taskRepository, String expectedMessage) {
	try {
		new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, stepName,
				taskRepository);
	}
	catch (IllegalArgumentException iae) {
		assertThat(iae.getMessage()).isEqualTo(expectedMessage);
	}
}
 
Example #5
Source File: DeployerPartitionHandlerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void validateDeprecatedConstructorValidation(TaskLauncher taskLauncher,
		JobExplorer jobExplorer, Resource resource, String stepName,
		String expectedMessage) {
	try {
		new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, stepName,
				this.taskRepository);
	}
	catch (IllegalArgumentException iae) {
		assertThat(iae.getMessage()).isEqualTo(expectedMessage);
	}
}
 
Example #6
Source File: TaskJobLauncherCommandLineRunnerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoTaskJobLauncher() {
	String[] enabledArgs = new String[] {
			"--spring.cloud.task.batch.failOnJobFailure=true",
			"--spring.cloud.task.batch.failOnJobFailurePollInterval=500",
			"--spring.batch.job.enabled=false" };
	this.applicationContext = SpringApplication.run(new Class[] {
			TaskJobLauncherCommandLineRunnerTests.JobWithFailureConfiguration.class },
			enabledArgs);
	JobExplorer jobExplorer = this.applicationContext.getBean(JobExplorer.class);
	assertThat(jobExplorer.getJobNames().size()).isEqualTo(0);
}
 
Example #7
Source File: SingleStepJobAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testSimpleConfiguration() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(SimpleConfiguration.class)
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							BatchAutoConfiguration.class,
							SingleStepJobAutoConfiguration.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1",
					"spring.batch.job.chunkSize=5");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		ListItemWriter itemWriter = context.getBean(ListItemWriter.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		List<Map<Object, Object>> writtenItems = itemWriter.getWrittenItems();

		assertThat(writtenItems.size()).isEqualTo(3);

		assertThat(writtenItems.get(0).get("item")).isEqualTo("foo");
		assertThat(writtenItems.get(1).get("item")).isEqualTo("bar");
		assertThat(writtenItems.get(2).get("item")).isEqualTo("baz");
	});
}
 
Example #8
Source File: TaskJobLauncherAutoConfiguration.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Bean
public TaskJobLauncherCommandLineRunnerFactoryBean jobLauncherCommandLineRunner(
		JobLauncher jobLauncher, JobExplorer jobExplorer, List<Job> jobs,
		JobRegistry jobRegistry, JobRepository jobRepository,
		BatchProperties batchProperties) {
	TaskJobLauncherCommandLineRunnerFactoryBean taskJobLauncherCommandLineRunnerFactoryBean;
	taskJobLauncherCommandLineRunnerFactoryBean = new TaskJobLauncherCommandLineRunnerFactoryBean(
			jobLauncher, jobExplorer, jobs, this.properties, jobRegistry,
			jobRepository, batchProperties);

	return taskJobLauncherCommandLineRunnerFactoryBean;
}
 
Example #9
Source File: FlatFileItemReaderAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomLineMapper() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(CustomLineMapperConfiguration.class)
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							BatchAutoConfiguration.class,
							SingleStepJobAutoConfiguration.class,
							FlatFileItemReaderAutoConfiguration.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1", "spring.batch.job.chunkSize=5",
					"spring.batch.job.flatfilereader.name=fixedWidthConfiguration",
					"spring.batch.job.flatfilereader.resource=/test.txt",
					"spring.batch.job.flatfilereader.strict=true");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		ListItemWriter itemWriter = context.getBean(ListItemWriter.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		List writtenItems = itemWriter.getWrittenItems();

		assertThat(writtenItems.size()).isEqualTo(8);
	});
}
 
Example #10
Source File: BatchConfiguration.java    From spring-graalvm-native with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(JobOperator.class)
public JobOperator jobOperator(ObjectProvider<JobParametersConverter> jobParametersConverter,
		JobExplorer jobExplorer, JobLauncher jobLauncher, ListableJobLocator jobRegistry,
		JobRepository jobRepository) throws Exception {
	System.out.println("FOOBAR");
	SimpleJobOperator factory = new SimpleJobOperator();
	factory.setJobExplorer(jobExplorer);
	factory.setJobLauncher(jobLauncher);
	factory.setJobRegistry(jobRegistry);
	factory.setJobRepository(jobRepository);
	jobParametersConverter.ifAvailable(factory::setJobParametersConverter);
	return factory;
}
 
Example #11
Source File: DefaultJobService.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
public DefaultJobService(final JobOperator jobOperator,
                         final JobRegistry jobRegistry,
                         final JobExplorer jobExplorer,
                         final LightminJobExecutionDao lightminJobExecutionDao) {
    this.jobOperator = jobOperator;
    this.jobRegistry = jobRegistry;
    this.jobExplorer = jobExplorer;
    this.lightminJobExecutionDao = lightminJobExecutionDao;
}
 
Example #12
Source File: DeployerStepExecutionHandler.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
public DeployerStepExecutionHandler(BeanFactory beanFactory, JobExplorer jobExplorer,
		JobRepository jobRepository) {
	Assert.notNull(beanFactory, "A beanFactory is required");
	Assert.notNull(jobExplorer, "A jobExplorer is required");
	Assert.notNull(jobRepository, "A jobRepository is required");

	this.stepLocator = new BeanFactoryStepLocator();
	((BeanFactoryStepLocator) this.stepLocator).setBeanFactory(beanFactory);

	this.jobExplorer = jobExplorer;
	this.jobRepository = jobRepository;
}
 
Example #13
Source File: DeployerPartitionHandler.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
public DeployerPartitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer,
		Resource resource, String stepName, TaskRepository taskRepository) {
	Assert.notNull(taskLauncher, "A taskLauncher is required");
	Assert.notNull(jobExplorer, "A jobExplorer is required");
	Assert.notNull(resource, "A resource is required");
	Assert.hasText(stepName, "A step name is required");
	Assert.notNull(taskRepository, "A TaskRepository is required");

	this.taskLauncher = taskLauncher;
	this.jobExplorer = jobExplorer;
	this.resource = resource;
	this.stepName = stepName;
	this.taskRepository = taskRepository;
}
 
Example #14
Source File: FlatFileItemWriterAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testFormattedFieldExtractorFileGeneration() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(FormattedFieldExtractorJobConfiguration.class)
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							BatchAutoConfiguration.class,
							SingleStepJobAutoConfiguration.class,
							FlatFileItemWriterAutoConfiguration.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1", "spring.batch.job.chunkSize=5",
					"spring.batch.job.flatfilewriter.name=fooWriter",
					String.format(
							"spring.batch.job.flatfilewriter.resource=file://%s",
							this.outputFile.getAbsolutePath()),
					"spring.batch.job.flatfilewriter.encoding=UTF-8",
					"spring.batch.job.flatfilewriter.formatted=true",
					"spring.batch.job.flatfilewriter.names=item",
					"spring.batch.job.flatfilewriter.format=item = %s");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		AssertFile.assertLineCount(3, this.outputFile);

		String results = FileCopyUtils.copyToString(new InputStreamReader(
				new FileSystemResource(this.outputFile).getInputStream()));
		assertThat(results).isEqualTo("item = f\nitem = b\nitem = b\n");
	});
}
 
Example #15
Source File: FlatFileItemWriterAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testFieldExtractorFileGeneration() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(FieldExtractorConfiguration.class)
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							BatchAutoConfiguration.class,
							SingleStepJobAutoConfiguration.class,
							FlatFileItemWriterAutoConfiguration.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1", "spring.batch.job.chunkSize=5",
					"spring.batch.job.flatfilewriter.name=fooWriter",
					String.format(
							"spring.batch.job.flatfilewriter.resource=file://%s",
							this.outputFile.getAbsolutePath()),
					"spring.batch.job.flatfilewriter.encoding=UTF-8",
					"spring.batch.job.flatfilewriter.delimited=true");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		AssertFile.assertLineCount(3, this.outputFile);

		String results = FileCopyUtils.copyToString(new InputStreamReader(
				new FileSystemResource(this.outputFile).getInputStream()));
		assertThat(results).isEqualTo("f\nb\nb\n");
	});
}
 
Example #16
Source File: FlatFileItemWriterAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testCustomLineAggregatorFileGeneration() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(LineAggregatorConfiguration.class)
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							BatchAutoConfiguration.class,
							SingleStepJobAutoConfiguration.class,
							FlatFileItemWriterAutoConfiguration.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1", "spring.batch.job.chunkSize=5",
					"spring.batch.job.flatfilewriter.name=fooWriter",
					String.format(
							"spring.batch.job.flatfilewriter.resource=file://%s",
							this.outputFile.getAbsolutePath()),
					"spring.batch.job.flatfilewriter.encoding=UTF-8");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		AssertFile.assertLineCount(3, this.outputFile);

		String results = FileCopyUtils.copyToString(new InputStreamReader(
				new FileSystemResource(this.outputFile).getInputStream()));
		assertThat(results).isEqualTo("{item=foo}\n{item=bar}\n{item=baz}\n");
	});
}
 
Example #17
Source File: FlatFileItemWriterAutoConfigurationTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testHeaderFooterFileGeneration() {
	ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
			.withUserConfiguration(HeaderFooterConfiguration.class)
			.withConfiguration(
					AutoConfigurations.of(PropertyPlaceholderAutoConfiguration.class,
							BatchAutoConfiguration.class,
							SingleStepJobAutoConfiguration.class,
							FlatFileItemWriterAutoConfiguration.class))
			.withPropertyValues("spring.batch.job.jobName=job",
					"spring.batch.job.stepName=step1", "spring.batch.job.chunkSize=5",
					"spring.batch.job.flatfilewriter.name=fooWriter",
					String.format(
							"spring.batch.job.flatfilewriter.resource=file://%s",
							this.outputFile.getAbsolutePath()),
					"spring.batch.job.flatfilewriter.encoding=UTF-8",
					"spring.batch.job.flatfilewriter.delimited=true",
					"spring.batch.job.flatfilewriter.names=item");

	applicationContextRunner.run((context) -> {
		JobLauncher jobLauncher = context.getBean(JobLauncher.class);

		Job job = context.getBean(Job.class);

		JobExecution jobExecution = jobLauncher.run(job, new JobParameters());

		JobExplorer jobExplorer = context.getBean(JobExplorer.class);

		while (jobExplorer.getJobExecution(jobExecution.getJobId()).isRunning()) {
			Thread.sleep(1000);
		}

		AssertFile.assertLineCount(5, this.outputFile);

		String results = FileCopyUtils.copyToString(new InputStreamReader(
				new FileSystemResource(this.outputFile).getInputStream()));
		assertThat(results).isEqualTo("header\nfoo\nbar\nbaz\nfooter");
	});
}
 
Example #18
Source File: DeployerPartitionHandler.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor initializing the DeployerPartitionHandler instance.
 * @param taskLauncher the launcher used to execute partitioned tasks.
 * @param jobExplorer used to acquire the status of the job.
 * @param resource the url to the app to be launched.
 * @param stepName the name of the step.
 * @deprecated Use the constructor that accepts {@link TaskRepository} as well as the
 * this constructor's set of parameters.
 */
@Deprecated
public DeployerPartitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer,
		Resource resource, String stepName) {
	Assert.notNull(taskLauncher, "A taskLauncher is required");
	Assert.notNull(jobExplorer, "A jobExplorer is required");
	Assert.notNull(resource, "A resource is required");
	Assert.hasText(stepName, "A step name is required");

	this.taskLauncher = taskLauncher;
	this.jobExplorer = jobExplorer;
	this.resource = resource;
	this.stepName = stepName;
}
 
Example #19
Source File: TaskJobLauncherCommandLineRunner.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new {@link TaskJobLauncherCommandLineRunner}.
 * @param jobLauncher to launch jobs
 * @param jobExplorer to check the job repository for previous executions
 * @param jobRepository to check if a job instance exists with the given parameters
 * when running a job
 * @param taskBatchProperties the properties used to configure the
 * taskBatchProperties.
 */
public TaskJobLauncherCommandLineRunner(JobLauncher jobLauncher,
		JobExplorer jobExplorer, JobRepository jobRepository,
		TaskBatchProperties taskBatchProperties) {
	super(jobLauncher, jobExplorer, jobRepository);
	this.taskJobLauncher = jobLauncher;
	this.taskJobExplorer = jobExplorer;
	this.taskJobRepository = jobRepository;
	this.taskBatchProperties = taskBatchProperties;
}
 
Example #20
Source File: TaskConfiguration.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleJobServiceFactoryBean simpleJobServiceFactoryBean(DataSource dataSource,
		JobRepositoryFactoryBean repositoryFactoryBean, JobExplorer jobExplorer,
		PlatformTransactionManager dataSourceTransactionManager) throws Exception {
	SimpleJobServiceFactoryBean factoryBean = new SimpleJobServiceFactoryBean();
	factoryBean.setDataSource(dataSource);
	factoryBean.setJobRepository(repositoryFactoryBean.getObject());
	factoryBean.setJobLauncher(new SimpleJobLauncher());
	factoryBean.setDataSource(dataSource);
	factoryBean.setJobExplorer(jobExplorer);
	factoryBean.setTransactionManager(dataSourceTransactionManager);
	return factoryBean;
}
 
Example #21
Source File: Fixtures.java    From spring-batch-rest with Apache License 2.0 5 votes vote down vote up
public static void configureForJobExecutionsService(JobExplorer jobExplorer) {
    when(jobExplorer.getJobInstances(eq(JOB_NAME_1), anyInt(), anyInt())).thenReturn(newArrayList(ji11, ji12));
    when(jobExplorer.getJobInstances(eq(JOB_NAME_2), anyInt(), anyInt())).thenReturn(newArrayList(ji21, ji22, ji23));

    when(jobExplorer.getJobExecutions(ji11)).thenReturn(newArrayList(je11));
    when(jobExplorer.getJobExecutions(ji12)).thenReturn(newArrayList(je12));

    when(jobExplorer.getJobExecutions(ji21)).thenReturn(newArrayList(je21));
    when(jobExplorer.getJobExecutions(ji22)).thenReturn(newArrayList(je22));
    when(jobExplorer.getJobExecutions(ji23)).thenReturn(newArrayList(je23, je24));
}
 
Example #22
Source File: ComposedRunnerVisitorTests.java    From composed-task-runner with Apache License 2.0 5 votes vote down vote up
private Collection<StepExecution> getStepExecutions() {
	JobExplorer jobExplorer = this.applicationContext.getBean(JobExplorer.class);
	List<JobInstance> jobInstances = jobExplorer.findJobInstancesByJobName("job", 0, 1);
	assertEquals(1, jobInstances.size());
	JobInstance jobInstance = jobInstances.get(0);
	List<JobExecution> jobExecutions = jobExplorer.getJobExecutions(jobInstance);
	assertEquals(1, jobExecutions.size());
	JobExecution jobExecution = jobExecutions.get(0);
	return jobExecution.getStepExecutions();
}
 
Example #23
Source File: CustomJsrJobOperator.java    From spring-boot-starter-batch-web with Apache License 2.0 5 votes vote down vote up
public CustomJsrJobOperator(JobExplorer jobExplorer, JobRepository jobRepository,
		JobParametersConverter jobParametersConverter, AddListenerToJobService addListenerToJobService,
		PlatformTransactionManager transactionManager) {
	super(jobExplorer, jobRepository, jobParametersConverter, transactionManager);
	this.jobRepository = jobRepository;
	this.jobParametersConverter = jobParametersConverter;
	this.addListenerToJobService = addListenerToJobService;
}
 
Example #24
Source File: JobOperationsController.java    From spring-boot-starter-batch-web with Apache License 2.0 5 votes vote down vote up
public JobOperationsController(JobOperator jobOperator, JobExplorer jobExplorer, JobRegistry jobRegistry,
		JobRepository jobRepository, JobLauncher jobLauncher, JsrJobOperator jsrJobOperator) {
	super();
	this.jobOperator = jobOperator;
	this.jobExplorer = jobExplorer;
	this.jobRegistry = jobRegistry;
	this.jobRepository = jobRepository;
	this.jobLauncher = jobLauncher;
	this.jsrJobOperator = jsrJobOperator;
}
 
Example #25
Source File: BatchConfiguration.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Bean
BatchConfigurer myBatchConfigurer(DataSource dataSource,
		Jackson2ExecutionContextStringSerializer myJackson2ExecutionContextStringSerializer,
		PlatformTransactionManager transactionManager) {
	return new DefaultBatchConfigurer(dataSource) {
		@Override
		protected JobExplorer createJobExplorer() throws Exception {
			JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
			jobExplorerFactoryBean.setDataSource(dataSource);
			jobExplorerFactoryBean
					.setSerializer(myJackson2ExecutionContextStringSerializer);
			jobExplorerFactoryBean.afterPropertiesSet();
			return jobExplorerFactoryBean.getObject();
		}

		@Override
		protected JobRepository createJobRepository() throws Exception {
			JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
			jobRepositoryFactoryBean.setDataSource(dataSource);
			jobRepositoryFactoryBean
					.setSerializer(myJackson2ExecutionContextStringSerializer);
			jobRepositoryFactoryBean.setTransactionManager(transactionManager);
			jobRepositoryFactoryBean.afterPropertiesSet();
			return jobRepositoryFactoryBean.getObject();
		}
	};
}
 
Example #26
Source File: JobMonitoringController.java    From spring-boot-starter-batch-web with Apache License 2.0 5 votes vote down vote up
public JobMonitoringController(JobOperator jobOperator, JobExplorer jobExplorer,
		RunningExecutionTracker runningExecutionTracker) {
	super();
	this.jobOperator = jobOperator;
	this.jobExplorer = jobExplorer;
	this.runningExecutionTracker = runningExecutionTracker;
}
 
Example #27
Source File: JobConfiguration.java    From CogStack-Pipeline with Apache License 2.0 5 votes vote down vote up
@Bean
public StepExecutionRequestHandler stepExecutionRequestHandler(
        JobExplorer jobExplorer, BeanFactoryStepLocator stepLocator){
    StepExecutionRequestHandler handler = new StepExecutionRequestHandler();
    handler.setJobExplorer(jobExplorer);
    handler.setStepLocator(stepLocator);
    return handler;
}
 
Example #28
Source File: BatchConfigurer.java    From CogStack-Pipeline with Apache License 2.0 5 votes vote down vote up
@Bean
@Autowired
public JobExplorer jobExplorer(@Qualifier("jobRepositoryDataSource")
                                           DataSource dataSource) throws Exception{
    JobExplorerFactoryBean factory = new JobExplorerFactoryBean();
    factory.setDataSource(dataSource);
    
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example #29
Source File: AbstractEmployeeJobConfig.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Bean
public JobExplorer jobExplorer() throws Exception {
    JobExplorerFactoryBean factory = new JobExplorerFactoryBean();
    factory.setDataSource(dataSource);
    factory.afterPropertiesSet();
    return factory.getObject();
}
 
Example #30
Source File: JdbcHdfsConfiguration.java    From spring-cloud-task-app-starters with Apache License 2.0 5 votes vote down vote up
@Bean
@Profile("worker")
public DeployerStepExecutionHandler stepExecutionHandler(JobExplorer jobExplorer) {
	DeployerStepExecutionHandler handler = new DeployerStepExecutionHandler(this.context, jobExplorer, this.jobRepository);

	return handler;
}