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