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


Java JobLauncher类代码示例

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


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

示例1: main

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("chunkJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:24,代码来源:Main.java

示例2: main

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("taskletJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:24,代码来源:Main.java

示例3: runner

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
CommandLineRunner runner(JobLauncher launcher,
                         Job job,
                         @Value("${file}") File in,
                         JdbcTemplate jdbcTemplate) {
    return args -> {

        JobExecution execution = launcher.run(job,
                new JobParametersBuilder()
                        .addString("file", in.getAbsolutePath())
                        .toJobParameters());

        System.out.println("execution status: " + execution.getExitStatus().toString());

        List<Person> personList = jdbcTemplate.query("select * from PEOPLE", (resultSet, i) -> new Person(resultSet.getString("first"),
                resultSet.getString("last"),
                resultSet.getString("email")));

        personList.forEach(System.out::println);

    };

}
 
开发者ID:livelessons-spring,项目名称:building-microservices,代码行数:23,代码来源:BatchConfiguration.java

示例4: run

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
private static void run(final String[] args, final String payloadFilePath) throws Exception {
    try(final ConfigurableApplicationContext context = SpringApplication.run(PayloadJobMain.class, args)) {
        final List<JobLaunchingData> jobLaunchingDataList = parseJobParameters(payloadFilePath);
        final JobLauncher jobLauncher = context.getBean(JobLauncher.class);
        for(final JobLaunchingData jobLaunchingData : jobLaunchingDataList) {
            final String jobName = jobLaunchingData.getJobName();
            final JobParameters jobParameters = jobLaunchingData.getJobParameters();
            final Job job = context.getBean(jobName, Job.class);
            final JobExecution jobExecution = jobLauncher.run(job, jobParameters);
            awaitTermination(jobExecution, Duration.ofMinutes(30));
            if (!jobExecution.getExitStatus().equals(ExitStatus.COMPLETED)) {
                throw new JobExecutionUnsuccessfullException(String.format("Job %s was unsuccessful with status %s.", jobName, jobExecution.getExitStatus()));
            }
        }
    }
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:17,代码来源:PayloadJobMain.java

示例5: testRenamePrefix

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
@Test
public void testRenamePrefix() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.name:batchtest",
			"spring.batch.schema:classpath:batch/custom-schema-hsql.sql",
			"spring.batch.tablePrefix:PREFIX_");
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	assertThat(this.context.getBean(JobLauncher.class)).isNotNull();
	assertThat(new JdbcTemplate(this.context.getBean(DataSource.class))
			.queryForList("select * from PREFIX_JOB_EXECUTION")).isEmpty();
	JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
	assertThat(jobExplorer.findRunningJobExecutions("test")).isEmpty();
	JobRepository jobRepository = this.context.getBean(JobRepository.class);
	assertThat(jobRepository.getLastJobExecution("test", new JobParameters()))
			.isNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:BatchAutoConfigurationTests.java

示例6: init

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
@Before
public void init() throws Exception {
	this.context.register(BatchConfiguration.class);
	this.context.refresh();
	JobRepository jobRepository = this.context.getBean(JobRepository.class);
	this.jobLauncher = this.context.getBean(JobLauncher.class);
	this.jobs = new JobBuilderFactory(jobRepository);
	PlatformTransactionManager transactionManager = this.context
			.getBean(PlatformTransactionManager.class);
	this.steps = new StepBuilderFactory(jobRepository, transactionManager);
	this.step = this.steps.get("step").tasklet(new Tasklet() {
		@Override
		public RepeatStatus execute(StepContribution contribution,
				ChunkContext chunkContext) throws Exception {
			return null;
		}
	}).build();
	this.job = this.jobs.get("job").start(this.step).build();
	this.jobExplorer = this.context.getBean(JobExplorer.class);
	this.runner = new JobLauncherCommandLineRunner(this.jobLauncher,
			this.jobExplorer);
	this.context.getBean(BatchConfiguration.class).clear();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:24,代码来源:JobLauncherCommandLineRunnerTests.java

示例7: main

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("multiResourceItemReaderJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:24,代码来源:Main.java

示例8: main

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("customReaderWriterProcesorJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("Done");

	}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:24,代码来源:Main.java

示例9: main

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("customListeners");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("Done");

	}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:24,代码来源:Main.java

示例10: main

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("flatFileItemWriterJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:24,代码来源:Main.java

示例11: main

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("parallelStepsJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:24,代码来源:Main.java

示例12: main

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("secuentialControlFlow");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("Done");

	}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:24,代码来源:Main.java

示例13: main

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("xmlReadersWritersJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
开发者ID:maldiny,项目名称:Spring-Batch-en-Castellano,代码行数:24,代码来源:Main.java

示例14: resolveJobLauncher

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
private JobLauncher resolveJobLauncher() {
    if (jobLauncherRef != null) {
        JobLauncher jobLauncher = getCamelContext().getRegistry().lookupByNameAndType(jobLauncherRef, JobLauncher.class);
        if (jobLauncher == null) {
            throw new IllegalStateException(String.format("No JobLauncher named %s found in the registry.", jobLauncherRef));
        }
        return jobLauncher;
    }

    if (defaultResolvedJobLauncher != null) {
        return defaultResolvedJobLauncher;
    }

    if (allResolvedJobLaunchers.size() == 1) {
        return allResolvedJobLaunchers.values().iterator().next();
    } else if (allResolvedJobLaunchers.size() > 1) {
        throw new IllegalStateException("Expected single jobLauncher instance. Found: " + allResolvedJobLaunchers.size());
    }

    throw new IllegalStateException("Cannot find Spring Batch JobLauncher.");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:SpringBatchEndpoint.java

示例15: shouldInjectJobLauncherByReferenceName

import org.springframework.batch.core.launch.JobLauncher; //导入依赖的package包/类
@Test
public void shouldInjectJobLauncherByReferenceName() throws Exception {
    // Given
    context().addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:launcherRefTest").to("spring-batch:mockJob?jobLauncher=#alternativeJobLauncher");
        }
    });

    // When
    template.sendBody("direct:launcherRefTest", "Start the job, please.");

    // Then
    SpringBatchEndpoint batchEndpoint = context().getEndpoint("spring-batch:mockJob?jobLauncher=#alternativeJobLauncher", SpringBatchEndpoint.class);
    JobLauncher batchEndpointJobLauncher = (JobLauncher) FieldUtils.readField(batchEndpoint, "jobLauncher", true);
    assertSame(alternativeJobLauncher, batchEndpointJobLauncher);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:SpringBatchEndpointTest.java


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