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を継承している)

  1. JmsSessionFactoryImplクラスcreateQueueSessionメソッド
  2. JmsSessionFactoryImplクラスallocateConnectionメソッド
  3. BaseConnectionManager2$ConnectionManagerProxyクラスのallocateConnectionメソッド
  4. BaseConnectionManager2クラスのallocateConnectionメソッド
  5. TxConnectionManagerクラスのmanagedConnectionReconnectedメソッド
  6. TxConnectionManager$TxConnectionEventListenerクラスのenlistメソッド
  7. TransactionImplクラスのenlistResourceメソッド

こんな感じでTransactionImplへのXAResourceの追加にいたる.