So I made a little extension to Spring framework's SqlMapClientFactory class in order to monitor file modification and re-initialize sqlMapClient accordingly. Basic implementation ideas are :
1. don't change original classes of Spring Framework nor iBATIS library.
2. should run with iBATIS 2.3.0 for jdk 1.4 and iBATIS 2.3.2 or later for jdk 1.5 or higher.
(with the nice feature of Spring 2.5.5+ SqlMapClientFactoryBean's wildcard matching while preserving compatibility with old libraries.)
3. assuming default singleton scoped beans, SqlMapClientFactoryBean creates new SqlMapClient instance only when Spring initializes the applicationContext. The object (sqlMapclient) injected to other beans cannot be replaced while the application is up. It should be replaced with a proxy. The proxy, sitting in as the product of the factory, deligates all the received messages to the real sqlMapClient object, which can be replaced whenever the mapping files are modified.
4. make list of files to monitor from SqlMapClientFactoryBean's properties and sqlMapConfig files.
Limitations
The list of files to monitor is determined on startup. It doesn't detect added files while running, and emits warning messages for removed files. For example, with a sqlMap file registered to a sqlMapConfig file, it is not monitored but those changes work when refreshed.
Requirements
iBATIS sqlmap 2.3.0, Java 1.4, Spring 2.5+
or
iBATIS sqlmap 2.3.2+, Java 1.5+, Spring 2.5.5+
Installation
1. replace SqlMapClientFactoryBean with newly created RefreshableSqlMapClientFactoryBean in applicationContext configuration file
2. specify modification detection check interval in milliseconds.
3. add backport-util-concurrent-3.1.jar to classpath.
configuration example
<bean id="sqlMapClient" class="jcf.dao.ibatis.sqlmap.RefreshableSqlMapClientFactoryBean">
<property name="configLocation" value="classpath:jcf/dao/ibatis/sqlmap/sqlmap-config.xml" />
<property name="dataSource" ref="dataSource" />
<!-- Java 1.5 or higher and iBATIS 2.3.2 or higher REQUIRED -->
<property name="mappingLocations" value="jcf/dao/\*\*\/T\*.xml" />
<!-- <property name="mappingLocations" value="file:///D:/Type.xml" />-->
<property name="configLocation" value="classpath:jcf/dao/ibatis/sqlmap/sqlmap-config.xml" />
<property name="dataSource" ref="dataSource" />
<!-- Java 1.5 or higher and iBATIS 2.3.2 or higher REQUIRED -->
<property name="mappingLocations" value="jcf/dao/\*\*\/T\*.xml" />
<!-- <property name="mappingLocations" value="file:///D:/Type.xml" />-->
<property name="checkInterval" value="1000" />
</bean>
</bean>








2009/10/05 01:31




2009/06/22 18:38
ibatis


1.7로 업그레이드.
Automatically reloading iBATI...
