return repository.loadClassBefore(this, name);
}
protected Class findClass(String name) throws ClassNotFoundException
{
Logger logger = getLogger();
boolean trace = logger.isEnabledFor(Logger.TRACE);
// It may be possible that loading started with this MLet, then delegated to the CLR
// and came again to query this MLet which, if not stopped, will delegate to the CLR
// again in an endless loop. This is possible if this MLet is the parent of a child
// MLet registered before its parent.
if (loadingWithRepository.get() == Boolean.TRUE)
{
if (trace) logger.trace("MLet " + this + " is recursively calling itself to load class " + name + ": skipping further searches");
throw new ClassNotFoundException(name);
}
if (trace) logger.trace("Finding class " + name + "...");
try
{
Class cls = findClassLocally(name);
if (trace) logger.trace("Class " + name + " found in this MLet's classpath " + this);
return cls;
}
catch (ClassNotFoundException x)
{
if (!isDelegateToCLR())
{
if (trace) logger.trace("MLet " + this + " does not delegate to the ClassLoaderRepository");
throw x;
}
if (loadingOnlyLocally.get() == Boolean.TRUE) throw x;
if (server == null) throw x;
if (trace) logger.trace("Class " + name + " not found in this MLet's classpath " + this + ", trying the ClassLoaderRepository...", x);
try
{
loadingWithRepository.set(Boolean.TRUE);
ClassLoaderRepository repository = server.getClassLoaderRepository();
Class cls = loadClassFromRepository(name, repository);
if (trace) logger.trace("Class " + name + " found with ClassLoaderRepository " + repository);
return cls;
}
catch (ClassNotFoundException xx)
{
if (trace) logger.trace("Class " + name + " not found in ClassLoaderRepository, giving up", xx);
throw new ClassNotFoundException(name);
}
finally
{
loadingWithRepository.set(Boolean.FALSE);