Javaã®ã³ãã¯ã·ã§ã³ãã¼ãªã³ã°ã®ä»çµã¿
Javaã®ã³ãã¯ã·ã§ã³ãã¼ãªã³ã°ãã©ã®ãããªä»çµã¿ã«ãªã£ã¦ããã®ããç¥ããªã人ã¯çµæ§å¤ãããããªããã¨æãã¾ãã
Slim3ã®ã³ãã¯ã·ã§ã³ãã¼ãªã³ã°ã®å®è£
ãè¦ãã¨ããã®è¾ºãç解ã§ããããã«ãªãã¾ãããã©ã³ã¶ã¯ã·ã§ã³ã¨ã³ãã¯ã·ã§ã³ãã¼ãªã³ã°ãã©ã®ããã«é£æºãã¦ããããææ¡ãããã¨ã¯éè¦ã§ãã
http://svn.slim3.org/browse/trunk/slim3/slim3-datasource/src/main/java/org/slim3/datasource/
ç»å ´äººç©ã¯ã4人ããããªãããç°¡åã§ããã
æåã«è¦ã¦æ¬²ããã®ã¯ãConnectionWrapperãDataSource.getConnection()ããã¨ãã«æ»ãããã³ãã¯ã·ã§ã³ã®å®æ
ã§ãããã®ã³ãã¯ã·ã§ã³ãè«ççãªã³ãã¯ã·ã§ã³ã¨å¼ã¶ããã«ãã¾ãã
主ãªå½¹å²ã¯ãã³ãã¯ã·ã§ã³ãã¯ãã¼ãºãããã¨ãã«ãã³ãã¯ã·ã§ã³ããã¼ã«ã«è¿ããã¨ããã¼ã«ã«è¿ãããã³ãã¯ã·ã§ã³ã¯ãç©ççãª(DriverManagerããåå¾ããã)Connectionã§ã¯ãªããXAConnectionã«ãªãã¾ãã
XAConnectionImplãXAConnectionã®å®è£
ã¯ã©ã¹ã§ãã
ãã¤ã³ãã¯ãã³ãã¯ã·ã§ã³ãã¯ãã¼ãºãããã¨ã(notifyConnectionClosedã¡ã½ãããå¼ã³åºãããã¨ã)ã«ãConnectionEventListener#connectionClosed()ãå¼ã³åºããã¨ã
ã³ãã¯ã·ã§ã³ãã¼ãªã³ã°ãå®è£
ãã¦ããã¯ã©ã¹ã¯ãConnectionEventListenerã¤ã³ã¿ã¼ãã§ã¼ã¹ãå®è£
ãã¦ãã¯ãã¼ãºãããã¨ãã«ãXAConnectionããã¼ã«ã«æ»ãã¾ãã
ããä¸ã¤ã®ãã¤ã³ãããXAResourceã®å®è£
ãªãã¸ã§ã¯ããæã£ã¦ãããã¨ããã®XAResourceã¯ããã©ã³ã¶ã¯ã·ã§ã³ã«ç»é²ãããcommitãrollbackã®æã«å¼ã³åºããã¾ãã
XAResourceImplãXAResourceã®å®è£
ã¯ã©ã¹ã§ãã
ãã¤ã³ãã¯ãstart,commit, rollbackã¡ã½ããã
startã¡ã½ããã¯ããã®ãªãã¸ã§ã¯ãããã©ã³ã¶ã¯ã·ã§ã³ã«ç»é²ãããã¨ãã«å¼ã³åºããã¾ãããã®ã¨ãã«ãã£ã¦ããã®ã¯ãç©ççãªConnectionã®autoCommitãfalseã«ãããã¨ã
commitãrollbackã¡ã½ããã¯ããã©ã³ã¶ã¯ã·ã§ã³ãcommit,rollbackããã¿ã¤ãã³ã°ã§å¼ã³åºããã¾ãããã£ã¦ãããã¨ã¯ãç©ççãªConnectionã®commit,rollbackã¡ã½ãããå¼ã³åºããå¾ã«ãautoCommitãtrueã«ãã©ããã¨ã§ãã
ãã®XAResourceImplã«ãã£ã¦ããã©ã³ã¶ã¯ã·ã§ã³ã¨ã³ãã¯ã·ã§ã³ãé£åãã¦ããã®ã§ãã
æå¾ããXADataSourceImplãã³ãã¯ã·ã§ã³ãã¼ã«ã®å®è£
ã§ãã
getConnection,getXAConnectionãæåã«èªãã¨ããã§ããããã³ãã¯ã·ã§ã³ããã¼ã«ããåãåºãé¨åãç解ã§ãã¾ãã
connectionClosedã¡ã½ããã¯ãConnectionEventListenerã®ã¡ã½ããã§ãããã§XAConnectionããã¼ã«ã«æ»ãã¦ãã¾ãã
以ä¸ã§ãã³ãã¯ã·ã§ã³ãã¼ãªã³ã°ã®ä»çµã¿ã®èª¬æã¯ããã¾ãããããªã«é£ãããªãã£ãã§ãããã¤ã³ã¿ã¼ãã«ãªä»çµã¿ãç解ããã®ã¯æ¥½ããããã
ããã§ãSeasar2ã«ç¸å½ããé¨åã®å®è£
ã¯å®äºããããããSAStrutsãSlim3ã«ç§»æ¤ãã¾ãã