1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.core.database;
17
18 import java.sql.SQLException;
19
20 import javax.transaction.TransactionManager;
21
22 import org.enhydra.jdbc.pool.StandardXAPoolDataSource;
23 import org.kuali.rice.core.exception.RiceRuntimeException;
24 import org.springframework.beans.factory.DisposableBean;
25 import org.springframework.beans.factory.InitializingBean;
26
27
28
29
30
31
32
33
34 public class XAPoolDataSource extends StandardXAPoolDataSource implements InitializingBean, DisposableBean {
35
36 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(XAPoolDataSource.class);
37
38 private static final long serialVersionUID = -3698043954102287887L;
39 public static final String DRIVER_CLASS_NAME = "driverClassName";
40 public static final String URL = "url";
41 public static final String USERNAME = "username";
42 public static final String PASSWORD = "password";
43 public static final String MAX_SIZE = "maxSize";
44 public static final String MIN_SIZE = "minSize";
45 public static final String MAX_WAIT = "maxWait";
46 public static final String VALIDATION_QUERY = "validationQuery";
47
48 private RiceXADataSource dataSource = new RiceXADataSource();
49 private boolean started = false;
50
51 public XAPoolDataSource() {
52 setDataSource(this.dataSource);
53 setPreparedStmtCacheSize(0);
54 setCheckLevelObject(2);
55 }
56
57 public void afterPropertiesSet() throws Exception {
58 }
59
60 public void destroy() throws Exception {
61 LOG.info("Destroying WorkflowManagedDatasource.");
62 shutdown(true);
63 this.started = false;
64 }
65
66 public boolean isStarted() {
67 return this.started;
68 }
69
70 public String getDriverClassName() throws SQLException {
71 return this.dataSource.getDriverName();
72 }
73
74 public long getMaxWait() {
75 return super.getDeadLockMaxWait();
76 }
77
78 public String getUrl() {
79 return this.dataSource.getUrl();
80 }
81
82 public String getUsername() {
83 return this.dataSource.getUser();
84 }
85
86 public String getValidationQuery() {
87 return super.getJdbcTestStmt();
88 }
89
90 public void setBeanName(String dataSourceName) {
91 this.dataSourceName = dataSourceName;
92 }
93
94 public void setDriverClassName(String driverClassName) {
95 try {
96 this.dataSource.setDriverName(driverClassName);
97 } catch (SQLException e) {
98 throw new RiceRuntimeException("Problem setting the driver name to: " + driverClassName, e);
99 }
100 }
101
102 public void setMaxWait(long maxWait) {
103 super.setDeadLockMaxWait(maxWait);
104 }
105
106 public void setPassword(String password) {
107
108 this.dataSource.setPassword(password);
109 super.setPassword(password);
110 }
111
112 public void setTransactionManager(TransactionManager transactionManager) {
113 this.dataSource.setTransactionManager(transactionManager);
114 }
115
116 public void setUrl(String url) {
117 this.dataSource.setUrl(url);
118 }
119
120 public void setUsername(String username) {
121
122 this.dataSource.setUser(username);
123 super.setUser(username);
124 }
125
126 public void setValidationQuery(String validationQuery) {
127 super.setJdbcTestStmt(validationQuery);
128 }
129
130 public void setPreparedStmtCacheSize(int preparedStatementCacheSize) {
131 this.dataSource.setPreparedStatementCacheSize(preparedStatementCacheSize);
132 }
133 }