diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-02 20:23:08 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-09-02 20:23:08 +0000 |
commit | 27fcfdf32ae017dd7759f78dceb4638ac8fa01a5 (patch) | |
tree | 2758b33b2785f7104847dcc01659364ac4e89b70 /branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org | |
parent | 3c14d04dd18e34baaeb79223b121650fe19575b9 (diff) |
Fix for TUSCANY-3238
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@810694 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org')
-rw-r--r-- | branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java b/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java index 2e8a4fc385..95aa6d1402 100644 --- a/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java +++ b/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java @@ -37,6 +37,7 @@ import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchema; +import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; import javax.xml.namespace.QName; @@ -47,6 +48,8 @@ import org.apache.tuscany.sca.databinding.util.LRUCache; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.interfacedef.util.WrapperInfo; import org.apache.tuscany.sca.interfacedef.util.XMLType; @@ -98,6 +101,18 @@ public class JAXBContextHelper { return createJAXBContext(dataType); } + + private static Class<?>[] getSeeAlso(Class<?> interfaze) { + if (interfaze == null) { + return null; + } + XmlSeeAlso seeAlso = interfaze.getAnnotation(XmlSeeAlso.class); + if (seeAlso == null) { + return null; + } else { + return seeAlso.value(); + } + } public static JAXBContext createJAXBContext(DataType dataType) throws JAXBException { return createJAXBContext(findClasses(dataType)); @@ -298,6 +313,23 @@ public class JAXBContextHelper { private static List<DataType> getDataTypes(Operation op, boolean useWrapper) { List<DataType> dataTypes = new ArrayList<DataType>(); getDataTypes(dataTypes, op, useWrapper); + // Adding classes referenced by @XmlSeeAlso in the java interface + Interface interface1 = op.getInterface(); + if (interface1 instanceof JavaInterface) { + JavaInterface javaInterface = (JavaInterface)interface1; + Class<?>[] seeAlso = getSeeAlso(javaInterface.getJavaClass()); + if (seeAlso != null) { + for (Class<?> cls : seeAlso) { + dataTypes.add(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls, XMLType.UNKNOWN)); + } + } + seeAlso = getSeeAlso(javaInterface.getCallbackClass()); + if (seeAlso != null) { + for (Class<?> cls : seeAlso) { + dataTypes.add(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, cls, XMLType.UNKNOWN)); + } + } + } return dataTypes; } |