package org.apache.struts.config;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.util.RequestUtils;

public abstract class ModuleConfigFactory {
  public abstract ModuleConfig createModuleConfig(String paramString);
  
  public static String getFactoryClass() {
    return factoryClass;
  }
  
  public static void setFactoryClass(String factoryClass) {
    ModuleConfigFactory.factoryClass = factoryClass;
    clazz = null;
  }
  
  public static ModuleConfigFactory createFactory() {
    try {
      if (clazz == null)
        clazz = RequestUtils.applicationClass(factoryClass); 
      ModuleConfigFactory factory = clazz.newInstance();
      return factory;
    } catch (Throwable t) {
      LOG.error("ModuleConfigFactory.createFactory", t);
      return null;
    } 
  }
  
  protected static Class clazz = null;
  
  private static Log LOG = LogFactory.getLog(ModuleConfigFactory.class);
  
  protected static String factoryClass = "org.apache.struts.config.impl.DefaultModuleConfigFactory";
}
