當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。