Example usage for org.springframework.transaction.support TransactionSynchronization getClass

List of usage examples for org.springframework.transaction.support TransactionSynchronization getClass

Introduction

In this page you can find the example usage for org.springframework.transaction.support TransactionSynchronization getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.motechproject.server.omod.sdsched.TxSyncManWrapperImpl.java

@SuppressWarnings("unchecked")
public boolean containsSynchronization(Class<? extends TransactionSynchronization> syncClass) {

    if (isSynchronizationActive()) {
        List<TransactionSynchronization> syncs = (List<TransactionSynchronization>) TransactionSynchronizationManager
                .getSynchronizations();// w w w .j  a  v  a  2s.co m

        for (TransactionSynchronization sync : syncs)
            if (syncClass.isAssignableFrom(sync.getClass()))
                return true;
    }

    return false;
}

From source file:org.mybatis.spring.asyncsynchronization.AsyncAfterCompletionHelper.java

/**
 * Creates proxy that performs afterCompletion call on a separate thread
 * // ww  w . j  ava 2  s . c om
 * @param synchronization
 * @return
 */
public TransactionSynchronization createSynchronizationWithAsyncAfterComplete(
        TransactionSynchronization synchronization) {
    if (Proxy.isProxyClass(synchronization.getClass())
            && Proxy.getInvocationHandler(synchronization) instanceof AsynchAfterCompletionInvocationHandler) {
        // avoiding double wrapping just in case
        return synchronization;
    }
    Class<?>[] interfaces = { TransactionSynchronization.class };
    return (TransactionSynchronization) Proxy.newProxyInstance(synchronization.getClass().getClassLoader(),
            interfaces, new AsynchAfterCompletionInvocationHandler(synchronization));

}