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


Java JobParameters类代码示例

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


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

示例1: testComposedConfiguration

import org.springframework.batch.core.JobParameters; //导入依赖的package包/类
@Test
@DirtiesContext
public void testComposedConfiguration() throws Exception {
	JobExecution jobExecution = this.jobRepository.createJobExecution(
			"ComposedTest", new JobParameters());
	job.execute(jobExecution);

	Map<String, String> props = new HashMap<>(1);
	props.put("format", "yyyy");
	assertEquals(1010, composedTaskProperties.getMaxWaitTime());
	assertEquals(1100, composedTaskProperties.getIntervalTimeBetweenChecks());
	assertEquals("http://bar", composedTaskProperties.getDataflowServerUri().toASCIIString());

	List<String> args = new ArrayList<>(1);
	args.add("--baz=boo");
	Assert.isNull(job.getJobParametersIncrementer(), "JobParametersIncrementer must be null.");
	verify(this.taskOperations).launch("AAA", props, args);
}
 
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:19,代码来源:ComposedTaskRunnerConfigurationWithPropertiesTests.java

示例2: main

import org.springframework.batch.core.JobParameters; //导入依赖的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

示例3: main

import org.springframework.batch.core.JobParameters; //导入依赖的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

示例4: testWriteTaxonFile

import org.springframework.batch.core.JobParameters; //导入依赖的package包/类
/**
 * @throws Exception
 */
