Example usage for org.springframework.batch.core Job getName

List of usage examples for org.springframework.batch.core Job getName

Introduction

In this page you can find the example usage for org.springframework.batch.core Job getName.

Prototype

String getName();

Source Link

Usage

From source file:com.ibm.zdu.ZduApplication.java

private static void executeBatchProcess(ZduConfig config) {
    // TODO read all CSV files that are placed in the path
    try {/*from   w w w.jav a2  s.c  o m*/
        // Execute the batch process
        Job createOrUpdateUserJob = ctx.getBean("createOrUpdateUserJob", Job.class);
        System.out.println("job.getName()***" + createOrUpdateUserJob.getName());
        JobLauncher jobLauncher = ctx.getBean(JobLauncher.class);
        JobStatusManager statusManager = BatchContextManager.getInstance()
                .initializeStatusManager(createOrUpdateUserJob.getName(), config);
        System.out.println("in application statusManager***" + statusManager);

        JobParameters jobParameters = new JobParametersBuilder().addDate("date", new Date()).toJobParameters();
        JobExecution jobExecution = jobLauncher.run(createOrUpdateUserJob, jobParameters);
    } catch (Exception e) {
    }
}

From source file:com.enterra.batch.admin.sample.JobIntegrationTests.java

@Test
public void testSimpleProperties() throws Exception {
    assertNotNull(jobLocator);/*w w  w . j a va2  s  .c  o m*/
    Job job = jobLocator.getJob("infinite");
    assertNotNull(job);
    assertEquals("infinite", job.getName());
}

From source file:io.spring.batch.integration.TweetToJobTransformer.java

@Transformer(inputChannel = "jobTweets", outputChannel = "jobChannel")
public JobLaunchRequest transform(Tweet tweet) {

    System.out.println("Creating request");

    String[] tweetParams = tweet.getText().split(" ");
    Job job = (Job) context.getBean(tweetParams[0]);

    System.out.println("Job = " + job.getName());

    JobParametersBuilder paramsBuilder = new JobParametersBuilder();

    for (int i = 1; i < tweetParams.length; i++) {
        String[] param = tweetParams[1].split("=");
        paramsBuilder.addString(param[0], param[1]);
    }//from  w w  w.  j  a v a2  s .  com

    System.out.println("Parameters = " + paramsBuilder.toString());

    JobLaunchRequest request = new JobLaunchRequest(job, paramsBuilder.toJobParameters());

    return request;
}

From source file:kr.okplace.job.launch.DefaultJobLoader.java

public Map<String, String> getConfigurations() {
    Map<String, String> result = new HashMap<String, String>(configurations);
    for (String jobName : registry.getJobNames()) {
        try {/*from   w  ww.ja  va 2  s  . c om*/
            Job configuration = registry.getJob(jobName);
            String name = configuration.getName();
            if (!configurations.containsKey(name)) {
                result.put(name, "<unknown path>: " + configuration);
            }
        } catch (NoSuchJobException e) {
            throw new IllegalStateException("Registry could not locate its own job (NoSuchJobException).");
        }
    }
    return result;
}

From source file:com.rsone.util.JobLauncherSynchronizer.java

@Before("execution(* org.springframework.batch..JobLauncher+.*(..)) && args(job,..)")
public void checkJobBeforeLaunch(Job job) throws JobExecutionAlreadyRunningException {
    String jobName = job.getName();
    logger.debug("Checking for synchronization on Job: " + jobName);
    if (!jobNames.contains(jobName)) {
        logger.debug("Not synchronizing Job: " + jobName);
        return;//  w ww.j a v  a 2s . c o  m
    }
    Set<JobExecution> running = jobExplorer.findRunningJobExecutions(jobName);
    if (!running.isEmpty()) {
        throw new JobExecutionAlreadyRunningException("An instance of this job is already active: " + jobName);
    }
    logger.debug("Job checked and no duplicates detected: " + jobName);
}

From source file:org.appverse.web.framework.backend.batch.services.business.impl.live.JobRunnerServiceImpl.java

