throws Exception
{
// Use the class load that loaded the ModelImpl class as parent class loader of the model.
ClassLoader parentClassLoader = model.getClass().getClassLoader();
XClassLoaderConfiguration config = new XClassLoaderConfiguration();
addClassesDir(config, model, ModelLocationUtil.DIR_CLASSES);
addLibDir(config, model, ModelLocationUtil.DIR_LIB);
addLibDir(config, model, ModelLocationUtil.DIR_EXTLIB);
if (config.getRepositories().size() == 0)
{
// Nothing in repository, so use regular CL
return parentClassLoader;
}
// Set the name of the class loader.
String qualifier = model.getQualifier().toString();
qualifier = qualifier.replace(ModelQualifier.PATH_DELIMITER_CHAR, '.');
config.setName("Model" + qualifier);
config.setParentClassLoader(parentClassLoader);
// Create a class loader for this model
return new ModelClassLoader(config, model);
}