3939import org .springframework .batch .core .job .JobInstance ;
4040import org .springframework .batch .core .job .parameters .JobParameter ;
4141import org .springframework .batch .core .job .parameters .JobParameters ;
42- import org .springframework .batch .core .converter .DateToStringConverter ;
43- import org .springframework .batch .core .converter .LocalDateTimeToStringConverter ;
44- import org .springframework .batch .core .converter .LocalDateToStringConverter ;
45- import org .springframework .batch .core .converter .LocalTimeToStringConverter ;
46- import org .springframework .batch .core .converter .StringToDateConverter ;
47- import org .springframework .batch .core .converter .StringToLocalDateConverter ;
48- import org .springframework .batch .core .converter .StringToLocalDateTimeConverter ;
49- import org .springframework .batch .core .converter .StringToLocalTimeConverter ;
5042import org .springframework .batch .core .repository .dao .AbstractJdbcBatchMetadataDao ;
5143import org .springframework .batch .core .repository .dao .JobExecutionDao ;
5244import org .springframework .batch .core .repository .dao .NoSuchObjectException ;
5345import org .springframework .beans .factory .InitializingBean ;
54- import org .springframework .core .convert .support .ConfigurableConversionService ;
55- import org .springframework .core .convert .support .DefaultConversionService ;
5646import org .springframework .dao .EmptyResultDataAccessException ;
5747import org .springframework .dao .OptimisticLockingFailureException ;
5848import org .springframework .jdbc .core .RowCallbackHandler ;
@@ -157,23 +147,8 @@ SELECT COUNT(*)
157147
158148 private DataFieldMaxValueIncrementer jobExecutionIncrementer ;
159149
160- private ConfigurableConversionService conversionService ;
161-
162150 private final Lock lock = new ReentrantLock ();
163151
164- public JdbcJobExecutionDao () {
165- DefaultConversionService conversionService = new DefaultConversionService ();
166- conversionService .addConverter (new DateToStringConverter ());
167- conversionService .addConverter (new StringToDateConverter ());
168- conversionService .addConverter (new LocalDateToStringConverter ());
169- conversionService .addConverter (new StringToLocalDateConverter ());
170- conversionService .addConverter (new LocalTimeToStringConverter ());
171- conversionService .addConverter (new StringToLocalTimeConverter ());
172- conversionService .addConverter (new LocalDateTimeToStringConverter ());
173- conversionService .addConverter (new StringToLocalDateTimeConverter ());
174- this .conversionService = conversionService ;
175- }
176-
177152 /**
178153 * Public setter for the exit message length in database. Do not set this if you
179154 * haven't modified the schema.
@@ -192,15 +167,6 @@ public void setJobExecutionIncrementer(DataFieldMaxValueIncrementer jobExecution
192167 this .jobExecutionIncrementer = jobExecutionIncrementer ;
193168 }
194169
195- /**
196- * Set the conversion service to use to convert job parameters from String literals to
197- * typed values and vice versa.
198- */
199- public void setConversionService (@ NonNull ConfigurableConversionService conversionService ) {
200- Assert .notNull (conversionService , "conversionService must not be null" );
201- this .conversionService = conversionService ;
202- }
203-
204170 @ Override
205171 public void afterPropertiesSet () throws Exception {
206172 super .afterPropertiesSet ();
@@ -432,7 +398,7 @@ private <T> void insertParameter(PreparedStatement preparedStatement, Long execu
432398
433399 String identifyingFlag = identifying ? "Y" : "N" ;
434400
435- String stringValue = this . conversionService .convert (value , String .class );
401+ String stringValue = getConversionService () .convert (value , String .class );
436402
437403 preparedStatement .setLong (1 , executionId );
438404 preparedStatement .setString (2 , key );
@@ -459,7 +425,7 @@ protected JobParameters getJobParameters(Long executionId) {
459425 throw new RuntimeException (e );
460426 }
461427 String stringValue = rs .getString ("PARAMETER_VALUE" );
462- Object typedValue = conversionService .convert (stringValue , parameterType );
428+ Object typedValue = getConversionService () .convert (stringValue , parameterType );
463429
464430 boolean identifying = rs .getString ("IDENTIFYING" ).equalsIgnoreCase ("Y" );
465431
0 commit comments