try {
clazz = ClassLoaderUtils.loadClass(impl, getClass());
object = clazz.newInstance();
target = object;
} catch (ClassNotFoundException e) {
throw new DatabindingException("Could not find implementation class " + impl
+ " for class " + clazz.getName());
}
}
} else if (isException) {
object = createFromFault(context);
target = object;
} else {
object = clazz.newInstance();
target = object;
}
// Read attributes
while (reader.hasMoreAttributeReaders()) {
MessageReader childReader = reader.getNextAttributeReader();
QName name = childReader.getName();
Type type = inf.getType(name);
if (type != null) {
Object writeObj = type.readObject(childReader, context);
writeProperty(name, target, writeObj, clazz, inf);
}
}
// Read child elements
while (reader.hasMoreElementReaders()) {
MessageReader childReader = reader.getNextElementReader();
QName name = childReader.getName();
// Find the BeanTypeInfo that contains a property for the element name
BeanTypeInfo propertyTypeInfo = getBeanTypeInfoWithProperty(name);
// Get the Type for the property
Type type = getElementType(name, propertyTypeInfo, childReader, context);
if (type != null) {
if (!childReader.isXsiNil()) {
Object writeObj = type.readObject(childReader, context);
writeProperty(name, target, writeObj, clazz, propertyTypeInfo);
} else {
if (!propertyTypeInfo.isNillable(name)) {
throw new DatabindingException(name.getLocalPart()
+ " is nil, but not nillable.");
}
childReader.readToEnd();
}
} else {
childReader.readToEnd();
}
}
return object;
} catch (IllegalAccessException e) {
throw new DatabindingException("Illegal access. " + e.getMessage(), e);
} catch (InstantiationException e) {
throw new DatabindingException("Couldn't instantiate class. " + e.getMessage(), e);
} catch (SecurityException e) {
throw new DatabindingException("Illegal access. " + e.getMessage(), e);
} catch (IllegalArgumentException e) {
throw new DatabindingException("Illegal argument. " + e.getMessage(), e);
} catch (InvocationTargetException e) {
throw new DatabindingException("Could not create class: " + e.getMessage(), e);
}
}