{
// Abstract class, so we need an implementation
ClassMetaData cmd = (ClassMetaData)mmgr.getMetaDataForClass(cls, clr);
if (cmd == null)
{
throw new JDOFatalException("Could not find metadata for class " + cls.getName());
}
Object obj = newInstance(cmd, clr);
if (!mmgr.hasMetaDataForClass(obj.getClass().getName()))
{
// No metadata yet present for the implementation so register it
mmgr.registerImplementationOfAbstractClass(cmd, obj.getClass(), clr);
}
if (obj == null)
{
throw new JDOFatalException(LOCALISER.msg("ImplementationCreator.InstanceCreateFailed", cls.getName()));
}
return obj;
}
else
{
// Concrete class that is PC so just create an instance using its no args constructor
return cls.newInstance();
}
}
else
{
// Interface, so we need an implemenation
InterfaceMetaData imd = mmgr.getMetaDataForInterface(cls, clr);
if (imd == null)
{
throw new JDOFatalException("Could not find metadata for class/interface "+cls.getName());
}
Object obj = newInstance(imd, clr);
if (!mmgr.hasMetaDataForClass(obj.getClass().getName()))
{
// No metadata yet present for the implementation so register it
mmgr.registerPersistentInterface(imd, obj.getClass(), clr);
}
if (obj == null)
{
throw new JDOFatalException(LOCALISER.msg("ImplementationCreator.InstanceCreateFailed", cls.getName()));
}
return obj;
}
}
catch (ClassNotFoundException e)