package instantiation;

import org.apache.ojb.broker.util.factory.ConfigurableFactory;

/**
 * @author tal
 *
 */
public class InstantiationFactory extends ConfigurableFactory {
	private static InstantiationFactory instance = null;
	
    private Instantiation INSTANTIATION = null;
    
    public static InstantiationFactory getInstance() {
    	if (instance == null) {
    		instance = new InstantiationFactory();
    	}
    	
    	return instance;	
    }

    public Instantiation getInstantiation() {
        if (INSTANTIATION == null) {
            synchronized(this) {
				try	{
					INSTANTIATION = (Instantiation) this.createNewInstance();
				} catch (Exception e) {
					INSTANTIATION = new InstantiationDefaultImpl();
				}
            }
        }
        
        return INSTANTIATION;
    }

	/**
	 * @see org.apache.ojb.broker.util.factory.ConfigurableFactory#getConfigurationKey()
	 */
	protected String getConfigurationKey() {
		return "instantiationFactory";
	}
}
