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

net.sf.hajdbc.invocation.InvocationStrategies Maven / Gradle / Ivy

There is a newer version: 3.6.61
Show newest version
package net.sf.hajdbc.invocation;

import java.util.SortedMap;

import net.sf.hajdbc.Database;
import net.sf.hajdbc.logging.Level;
import net.sf.hajdbc.logging.Logger;
import net.sf.hajdbc.logging.LoggerFactory;
import net.sf.hajdbc.sql.ProxyFactory;

public enum InvocationStrategies implements InvocationStrategy
{
	INVOKE_ON_ALL(new InvokeOnManyInvocationStrategy(new AllResultsCollector(new StandardExecutorProvider()))),
	INVOKE_ON_ANY(new InvokeOnAnyInvocationStrategy(new InvokeOnOneInvocationStrategy(new NextDatabaseSelector()))),
	INVOKE_ON_EXISTING(new InvokeOnManyInvocationStrategy(new ExistingResultsCollector())),
  INVOKE_ON_NEXT(new InvokeOnOneInvocationStrategy(new NextDatabaseSelector())),
	INVOKE_ON_PRIMARY(new InvokeOnOneInvocationStrategy(new PrimaryDatabaseSelector())),
	TRANSACTION_INVOKE_ON_ALL(new InvokeOnManyInvocationStrategy(new AllResultsCollector(new TransactionalExecutorProvider(false)))),
	END_TRANSACTION_INVOKE_ON_ALL(new InvokeOnManyInvocationStrategy(new AllResultsCollector(new TransactionalExecutorProvider(true)))),
	;
	
	private static final Logger logger = LoggerFactory.getLogger(SimpleInvoker.class);
	
	private final InvocationStrategy strategy;
	
	private InvocationStrategies(InvocationStrategy strategy)
	{
		this.strategy = strategy;
	}
	
	@Override
	public , T, R, E extends Exception> SortedMap invoke(ProxyFactory map, Invoker invoker) throws E
	{
		logger.log(Level.TRACE, "Invoking {0} using {1} strategy.", invoker, this);
		return this.strategy.invoke(map, invoker);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy