package jas2.loader;

/**
 * A Classloader that first tries to delegate loading to another ClassLoader, and if that
 * fails tries to load a class using its own ClassPath.
 */
public class DelegateLoader extends ClassPathLoader
{
	/**
	 * A ClassLoader which first delegates loading to another ClassPathLoader and only
	 * if that loader fails to load a class will load it itself
	 * @delegateLoader The loader to delegate to
	 * @path The path this loader will use
	 * @name This loaders name (for debugging)
	 */
	public DelegateLoader(ClassPathLoader delegateLoader, ClassPath path, String name)
	{
		super(path,name);
		m_delegate = delegateLoader;
	}
	public Class loadClass(String name, boolean resolve) throws ClassNotFoundException
	{
		try
		{
			return m_delegate.loadClass(name,resolve);
		}
		catch (ClassNotFoundException x)
		{
			
			return super.loadClass(name,resolve);
		}
	}
	private ClassPathLoader m_delegate;
}

 

Ads help maintain this website.