Package org.springframework.batch.core.configuration

Examples of org.springframework.batch.core.configuration.JobFactory


      }
      mainJob
            .setJobExecutionListeners(new JobExecutionListener[] { mainJobExecutionListener });
      mainJob.setJobRepository(jobRepository);
      mainJob.afterPropertiesSet();
      JobFactory jobFactory = new ReferenceJobFactory(mainJob);
      jobRegistry.register(jobFactory);
      logger.info("registered job: " + mainJob.getName());
      JobParameters mainJobParameters = new JobParameters(mainJobParams);
      JobExecution mainJobExecution =
            jobLauncher.run(mainJob, mainJobParameters);
View Full Code Here


  @Override
  public void register(JobFactory jobFactory) throws DuplicateJobException {
    Assert.notNull(jobFactory);
    String name = jobFactory.getJobName();
    Assert.notNull(name, "Job configuration must have a name.");
    JobFactory previousValue = map.putIfAbsent(name, jobFactory);
    if (previousValue != null) {
      throw new DuplicateJobException("A job configuration with this name [" + name
          + "] was already registered");
    }
  }
View Full Code Here

    map.remove(name);
  }

  @Override
  public Job getJob(String name) throws NoSuchJobException {
    JobFactory factory = map.get(name);
    if (factory == null) {
      throw new NoSuchJobException("No job configuration with the name [" + name + "] was registered");
    } else {
      return factory.createJob();
    }
  }
View Full Code Here

  /**
   * Test method for {@link org.springframework.batch.core.configuration.support.MapJobRegistry#getJob(java.lang.String)}.
   */
  public void testRealDuplicateConfiguration() throws Exception {
    JobFactory jobFactory = new ReferenceJobFactory(new JobSupport("foo"));
    registry.register(jobFactory);
    try {
      registry.register(jobFactory);
      fail("Unexpected DuplicateJobConfigurationException");
    } catch (DuplicateJobException e) {
View Full Code Here

  /**
   * Test method for {@link org.springframework.batch.core.configuration.support.MapJobRegistry#getJobNames()}.
   * @throws Exception
   */
  public void testGetJobConfigurations() throws Exception {
    JobFactory jobFactory = new ReferenceJobFactory(new JobSupport("foo"));
    registry.register(jobFactory);
    registry.register(new ReferenceJobFactory(new JobSupport("bar")));
    Collection<String> configurations = registry.getJobNames();
    assertEquals(2, configurations.size());
    assertTrue(configurations.contains(jobFactory.getJobName()));
  }
View Full Code Here

   * @throws Exception
   */
  @Test
  public void testBind() throws Exception {
    listener.setJobRegistry(registry);
    listener.bind(new JobFactory() {
      @Override
      public Job createJob() {
        return null;
      }

View Full Code Here

   * @throws Exception
   */
  @Test
  public void testUnbind() throws Exception {
    testBind();
    listener.unbind(new JobFactory() {
      @Override
      public Job createJob() {
        return null;
      }

View Full Code Here

   * @param context the context in which the job is defined
   * @param job the job to register
   * @throws DuplicateJobException if that job is already registered
   */
  private void doRegister(ConfigurableApplicationContext context, Job job) throws DuplicateJobException {
    final JobFactory jobFactory = new ReferenceJobFactory(job);
    jobRegistry.register(jobFactory);

    if (stepRegistry != null) {
      if (!(job instanceof StepLocator)) {
        throw new UnsupportedOperationException("Cannot locate steps from a Job that is not a StepLocator: job="
View Full Code Here

TOP

Related Classes of org.springframework.batch.core.configuration.JobFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.