/*
 * Copyright 2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.spring.scdf.batch.job;

import java.util.Random;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.task.configuration.EnableTask;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;

/**
 * Created by glennrenfro on 3/7/16.
 */
@Configuration
@EnableBatchProcessing
@EnableTask
public class JobConfiguration {

	@Autowired
	private JobBuilderFactory jobBuilderFactory;

	@Autowired
	private StepBuilderFactory stepBuilderFactory;

	@Value("${sample.jobName}")
	private String jobName;

	@Bean
	public Job job() {

		final String jobNameToUse;

		if (StringUtils.hasText(this.jobName)) {
			jobNameToUse = this.jobName;
		}
		else {
			Random rand = new Random();
			jobNameToUse = "job" + rand.nextInt();
		}

		return jobBuilderFactory.get(jobNameToUse)
				.start(stepBuilderFactory.get("step1").tasklet(new HelloSimpleBatchTasklet()).build())
				.build();
	}
}

@@ -1583,16 +1583,17 @@
 .jobName
+:
 %7D%22)%0A%09pri
@@ -1838,16 +1838,90 @@
 );%0A%09%09%7D%0A%0A
+%09%09System.out.println(%22Setting up new Batch Job named: %22 + jobNameToUse);%0A%0A
 %09%09return

Fix JobName parameter