All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openl.rules.project.instantiation.SharedClassLoader Maven / Gradle / Ivy

package org.openl.rules.project.instantiation;

import java.util.ArrayList;
import java.util.List;

public class SharedClassLoader extends ClassLoader {

    private List classLoaders = new ArrayList();

    public SharedClassLoader(ClassLoader parent) {
        super(parent);
    }
    
    public void addClassLoader(ClassLoader classLoader) {
        classLoaders.add(classLoader);
    }

    public void removeClassLoader(ClassLoader classLoader) {
        classLoaders.remove(classLoader);
    }

    @Override
    protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
        
        for (ClassLoader loader : classLoaders) {
            try {
                Class loadedClass = loader.loadClass(name);
                if (loadedClass != null) {
                    return loadedClass;
                }
            } catch (ClassNotFoundException ex) {
            }
        }

        return super.loadClass(name, resolve);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy