1 16 17 package org.springframework.orm.ibatis.support; 18 19 import javax.sql.DataSource ; 20 21 import com.ibatis.sqlmap.client.SqlMapClient; 22 23 import org.springframework.dao.support.DaoSupport; 24 import org.springframework.orm.ibatis.SqlMapClientTemplate; 25 26 43 public abstract class SqlMapClientDaoSupport extends DaoSupport { 44 45 private SqlMapClientTemplate sqlMapClientTemplate = new SqlMapClientTemplate(); 46 47 private boolean externalTemplate = false; 48 49 54 public final void setDataSource(DataSource dataSource) { 55 this.sqlMapClientTemplate.setDataSource(dataSource); 56 } 57 58 61 public final DataSource getDataSource() { 62 return (this.sqlMapClientTemplate != null ? this.sqlMapClientTemplate.getDataSource() : null); 63 } 64 65 70 public final void setSqlMapClient(SqlMapClient sqlMapClient) { 71 this.sqlMapClientTemplate.setSqlMapClient(sqlMapClient); 72 } 73 74 77 public final SqlMapClient getSqlMapClient() { 78 return this.sqlMapClientTemplate.getSqlMapClient(); 79 } 80 81 86 public final void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate) { 87 if (sqlMapClientTemplate == null) { 88 throw new IllegalArgumentException ("Cannot set sqlMapClientTemplate to null"); 89 } 90 this.sqlMapClientTemplate = sqlMapClientTemplate; 91 this.externalTemplate = true; 92 } 93 94 98 public final SqlMapClientTemplate getSqlMapClientTemplate() { 99 return sqlMapClientTemplate; 100 } 101 102 protected final void checkDaoConfig() { 103 if (!this.externalTemplate) { 104 this.sqlMapClientTemplate.afterPropertiesSet(); 105 } 106 } 107 108 } 109 | Popular Tags |