TX その24 XAResourceとの関係をJMSを例にとって考えてみる
JCA関連のソースを読んでいると全く不慣れなので非常に混乱する.とりあえず仕様解説本読め,という感じだがいま手元に無いので分かるところから.
JMSを例にとって考えてみる.
アプリ側では,以下のようなコードでQueueSessionを取得する.
InitialContext ctx = new InitialContext(); QueueConnectionFactory qcf = (QueueConnectionFactory) PortableRemoteObject.narrow( ctx.lookup(Const.MQSOURCE), QueueConnectionFactory.class); QueueConnection qc = qcf.createQueueConnection(); QueueSession qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
4行目のQueueConnection.createQueueSessionメソッドは,JBossXAだとJmsSessionFactoryImpl.createQueueSessionメソッド.(JmsSessionFactoryインタフェースはQueueConnectionを継承している)
- JmsSessionFactoryImplクラスcreateQueueSessionメソッド
- JmsSessionFactoryImplクラスallocateConnectionメソッド
- BaseConnectionManager2$ConnectionManagerProxyクラスのallocateConnectionメソッド
- BaseConnectionManager2クラスのallocateConnectionメソッド
- TxConnectionManagerクラスのmanagedConnectionReconnectedメソッド
- TxConnectionManager$TxConnectionEventListenerクラスのenlistメソッド
- TransactionImplクラスのenlistResourceメソッド
こんな感じでTransactionImplへのXAResourceの追加にいたる.