TxAttributeCustomizerã§ã®ç¹å®ä¾å¤ãã³ãããå¦çã«ããã
TxAttributeCustomizerãè¨å®ããå ´åãä¾å¤ã¯ãã¹ã¦ã³ãããå¦çãããã¿ããã§ãã
j2ee.requiredTxçã®ã³ã³ãã¼ãã³ãã使ã£ã¦è¨å®ããå ´åã¯ã³ãããããã»ããªããæ示çã«è¨å®ã§ãããã©ãã©ããTxAttributeCustomizerã«ã¯addCommitRule()ãaddRollbackRule()ã¡ã½ããããªãã®ã§ãããã£ãè¨å®ã¯ã§ããªãã¿ããã
ãã©ã³ã¶ã¯ã·ã§ã³å¶å¾¡ãæ示çã«ããããå ´åã¯UserTransactionã使ãã°ã§ãããã ãã©ãããç¨åº¦ã®ä¸å¾ã«å¯¾å¦ãããå ´åã¯ã©ãããããããã
åéããã¦ã¾ãããTxAttributeCustomizerã¯ããã¾ã§ãEJB3 ã® @TransactionAttribute ã¢ããã¼ã·ã§ã³ãå©ç¨å¯è½ããããã ãã§ã¢ããã¼ã·ã§ã³ããªãå ´åã¯ããã©ã«ãã§j2ee.requiredTxãé©ç¨ãããã¨ãããã¨ã
ã¨ãããã¨ã¯çµå±j2ee.requiredTxãé©ç¨ãããã®ã§ããã¾ã§éãdiconã«ã³ã³ãã¼ãã³ããaddCommitRuleãaddRollbackRuleãè¨å®ãã¦åå®ç¾©ããã°ä¾å¤æ¯ã«å¦çãå¤æ´ã§ãã¾ãã
j2ee.diconããã®ã¾ã¾ã³ãã¼ãã¦ä»»æã®åå(app-j2ee.diconã¨ã)ã«ããaddCommitRuleãaddRollbackRuleãè¨å®ãã¾ãã
@example.exception.HogeException@class
ã§ãapp.diconã§includeãã¦ããj2ee.diconãä¸ã§æå®ããååã®diconã«å¤æ´ããã¨ãã¾ãããã¾ãã
éè¦ãªã®ã¯namespaceãj2eeã§è¨å®ãããã¨ãTxAttributeCustomizerãããããã¿ã¦ãªãã®ã§ã
ã¡ãªã¿ã«UserTransactionãç´æ¥ä½¿ãã¨ã¢ããã¼ã·ã§ã³ã®è¨å®ãç¡è¦ãã¦ãã©ã³ã¶ã¯ã·ã§ã³å¶å¾¡ãã§ãã¾ãããããªäºããããããã©ããã¯å¥ã§ããã»ã»ã»
@TransactionAttribute(TransactionAttributeType.NEVER)
public String index() throws Exception {
userTransaction.begin();
userTransaction.commit();
return null;
}