*/
protected AbstractComponentFactory getFactory(Class componentClass) {
Map<Class, Class<? extends AbstractComponentFactory>> defaultFactoryMap = getDefaultFactoryMap();
Class<? extends AbstractComponentFactory> cfClass = defaultFactoryMap.get(componentClass);
if (cfClass == null)
throw new ConfigurationException("No registered default factory for component '" + componentClass + "' found! Debug stack: " + debugStack);
// a component factory is a component too! See if one has been created and exists in the registry
AbstractComponentFactory cf = getComponent(cfClass);
if (cf == null) {
// hasn't yet been created. Create and put in registry
cf = instantiateFactory(cfClass);
if (cf == null)
throw new ConfigurationException("Unable to locate component factory for component " + componentClass + " Debug stack: " + debugStack);
// we simply register this factory. Registration will take care of constructing any dependencies.
registerComponent(cf, cfClass);
}
// ensure the component factory is in the STARTED state!
Component c = lookupComponent(cfClass, cfClass.getName());
if (c.instance != cf)
throw new ConfigurationException("Component factory " + cfClass + " incorrectly registered! Debug stack: " + debugStack);
return cf;
}