* @param classDescriptor
* @param objectFactory
* @return
*/
private JavaType createJAXBType(ClassDescriptor classDescriptor, ObjectFactory objectFactory) {
JavaType javaType = new JavaType();
String alias = classDescriptor.getAlias();
if (alias == null || alias.isEmpty()) {
alias = classDescriptor.getJavaClass().getSimpleName();
}
javaType.setName(alias);
javaType.setJavaAttributes(new JavaAttributes());
boolean isDynamic = DynamicEntity.class.isAssignableFrom(classDescriptor.getJavaClass());
for (DatabaseMapping ormMapping : classDescriptor.getMappings()) {
JAXBElement<XmlElement> element = createJAXBProperty(ormMapping, objectFactory, javaType, isDynamic);
if (element != null) {
javaType.getJavaAttributes().getJavaAttribute().add(element);
}
}
// Embeddables don't need Rest adapters, return if the classDescriptor is an aggregate descriptor.
if (classDescriptor.isAggregateDescriptor()) {
return javaType;
}
// Set an adapter that is a subclass of ReferenceAdapter that can adapt the class to create a link for
// the persistence_href field that has been weaved in.
String name = RestAdapterClassWriter.constructClassNameForReferenceAdapter(classDescriptor.getJavaClassName());
XmlJavaTypeAdapter adapter = new XmlJavaTypeAdapter();
adapter.setValue(name);
adapter.setValueType(classDescriptor.getJavaClassName());
adapter.setType(classDescriptor.getJavaClassName());
javaType.setXmlJavaTypeAdapter(adapter);
return javaType;
}