1+ /*
2+ * Copyright 2022-2023 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
116package org .springframework .batch .sample .metrics ;
217
18+ import javax .sql .DataSource ;
19+
320import org .springframework .batch .core .configuration .annotation .EnableBatchProcessing ;
421import org .springframework .beans .factory .annotation .Value ;
522import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
623import org .springframework .context .annotation .Bean ;
724import org .springframework .context .annotation .Import ;
825import org .springframework .context .annotation .PropertySource ;
26+ import org .springframework .jdbc .datasource .embedded .EmbeddedDatabaseBuilder ;
27+ import org .springframework .jdbc .datasource .embedded .EmbeddedDatabaseType ;
28+ import org .springframework .jdbc .support .JdbcTransactionManager ;
929import org .springframework .scheduling .annotation .EnableScheduling ;
1030import org .springframework .scheduling .concurrent .ThreadPoolTaskScheduler ;
1131
@@ -28,4 +48,16 @@ public ThreadPoolTaskScheduler taskScheduler(@Value("${thread.pool.size}") int t
2848 return threadPoolTaskScheduler ;
2949 }
3050
51+ @ Bean
52+ public DataSource dataSource () {
53+ return new EmbeddedDatabaseBuilder ().setType (EmbeddedDatabaseType .HSQL )
54+ .addScript ("/org/springframework/batch/core/schema-hsqldb.sql" )
55+ .build ();
56+ }
57+
58+ @ Bean
59+ public JdbcTransactionManager transactionManager (DataSource dataSource ) {
60+ return new JdbcTransactionManager (dataSource );
61+ }
62+
3163}
0 commit comments