FileDocCategorySizeDatePackage
OptimizerFactory.javaAPI DocHibernate 3.2.55731Thu Mar 15 04:33:16 GMT 2007org.hibernate.id.enhanced

OptimizerFactory

public class OptimizerFactory extends Object
Factory for {@link Optimizer} instances.
author
Steve Ebersole

Fields Summary
private static final Log
log
public static final String
NONE
public static final String
HILO
public static final String
POOL
private static Class[]
CTOR_SIG
Constructors Summary
Methods Summary
public static OptimizerbuildOptimizer(java.lang.String type, java.lang.Class returnClass, int incrementSize)


	         
		String optimizerClassName;
		if ( NONE.equals( type ) ) {
			optimizerClassName = NoopOptimizer.class.getName();
		}
		else if ( HILO.equals( type ) ) {
			optimizerClassName = HiLoOptimizer.class.getName();
		}
		else if ( POOL.equals( type ) ) {
			optimizerClassName = PooledOptimizer.class.getName();
		}
		else {
			optimizerClassName = type;
		}

		try {
			Class optimizerClass = ReflectHelper.classForName( optimizerClassName );
			Constructor ctor = optimizerClass.getConstructor( CTOR_SIG );
			return ( Optimizer ) ctor.newInstance( new Object[] { returnClass, new Integer( incrementSize ) } );
		}
		catch( Throwable ignore ) {
			// intentionally empty
		}

		// the default...
		return new NoopOptimizer( returnClass, incrementSize );