@SuppressWarnings("unchecked")
public ScopeKey getScope()
{
// THIS IS A HACK - the scope originally gets initialise with a class name, we fix it to have the class
ScopeKey key = super.getScope();
Scope scope = key.getScope(CommonLevels.CLASS);
if (scope == null)
return key;
Object qualifier = scope.getQualifier();
if (qualifier instanceof Class)
return key;
String className = (String) qualifier;
ClassLoader cl;
try
{
cl = Configurator.getClassLoader(beanMetaData);
}
catch (Throwable t)
{
throw new RuntimeException("Error getting classloader for " + key, t);
}
Class<?> clazz;
try
{
clazz = Class.forName(className, false, cl);
}
catch (ClassNotFoundException e)
{
throw new RuntimeException("Unable to load class: " + className + " for " + key, e);
}
key.addScope(new Scope(CommonLevels.CLASS, clazz));
return key;
}