use of nl.nn.adapterframework.configuration.classloaders.JarFileClassLoader in project iaf by ibissource.
the class ClassLoaderManager method createClassloader.
private ClassLoader createClassloader(String configurationName, String configurationFile, ClassLoader parentClassLoader) throws ConfigurationException {
String classLoaderType = APP_CONSTANTS.getResolvedProperty("configurations." + configurationName + ".classLoaderType");
ClassLoader classLoader = null;
if ("DirectoryClassLoader".equals(classLoaderType)) {
String directory = APP_CONSTANTS.getResolvedProperty("configurations." + configurationName + ".directory");
classLoader = new DirectoryClassLoader(directory, parentClassLoader);
} else if ("JarFileClassLoader".equals(classLoaderType)) {
String jar = APP_CONSTANTS.getResolvedProperty("configurations." + configurationName + ".jar");
classLoader = new JarFileClassLoader(jar, configurationName, parentClassLoader);
} else if ("ServiceClassLoader".equals(classLoaderType)) {
String adapterName = APP_CONSTANTS.getResolvedProperty("configurations." + configurationName + ".adapterName");
classLoader = new ServiceClassLoader(ibisManager, adapterName, configurationName, parentClassLoader);
} else if ("DatabaseClassLoader".equals(classLoaderType)) {
try {
classLoader = new DatabaseClassLoader(ibisContext, configurationName, parentClassLoader);
} catch (ConfigurationException ce) {
String configNotFoundReportLevel = APP_CONSTANTS.getString("configurations." + configurationName + ".configNotFoundReportLevel", "ERROR").toUpperCase();
String msg = "Could not get config '" + configurationName + "' from database, skipping";
if (configNotFoundReportLevel.equals("DEBUG")) {
LOG.debug(msg);
} else if (configNotFoundReportLevel.equals("INFO")) {
ibisContext.log(msg);
} else if (configNotFoundReportLevel.equals("WARN")) {
ConfigurationWarnings.getInstance().add(LOG, msg);
} else {
if (!configNotFoundReportLevel.equals("ERROR"))
ConfigurationWarnings.getInstance().add(LOG, "Invalid configNotFoundReportLevel [" + configNotFoundReportLevel + "], using default [ERROR]");
throw ce;
}
// Break here, we cannot continue when there are ConfigurationExceptions!
return null;
}
} else if ("DummyClassLoader".equals(classLoaderType)) {
classLoader = new DummyClassLoader(configurationName, configurationFile);
} else if (classLoaderType != null) {
throw new ConfigurationException("Invalid classLoaderType: " + classLoaderType);
}
// It is possible that no classloader has been defined, use default contextClassloader.
if (classLoader == null) {
classLoader = parentClassLoader;
}
LOG.debug(configurationName + " created classloader [" + classLoader.getClass().getSimpleName() + "]");
return classLoader;
}
Aggregations