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

org.infinispan.factories.ResponseGeneratorFactory 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.remoting.responses.DefaultResponseGenerator;
import org.infinispan.remoting.responses.DistributionResponseGenerator;
import org.infinispan.remoting.responses.NoReturnValuesDistributionResponseGenerator;
import org.infinispan.remoting.responses.ResponseGenerator;

/**
 * Creates a ResponseGenerator
 *
 * @author Manik Surtani
 * @since 4.0
 */
@DefaultFactoryFor(classes = ResponseGenerator.class)
public class ResponseGeneratorFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {

   @Override
   @SuppressWarnings("unchecked")
   public  T construct(Class componentType) {
      if (configuration.clustering().cacheMode().isDistributed() || configuration.clustering().cacheMode().isReplicated()) {
         if (configuration.unsafe().unreliableReturnValues() && configuration.transaction().transactionMode().isTransactional())
            return (T) new NoReturnValuesDistributionResponseGenerator();
         else
            //distributed non-transactional caches require the response value
            return (T) new DistributionResponseGenerator();
      } else
         return (T) new DefaultResponseGenerator();
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy