schemaInfo.setElement(null);
return el;
}
public void end(FaultInfo fault) {
MessagePartInfo part = fault.getMessageParts().get(0);
Class<?> cls = part.getTypeClass();
Class<?> cl2 = (Class)fault.getProperty(Class.class.getName());
if (cls != cl2) {
QName name = (QName)fault.getProperty("elementName");
part.setElementQName(name);
JAXBBeanInfo beanInfo = getBeanInfo(cls);
if (beanInfo == null) {
throw new Fault(new Message("NO_BEAN_INFO", LOG, cls.getName()));
}
SchemaInfo schemaInfo = serviceInfo.getSchema(part.getElementQName().getNamespaceURI());
if (schemaInfo != null
&& !isExistSchemaElement(schemaInfo.getSchema(), part.getElementQName())) {
XmlSchemaElement el = new XmlSchemaElement();
XmlSchemaUtils.setElementQName(el, part.getElementQName());
el.setNillable(true);
schemaInfo.getSchema().getItems().add(el);
schemaInfo.getSchema().getElements().add(el.getQName(), el);
schemaInfo.setElement(null);
Iterator<QName> itr = beanInfo.getTypeNames().iterator();
if (!itr.hasNext()) {
return;
}
QName typeName = itr.next();
el.setSchemaTypeName(typeName);
}
} else if (part.getXmlSchema() == null) {
try {
cls.getConstructor(new Class[] {String.class});
} catch (Exception e) {
try {
cls.getConstructor(new Class[0]);
} catch (Exception e2) {
//no String or default constructor, we cannot use it
return;
}
}
//not mappable in JAXBContext directly, we'll have to do it manually :-(
SchemaInfo schemaInfo = serviceInfo.getSchema(part.getElementQName().getNamespaceURI());
if (schemaInfo == null
|| isExistSchemaElement(schemaInfo.getSchema(), part.getElementQName())) {
return;
}
XmlSchemaElement el = new XmlSchemaElement();
XmlSchemaUtils.setElementQName(el, part.getElementQName());
schemaInfo.getSchema().getItems().add(el);
schemaInfo.getSchema().getElements().add(el.getQName(), el);
schemaInfo.setElement(null);
part.setXmlSchema(el);
XmlSchemaComplexType ct = new XmlSchemaComplexType(schemaInfo.getSchema());
el.setSchemaType(ct);
XmlSchemaSequence seq = new XmlSchemaSequence();
ct.setParticle(seq);
Method methods[] = cls.getMethods();
for (Method m : methods) {
if (m.getName().startsWith("get")
|| m.getName().startsWith("is")) {
int beginIdx = m.getName().startsWith("get") ? 3 : 2;
try {
m.getDeclaringClass().getMethod("set" + m.getName().substring(beginIdx),
m.getReturnType());
JAXBBeanInfo beanInfo = getBeanInfo(m.getReturnType());
if (beanInfo != null) {
el = new XmlSchemaElement();
el.setName(m.getName().substring(beginIdx));
String ns = schemaInfo.getSchema().getElementFormDefault()
.getValue().equals(XmlSchemaForm.UNQUALIFIED)
? "" : part.getElementQName().getLocalPart();
XmlSchemaUtils.setElementQName(el,
new QName(ns, m.getName().substring(beginIdx)));
Iterator<QName> itr = beanInfo.getTypeNames().iterator();
if (!itr.hasNext()) {
return;