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

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

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.factories;

import org.infinispan.factories.annotations.DefaultFactoryFor;
import org.infinispan.util.concurrent.locks.DeadlockDetectingLockManager;
import org.infinispan.util.concurrent.locks.LockManager;
import org.infinispan.util.concurrent.locks.PendingLockManager;
import org.infinispan.util.concurrent.locks.impl.DefaultLockManager;
import org.infinispan.util.concurrent.locks.impl.DefaultPendingLockManager;
import org.infinispan.util.concurrent.locks.impl.NoOpPendingLockManager;

/**
 * Factory class that creates instances of {@link LockManager}.
 *
 * @author Manik Surtani ([email protected])
 * @since 4.0
 */
@DefaultFactoryFor(classes = {LockManager.class, PendingLockManager.class} )
public class LockManagerFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {

   @Override
   public  T construct(Class componentType) {
      if (PendingLockManager.class.equals(componentType)) {
         return componentType.cast(configuration.clustering().cacheMode().isClustered() ?
                                         new DefaultPendingLockManager() :
                                         NoOpPendingLockManager.getInstance());
      } else if (LockManager.class.equals(componentType)) {
         return componentType.cast(configuration.deadlockDetection().enabled() ?
                                         new DeadlockDetectingLockManager() :
                                         new DefaultLockManager());
      }
      throw new IllegalArgumentException("Unexpected component type " + componentType + ".");
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy