本文整理汇总了Java中org.springframework.batch.support.PropertiesConverter类的典型用法代码示例。如果您正苦于以下问题:Java PropertiesConverter类的具体用法?Java PropertiesConverter怎么用?Java PropertiesConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PropertiesConverter类属于org.springframework.batch.support包,在下文中一共展示了PropertiesConverter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createJobParametersWithIncrementerIfAvailable
import org.springframework.batch.support.PropertiesConverter; //导入依赖的package包/类
private JobParameters createJobParametersWithIncrementerIfAvailable(String parameters, Job job) throws JobParametersNotFoundException {
JobParameters jobParameters = jobParametersConverter.getJobParameters(PropertiesConverter.stringToProperties(parameters));
// use JobParametersIncrementer to create JobParameters if incrementer is set and only if the job is no restart
if (job.getJobParametersIncrementer() != null){
JobExecution lastJobExecution = jobRepository.getLastJobExecution(job.getName(), jobParameters);
boolean restart = false;
// check if job failed before
if (lastJobExecution != null) {
BatchStatus status = lastJobExecution.getStatus();
if (status.isUnsuccessful() && status != BatchStatus.ABANDONED) {
restart = true;
}
}
// if it's not a restart, create new JobParameters with the incrementer
if (!restart) {
JobParameters nextParameters = getNextJobParameters(job);
Map<String, JobParameter> map = new HashMap<String, JobParameter>(nextParameters.getParameters());
map.putAll(jobParameters.getParameters());
jobParameters = new JobParameters(map);
}
}
return jobParameters;
}
示例2: fromJobParameters
import org.springframework.batch.support.PropertiesConverter; //导入依赖的package包/类
/**
* @param oldParameters the latest job parameters
* @return a String representation for rendering the job parameters from the last
* instance
*/
private String fromJobParameters(JobParameters oldParameters) {
String properties = PropertiesConverter.propertiesToString(converter.getProperties(oldParameters));
if (properties.startsWith("#")) {
properties = properties.substring(properties.indexOf(LINE_SEPARATOR) + LINE_SEPARATOR.length());
}
properties = properties.replace("\\:", ":");
return properties;
}
示例3: extractJobDataMap
import org.springframework.batch.support.PropertiesConverter; //导入依赖的package包/类
/**
* <p>
* Returns a map with the job parameters
* </p>
*
* @param jobName
* @param params
* @return Map<String, Object>
*/
public static Map<String, Object> extractJobDataMap(String jobName, String params) {
Map<String, Object> jobDataMap = new HashMap<String, Object>();
// Adding the job name
jobDataMap.put(Constants.JOB_NAME, jobName);
Properties properties = PropertiesConverter.stringToProperties(params);
for (String propertyName : properties.stringPropertyNames()) {
jobDataMap.put(propertyName, properties.getProperty(propertyName));
}
return jobDataMap;
}