* @throws MappingException
* in case that the name is null or the Class can not be loaded
*/
public void addClass(final Class cls, final boolean deep) throws MappingException {
if (cls == null) {
throw new MappingException("Cannot introspect a null class.");
}
if (_mappings.get(cls) != null) {
return;
}
if (cls.isArray()) {
Class cType = cls.getComponentType();
if (_mappings.get(cType) != null) {
return;
}
if (Types.isSimpleType(cType)) {
return;
}
// -- handle component type
addClass(cType);
}
if (_forceIntrospection && (!Types.isConstructable(cls))) {
throw new MappingException("mapping.classNotConstructable", cls.getName());
}
XMLClassDescriptor xmlClass;
FieldDescriptor[] fields;
ClassMapping classMap;
FieldMapping fieldMap;
boolean introspected = false;
try {
if (_forceIntrospection) {
xmlClass = _internalContext.getIntrospector().generateClassDescriptor(cls);
introspected = true;
} else {
xmlClass = (XMLClassDescriptor) _internalContext.getXMLClassDescriptorResolver().resolve(cls);
introspected = _internalContext.getIntrospector().introspected(xmlClass);
}
} catch (Exception except) {
throw new MappingException(except);
}
classMap = new ClassMapping();
classMap.setName(cls.getName());
classMap.setDescription("Default mapping for class " + cls.getName());