Search in sources :

Example 1 with ServiceClassLoader

use of nl.nn.adapterframework.configuration.classloaders.ServiceClassLoader 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;
}
Also used : DirectoryClassLoader(nl.nn.adapterframework.configuration.classloaders.DirectoryClassLoader) ServiceClassLoader(nl.nn.adapterframework.configuration.classloaders.ServiceClassLoader) DatabaseClassLoader(nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader) JarFileClassLoader(nl.nn.adapterframework.configuration.classloaders.JarFileClassLoader) DirectoryClassLoader(nl.nn.adapterframework.configuration.classloaders.DirectoryClassLoader) ServiceClassLoader(nl.nn.adapterframework.configuration.classloaders.ServiceClassLoader) DummyClassLoader(nl.nn.adapterframework.configuration.classloaders.DummyClassLoader) JarFileClassLoader(nl.nn.adapterframework.configuration.classloaders.JarFileClassLoader) BasePathClassLoader(nl.nn.adapterframework.configuration.classloaders.BasePathClassLoader) DatabaseClassLoader(nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader) DummyClassLoader(nl.nn.adapterframework.configuration.classloaders.DummyClassLoader)

Aggregations

BasePathClassLoader (nl.nn.adapterframework.configuration.classloaders.BasePathClassLoader)1 DatabaseClassLoader (nl.nn.adapterframework.configuration.classloaders.DatabaseClassLoader)1 DirectoryClassLoader (nl.nn.adapterframework.configuration.classloaders.DirectoryClassLoader)1 DummyClassLoader (nl.nn.adapterframework.configuration.classloaders.DummyClassLoader)1 JarFileClassLoader (nl.nn.adapterframework.configuration.classloaders.JarFileClassLoader)1 ServiceClassLoader (nl.nn.adapterframework.configuration.classloaders.ServiceClassLoader)1