1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.test.lifecycles;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.core.api.config.property.ConfigContext;
20 import org.kuali.rice.core.api.lifecycle.BaseLifecycle;
21 import org.kuali.rice.test.SQLDataLoader;
22
23
24
25
26
27
28
29
30
31 public class SQLDataLoaderLifecycle extends BaseLifecycle {
32 private static final Logger LOG = Logger.getLogger(SQLDataLoaderLifecycle.class);
33
34 private SQLDataLoader sqlDataLoader;
35
36 private String filename;
37
38 private String delimiter;
39
40 public SQLDataLoaderLifecycle(String filename, String delimiter) {
41 this.filename = filename;
42 this.delimiter = delimiter;
43 }
44
45 public void start() throws Exception {
46 String useSqlDataLoaderLifecycle = ConfigContext.getCurrentContextConfig().getProperty("use.sqlDataLoaderLifecycle");
47 if (useSqlDataLoaderLifecycle != null && !Boolean.valueOf(useSqlDataLoaderLifecycle)) {
48 LOG.debug("Skipping SQLDataLoaderLifecycle due to property: use.sqlDataLoaderLifecycle=" + useSqlDataLoaderLifecycle);
49 return;
50 }
51
52 sqlDataLoader = new SQLDataLoader(filename, delimiter);
53 sqlDataLoader.runSql();
54 super.start();
55 }
56
57 public void stop() throws Exception {
58
59 super.stop();
60 }
61 }