1 package org.kuali.common.jdbc.sql.spring;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.kuali.common.jdbc.model.context.JdbcContext;
7 import org.kuali.common.jdbc.service.JdbcExecutable;
8 import org.kuali.common.jdbc.service.JdbcService;
9 import org.kuali.common.util.execute.Executable;
10 import org.kuali.common.util.execute.impl.ExecutablesExecutable;
11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.context.annotation.Bean;
13 import org.springframework.context.annotation.Configuration;
14
15 @Configuration
16 public class JdbcContextsExecutableConfig {
17
18 @Autowired
19 JdbcContextsConfig config;
20
21 @Autowired
22 JdbcService service;
23
24 @Bean(initMethod = "execute")
25 public Executable executeSql() {
26 List<JdbcContext> contexts = config.jdbcContexts();
27 List<Executable> execs = new ArrayList<Executable>();
28 for (JdbcContext context : contexts) {
29 execs.add(new JdbcExecutable(service, context));
30 }
31 return new ExecutablesExecutable(execs);
32 }
33
34 }