Coordination getTopCoordination()

in jpa-support/src/main/java/org/apache/aries/jpa/support/impl/EMSupplierImpl.java [130:146]


    Coordination getTopCoordination() {
        // In normal situation, There should be TxInterceptor and JpaInterceptor
        Coordination coordination = coordinator.peek();
        while (coordination != null && coordination.getEnclosingCoordination() != null) {
            coordination = coordination.getEnclosingCoordination();
            if (coordination != null) {
                String transaction = (String) coordination.getVariables().get(Transaction.class);
                if (transaction != null) {
                    // ARIES-2050: transaction-blueprint doesn't always create new coordination (for example
                    // when calling REQUIRED -> REQUIRED annotated methods. And we can assume the "new" behavior
                    // when the Transaction.class attribute is not null (it matches one of the 6 TX behaviors)
                    return coordination;
                }
            }
        }
        return coordination;
    }