Factorize adapter common logic.