本文整理匯總了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;
}