package com.sun.identity.plugin.configuration;

import com.sun.identity.common.SystemConfigurationUtil;
import java.lang.reflect.InvocationTargetException;

public final class ConfigurationManager {
   private static final String PROP_CONFIG_IMPL_CLASS = "com.sun.identity.plugin.configuration.class";
   private static final String RESOURCE_BUNDLE = "libConfigurationManager";
   private static final String CONFIG_CLASS = SystemConfigurationUtil.getProperty("com.sun.identity.plugin.configuration.class");

   public static ConfigurationInstance getConfigurationInstance(String componentName) throws ConfigurationException {
      try {
         ConfigurationInstance config = (ConfigurationInstance)Class.forName(CONFIG_CLASS).getDeclaredConstructor().newInstance();
         config.init(componentName, null);
         return config;
      } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException iae) {
         Object[] objs = new Object[]{CONFIG_CLASS};
         throw new ConfigurationException("libConfigurationManager", "FailedCreatingConfigInstance", objs);
      } catch (ClassNotFoundException cnfe) {
         Object[] objs = new Object[]{CONFIG_CLASS};
         throw new ConfigurationException("libConfigurationManager", "ConfigClassNotFound", objs);
      }
   }
}
