JCF TEAM BLOG

관리자 글쓰기
블로그 »
Though iBATIS is one of a very popular ORM framework, it has some irritatating problems that every developers have suffered for a long time. Whenever sqlMap file is modified, one should undergo the tedious process of restarting the application so that the modifications actually take effect.
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="checkInterval" value="1000" /> 
</bean>

크리에이티브 커먼즈 라이센스
Creative Commons License
Writer profile
author image
setq
2009/06/22 18:38 2009/06/22 18:38

(go to top)