@Override
public JobExecution runJob(Job job, int postExecutionSleepTime) throws Exception {
    if (skipExecution(job.getName(), postExecutionSleepTime)) {
        return null;
    }//from ww  w  .  j  ava  2 s .  com
    return jobLauncher.run(job, job.getJobParametersIncrementer().getNext(new JobParameters()));
}

From source file:de.langmi.spring.batch.examples.basics.purejava.PureJavaJobTest.java

/**
 * Some simple tests for the simple job.
 * /*ww  w .j a  va2 s  . com*/
 * @throws Exception
 */
@Test
public void testJob() throws Exception {
    Job job = PureJavaJobFactory.createJob(jobRepository, transactionManager);
    // assertions on job level
    assertNotNull(job);
    assertEquals("job1", job.getName());
}

From source file:de.langmi.spring.batch.examples.basics.purejava.PureJavaJobTest.java

/**
 * Test if the job is constructed as i wanted it to be.
 * /*from  ww w .  j a  va  2 s  .  c  o m*/
 * @throws Exception 
 */
@Test
public void testJobStepConfig() throws Exception {
    Job job = PureJavaJobFactory.createJob(jobRepository, transactionManager);
    // assertions on job level
    assertNotNull(job);
    assertEquals("job1", job.getName());
    assertTrue(job instanceof SimpleJob);
    // assertions on step level
    assertNotNull(((SimpleJob) job).getStepNames());
    assertEquals(1, ((SimpleJob) job).getStepNames().size());
    Step step = ((SimpleJob) job).getStep("step1");
    assertNotNull(step);
    assertTrue(step instanceof TaskletStep);
}

From source file:de.codecentric.batch.web.JobOperationsController.java

/**
 * Borrowed from CommandLineJobRunner./*from   w  ww  .  ja  v  a  2s  . c om*/
 * @param job the job that we need to find the next parameters for
 * @return the next job parameters if they can be located
 * @throws JobParametersNotFoundException if there is a problem
 */
private JobParameters getNextJobParameters(Job job) throws JobParametersNotFoundException {
    String jobIdentifier = job.getName();
    JobParameters jobParameters;
    List<JobInstance> lastInstances = jobExplorer.getJobInstances(jobIdentifier, 0, 1);

    JobParametersIncrementer incrementer = job.getJobParametersIncrementer();

    if (lastInstances.isEmpty()) {
        jobParameters = incrementer.getNext(new JobParameters());
        if (jobParameters == null) {
            throw new JobParametersNotFoundException(
                    "No bootstrap parameters found from incrementer for job=" + jobIdentifier);
        }
    } else {
        List<JobExecution> lastExecutions = jobExplorer.getJobExecutions(lastInstances.get(0));
        jobParameters = incrementer.getNext(lastExecutions.get(0).getJobParameters());
    }
    return jobParameters;
}

From source file:egovframework.rte.bat.core.launch.support.EgovCommandLineRunner.java

/**
 * ?  ? Batch Job? Job Parameter ?.//  w w  w  . ja v a2s  . c  o m
 * 
 * @param job
 * @return JobParameters
 * @throws JobParametersNotFoundException 
 */
private JobParameters getNextJobParameters(Job job) throws JobParametersNotFoundException {
    String jobIdentifier = job.getName();
    JobParameters jobParameters;
    List<JobInstance> lastInstances = jobExplorer.getJobInstances(jobIdentifier, 0, 1);

    JobParametersIncrementer incrementer = job.getJobParametersIncrementer();
    if (incrementer == null) {
        throw new JobParametersNotFoundException(
                "No job parameters incrementer found for job=" + jobIdentifier);
    }

    if (lastInstances.isEmpty()) {
        jobParameters = incrementer.getNext(new JobParameters());
        if (jobParameters == null) {
            throw new JobParametersNotFoundException(
                    "No bootstrap parameters found from incrementer for job=" + jobIdentifier);
        }
    } else {
        jobParameters = incrementer.getNext(lastInstances.get(0).getJobParameters());
    }
    return jobParameters;
}