private static synchronized Realm doInstantiate(String name, String className,
Properties props)
throws BadRealmException
{
Habitat habitat = Globals.getDefaultHabitat();
RealmsManager mgr = null;
try {
mgr = getRealmsManager();
Class realmClass = null;
//try a HK2 route first
Realm r = habitat.getComponent(Realm.class, name);
if (r == null) {
try {
//TODO: workaround here. Once fixed in V3 we should be able to use
//Context ClassLoader instead.
ClassLoaderHierarchy hierarchy =
habitat.getComponent(ClassLoaderHierarchy.class);
realmClass = hierarchy.getCommonClassLoader().loadClass(className);
Object obj = realmClass.newInstance();
r = (Realm) obj;
} catch (ClassNotFoundException ex) {
realmClass = Class.forName(className);