All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.factories.TransactionSynchronizationRegistryFactory Maven / Gradle / Ivy

package org.infinispan.factories;

import org.infinispan.commons.CacheConfigurationException;
import org.infinispan.factories.annotations.DefaultFactoryFor;
import org.infinispan.transaction.lookup.TransactionSynchronizationRegistryLookup;

import javax.transaction.TransactionSynchronizationRegistry;

/**
 * Factory for the TransactionSynchronizationRegistry
 *
 * @author Stuart Douglas
 */
@DefaultFactoryFor(classes = {TransactionSynchronizationRegistry.class})
public class TransactionSynchronizationRegistryFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {

   @Override
   public  T construct(Class componentType) {
      // See if we had a TransactionSynchronizationRegistry injected into our config
      TransactionSynchronizationRegistryLookup lookup = configuration.transaction().transactionSynchronizationRegistryLookup();

      try {
         if (lookup != null) {
            return componentType.cast(lookup.getTransactionSynchronizationRegistry());
         }
      }
      catch (Exception e) {
         throw new CacheConfigurationException("failed obtaining TransactionSynchronizationRegistry", e);
      }
      return null;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy