SequencingCallbackImpl getCallbackImpl(AbstractSession writeSession, Accessor accessor) { SequencingCallbackImpl seqCallbackImpl; if (writeSession.hasExternalTransactionController()) { // note that controller obtained from writeSession (not from ownerSession) - // the difference is important in case of ownerSession being a member of SessionBroker: // in that case only writeSession (which is either ClientSession or DatabaseSession) always // has // the correct controller. seqCallbackImpl = (SequencingCallbackImpl) writeSession .getExternalTransactionController() .getActiveSequencingCallback(getOwnerSession(), getSequencingCallbackFactory()); } else { seqCallbackImpl = (SequencingCallbackImpl) accessor.getSequencingCallback(getSequencingCallbackFactory()); } return seqCallbackImpl; }