@Test
public void testWriteTaxonFile() throws Exception {
	Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
	parameters.put("query", new JobParameter(""));
	parameters.put("selected.facets", new JobParameter("taxon.family_ss=Araceae"));
	parameters.put("download.taxon", new JobParameter(toParameter(DarwinCorePropertyMap.getConceptTerms(DwcTerm.Taxon))));
	parameters.put("download.file", new JobParameter(UUID.randomUUID().toString() + ".txt"));
	parameters.put("download.limit", new JobParameter(new Integer(Integer.MAX_VALUE).toString()));
	parameters.put("download.fieldsTerminatedBy", new JobParameter("\t"));
	parameters.put("download.fieldsEnclosedBy", new JobParameter("\""));
	parameters.put("download.format", new JobParameter("taxon"));

	JobParameters jobParameters = new JobParameters(parameters);
	Job archiveCreatorJob = jobLocator.getJob("FlatFileCreation");
	assertNotNull("flatFileCreatorJob must exist", archiveCreatorJob);
	JobExecution jobExecution = jobLauncher.run(archiveCreatorJob,
			jobParameters);

	assertEquals("The Job should be sucessful", ExitStatus.COMPLETED, jobExecution.getExitStatus());
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:24,代码来源:FlatFileCreatorIntegrationTest.java

示例5: testCreateGenericArchive

import org.springframework.batch.core.JobParameters; //导入依赖的package包/类
@Test
public void testCreateGenericArchive() throws NoSuchJobException,
JobExecutionAlreadyRunningException, JobRestartException,
JobInstanceAlreadyCompleteException, JobParametersInvalidException, IOException {
	Map<String, JobParameter> parameters =
			new HashMap<String, JobParameter>();

	JobParameters jobParameters = new JobParameters(parameters);

	Job palmwebArchive = jobLocator.getJob("PalmWeb");
	assertNotNull("Palmweb must not be null",  palmwebArchive);
	JobExecution jobExecution = jobLauncher.run(palmwebArchive, jobParameters);
	assertEquals("The job should complete successfully",jobExecution.getExitStatus().getExitCode(),"COMPLETED");
	for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
		logger.info(stepExecution.getStepName() + " "
				+ stepExecution.getReadCount() + " "
				+ stepExecution.getFilterCount() + " "
				+ stepExecution.getWriteCount() + " " + stepExecution.getCommitCount());
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:21,代码来源:PalmwebIntegrationTest.java

示例6: testComposedConfiguration

import org.springframework.batch.core.JobParameters; //导入依赖的package包/类
@Test
@DirtiesContext
public void testComposedConfiguration() throws Exception {
	JobExecution jobExecution = this.jobRepository.createJobExecution(
			"ComposedTest", new JobParameters());
	job.execute(jobExecution);

	Assert.isNull(job.getJobParametersIncrementer(), "JobParametersIncrementer must be null.");
	verify(this.taskOperations).launch("AAA", new HashMap<String, String>(0), new ArrayList<String>(0));
}
 
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:11,代码来源:ComposedTaskRunnerConfigurationNoPropertiesTests.java

示例7: runDemoJob

import org.springframework.batch.core.JobParameters; //导入依赖的package包/类
@Scheduled(fixedDelayString = "${demo.job.fixed.delay.seconds:60}000")
public void runDemoJob() {

    SimpleDateFormat format = new SimpleDateFormat("M-dd-yy hh:mm:ss");
    String startDateTime = format.format(new Date());

    JobParameters jobParameters =
            new JobParametersBuilder()
                    .addLong("iterations", iterations)
                    .addString("username", username)
                    .addLong("time", System.currentTimeMillis()).toJobParameters();

    try {
        logger.info("");
        logger.info("STARTING BATCH JOB AT " + startDateTime);
        JobExecution execution = jobLauncher.run(demoJob, jobParameters);
        logger.info("JOB STATUS : " + execution.getStatus());
    } catch (Exception e) {
        e.printStackTrace();
        logger.info("JOB FAILED!!!");
    }

}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:24,代码来源:DemoJobRunner.java

示例8: executeRegisteredJobs

import org.springframework.batch.core.JobParameters; //导入依赖的package包/类
private void executeRegisteredJobs(JobParameters jobParameters)
		throws JobExecutionException {
	if (this.jobRegistry != null && StringUtils.hasText(this.jobNames)) {
		String[] jobsToRun = this.jobNames.split(",");
		for (String jobName : jobsToRun) {
			try {
				Job job = this.jobRegistry.getJob(jobName);
				if (this.jobs.contains(job)) {
					continue;
				}
				execute(job, jobParameters);
			}
			catch (NoSuchJobException ex) {
				logger.debug("No job found in registry for job name: " + jobName);
				continue;
			}
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:JobLauncherCommandLineRunner.java

示例9: testUsingJpa

import org.springframework.batch.core.JobParameters; //导入依赖的package包/类
@Test
public void testUsingJpa() throws Exception {
	this.context = new AnnotationConfigApplicationContext();
	// The order is very important here: DataSource -> Hibernate -> Batch
	this.context.register(TestConfiguration.class,
			EmbeddedDataSourceConfiguration.class,
			HibernateJpaAutoConfiguration.class, BatchAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class);
	this.context.refresh();
	PlatformTransactionManager transactionManager = this.context
			.getBean(PlatformTransactionManager.class);
	// It's a lazy proxy, but it does render its target if you ask for toString():
	assertThat(transactionManager.toString().contains("JpaTransactionManager"))
			.isTrue();
	assertThat(this.context.getBean(EntityManagerFactory.class)).isNotNull();
	// Ensure the JobRepository can be used (no problem with isolation level)
	assertThat(this.context.getBean(JobRepository.class).getLastJobExecution("job",
			new JobParameters())).isNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:BatchAutoConfigurationTests.java

示例10: testRenamePrefix

import org.springframework.batch.core.JobParameters; //导入依赖的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

示例11: retryFailedExecutionOnNonRestartableJob

import org.springframework.batch.core.JobParameters; //导入依赖的package包/类
@Test
public void retryFailedExecutionOnNonRestartableJob() throws Exception {
	this.job = this.jobs.get("job").preventRestart()
			.start(this.steps.get("step").tasklet(new Tasklet() {
				@Override
				public RepeatStatus execute(StepContribution contribution,
						ChunkContext chunkContext) throws Exception {
					throw new RuntimeException("Planned");
				}
			}).build()).incrementer(new RunIdIncrementer()).build();
	this.runner.execute(this.job, new JobParameters());
	this.runner.execute(this.job, new JobParameters());
	// A failed job that is not restartable does not re-use the job params of
	// the last execution, but creates a new job instance when running it again.
	assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(2);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:JobLauncherCommandLineRunnerTests.java

示例12: retryFailedExecutionWithNonIdentifyingParameters

import org.springframework.batch.core.JobParameters; //导入依赖的package包/类
@Test
public void retryFailedExecutionWithNonIdentifyingParameters() throws Exception {
	this.job = this.jobs.get("job")
			.start(this.steps.get("step").tasklet(new Tasklet() {
				@Override
				public RepeatStatus execute(StepContribution contribution,
						ChunkContext chunkContext) throws Exception {
					throw new RuntimeException("Planned");
				}
			}).build()).incrementer(new RunIdIncrementer()).build();
	JobParameters jobParameters = new JobParametersBuilder().addLong("id", 1L, false)
			.addLong("foo", 2L, false).toJobParameters();
	this.runner.execute(this.job, jobParameters);
	this.runner.execute(this.job, jobParameters);
	assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(1);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:JobLauncherCommandLineRunnerTests.java

示例13: main

import org.springframework.batch.core.JobParameters; //导入依赖的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

示例14: main

import org.springframework.batch.core.JobParameters; //导入依赖的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

示例15: main

import org.springframework.batch.core.JobParameters; //导入依赖的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


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