1 |
| package org.jboss.cache.loader; |
2 |
| |
3 |
| import org.apache.commons.logging.Log; |
4 |
| import org.apache.commons.logging.LogFactory; |
5 |
| import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig; |
6 |
| |
7 |
| import java.util.Properties; |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| public class JDBCCacheLoaderConfig extends AdjListJDBCCacheLoaderConfig |
16 |
| { |
17 |
| |
18 |
| private static final long serialVersionUID = -8371846151643130271L; |
19 |
| |
20 |
| private static final Log log = LogFactory.getLog(JDBCCacheLoaderConfig.class); |
21 |
| |
22 |
| private String deleteNode; |
23 |
| private String recursiveChildren; |
24 |
| private String nodeCountSql; |
25 |
| |
26 |
| |
27 |
253
| public JDBCCacheLoaderConfig(IndividualCacheLoaderConfig base)
|
28 |
| { |
29 |
253
| super(base);
|
30 |
253
| setClassName(JDBCCacheLoader.class.getName());
|
31 |
| } |
32 |
| |
33 |
| |
34 |
253
| public void setProperties(Properties props)
|
35 |
| { |
36 |
253
| super.setProperties(props);
|
37 |
253
| String sqlConcat = props.getProperty("cache.jdbc.sql-concat");
|
38 |
253
| if (sqlConcat == null) {
|
39 |
7
| log.info("Missiing JDBCCacheLoader config 'cache.jdbc.sql-concat', using default value:'concat(1,2)'");
|
40 |
7
| sqlConcat = "concat(1,2)";
|
41 |
| } |
42 |
253
| String startingWith = sqlConcat.replace('1', '?').replace("2", "'%'");
|
43 |
253
| String appendSepparator = sqlConcat.replace("1", fqnColumn).replace("2", "'/'");
|
44 |
253
| deleteNode = "delete from " + table + " where " + appendSepparator + " like " + startingWith;
|
45 |
253
| recursiveChildren = "select " + fqnColumn + "," + nodeColumn + " from " + table + " where " + appendSepparator + " like " + startingWith;
|
46 |
253
| nodeCountSql = "select count(*) from " + table;
|
47 |
| } |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
6636
| public String getDeleteNodeSql()
|
54 |
| { |
55 |
6636
| return deleteNode;
|
56 |
| } |
57 |
| |
58 |
| |
59 |
| |
60 |
| |
61 |
16
| public String getRecursiveChildrenSql()
|
62 |
| { |
63 |
16
| return recursiveChildren;
|
64 |
| } |
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
246
| public String getNodeCountSql()
|
71 |
| { |
72 |
246
| return nodeCountSql;
|
73 |
| } |
74 |
| } |