下面列出了怎么用javax.xml.bind.annotation.XmlSeeAlso的API类实例代码及写法,或者点击链接到github查看源代码。
private void writeXmlSeeAlso(JDefinedClass cls) {
if (model.getJAXBModel().getS2JJAXBModel() != null) {
List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
//if there are no object facotires, dont generate @XmlSeeAlso
if (objectFactories.isEmpty()) {
return;
}
JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
for (JClass of : objectFactories) {
paramArray = paramArray.param(of);
}
}
}
private void writeXmlSeeAlso(JDefinedClass cls) {
if (model.getJAXBModel().getS2JJAXBModel() != null) {
List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
//if there are no object facotires, dont generate @XmlSeeAlso
if (objectFactories.isEmpty()) {
return;
}
JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
for (JClass of : objectFactories) {
paramArray = paramArray.param(of);
}
}
}
private static LinkedList<FieldsOfSubType> getFieldsOfSubTypes(Class<?> thisType,
StubTypeTreeRepository typeTreeRepository) {
LinkedList<FieldsOfSubType> fieldsOfAllSubTypes = new LinkedList<FieldsOfSubType>();
if (!thisType.isAnnotationPresent(XmlSeeAlso.class)) {
return fieldsOfAllSubTypes;
}
List<Class<?>> subTypes = getSubTypes(thisType);
registerToStubTypeTree(thisType, typeTreeRepository, subTypes);
for (Class<?> subType : subTypes) {
FieldsOfSubType fieldsOfSubType = new FieldsOfSubType(subType);
fieldsOfSubType.addAll(Arrays.asList(subType.getDeclaredFields()));
LinkedList<FieldsOfSubType> fieldsOfGrandSonType = getFieldsOfSubTypes(subType, typeTreeRepository);
fieldsOfAllSubTypes.add(fieldsOfSubType);
fieldsOfAllSubTypes.addAll(fieldsOfGrandSonType);
}
return fieldsOfAllSubTypes;
}
private void writeXmlSeeAlso(JDefinedClass cls) {
if (model.getJAXBModel().getS2JJAXBModel() != null) {
List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
//if there are no object facotires, dont generate @XmlSeeAlso
if (objectFactories.isEmpty()) {
return;
}
JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
for (JClass of : objectFactories) {
paramArray = paramArray.param(of);
}
}
}
private void writeXmlSeeAlso(JDefinedClass cls) {
if (model.getJAXBModel().getS2JJAXBModel() != null) {
List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
//if there are no object facotires, dont generate @XmlSeeAlso
if (objectFactories.isEmpty()) {
return;
}
JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
for (JClass of : objectFactories) {
paramArray = paramArray.param(of);
}
}
}
private void writeXmlSeeAlso(JDefinedClass cls) {
if (model.getJAXBModel().getS2JJAXBModel() != null) {
List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
//if there are no object facotires, dont generate @XmlSeeAlso
if (objectFactories.isEmpty()) {
return;
}
JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
for (JClass of : objectFactories) {
paramArray = paramArray.param(of);
}
}
}
private void writeXmlSeeAlso(JDefinedClass cls) {
if (model.getJAXBModel().getS2JJAXBModel() != null) {
List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
//if there are no object facotires, dont generate @XmlSeeAlso
if (objectFactories.isEmpty()) {
return;
}
JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
for (JClass of : objectFactories) {
paramArray = paramArray.param(of);
}
}
}
private void writeXmlSeeAlso(JDefinedClass cls) {
if (model.getJAXBModel().getS2JJAXBModel() != null) {
List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
//if there are no object facotires, dont generate @XmlSeeAlso
if (objectFactories.isEmpty()) {
return;
}
JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
for (JClass of : objectFactories) {
paramArray = paramArray.param(of);
}
}
}
private void writeXmlSeeAlso(JDefinedClass cls) {
if (model.getJAXBModel().getS2JJAXBModel() != null) {
List<JClass> objectFactories = model.getJAXBModel().getS2JJAXBModel().getAllObjectFactories();
//if there are no object facotires, dont generate @XmlSeeAlso
if (objectFactories.isEmpty()) {
return;
}
JAnnotationUse xmlSeeAlso = cls.annotate(cm.ref(XmlSeeAlso.class));
JAnnotationArrayMember paramArray = xmlSeeAlso.paramArray("value");
for (JClass of : objectFactories) {
paramArray = paramArray.param(of);
}
}
}
/**
* Traverse XML data object hierarchy and collect all descendants of a root class.
*
* @param rootClass root class of type hierarchy
* @param clazz type class to be processed
* @param classes set to collect type classes
*/
public static void collectXmlTypes(Class<?> rootClass, Class<?> clazz, Set<Class<?>> classes) {
if (classes.contains(clazz)) {
return;
}
if (clazz != rootClass && rootClass.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers())) {
classes.add(clazz);
}
XmlSeeAlso xmlSeeAlso = clazz.getAnnotation(XmlSeeAlso.class);
if (xmlSeeAlso != null) {
Collection<Class<?>> referencedClasses = new HashSet<>(Arrays.<Class<?>>asList(xmlSeeAlso.value()));
for (Class<?> referencedClass : referencedClasses) {
collectXmlTypes(rootClass, referencedClass, classes);
}
}
}
public void annotate(JavaAnnotatable ja) {
if (collector == null || collector.getTypesPackages().isEmpty()) {
return;
}
JavaInterface intf = null;
if (ja instanceof JavaInterface) {
intf = (JavaInterface) ja;
} else {
throw new RuntimeException("XmlSeeAlso can only annotate JavaInterface");
}
JAnnotation jaxbAnnotation = new JAnnotation(XmlSeeAlso.class);
intf.addImports(jaxbAnnotation.getImports());
List<JavaType> types = new ArrayList<>();
for (String pkg : collector.getTypesPackages()) {
if (pkg.equals(intf.getPackageName())) {
types.add(new JavaType(null, "ObjectFactory", null));
} else {
types.add(new JavaType(null, pkg + ".ObjectFactory", null));
}
}
jaxbAnnotation.addElement(new JAnnotationElement(null, types));
intf.addAnnotation(jaxbAnnotation);
}
private static List<Class<?>> getSubTypes(Class<?> thisType) {
List<Class<?>> subTypes = new ArrayList<Class<?>>();
for (Class<?> subType : thisType.getAnnotation(XmlSeeAlso.class).value()) {
if (thisType.isAssignableFrom(subType)) {
subTypes.add(subType);
}
}
return subTypes;
}
@Test
public void testList() throws Exception {
JAnnotation annotation = new JAnnotation(XmlSeeAlso.class);
annotation.addElement(new JAnnotationElement(null,
Arrays.asList(new Class[]{XmlSeeAlso.class})));
assertEquals("@XmlSeeAlso({XmlSeeAlso.class})", annotation.toString());
assertEquals("javax.xml.bind.annotation.XmlSeeAlso", annotation.getImports().iterator().next());
}
void processClass(Class clazz) {
classUsesWebMethod = new HashSet<Class>();
determineWebMethodUse(clazz);
WebService webService = getAnnotation(clazz, WebService.class);
QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
// String portTypeLocalName = clazz.getSimpleName();
// if (webService.name().length() >0)
// portTypeLocalName = webService.name();
//
// targetNamespace = webService.targetNamespace();
packageName = "";
if (clazz.getPackage() != null)
packageName = clazz.getPackage().getName();
// if (targetNamespace.length() == 0) {
// targetNamespace = getNamespace(packageName);
// }
// model.setTargetNamespace(targetNamespace);
// QName portTypeName = new QName(targetNamespace, portTypeLocalName);
targetNamespace = portTypeName.getNamespaceURI();
model.setPortTypeName(portTypeName);
model.setTargetNamespace(targetNamespace);
model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
model.setWSDLLocation(webService.wsdlLocation());
SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
soapBinding, clazz);
}
isWrapped = soapBinding.parameterStyle()== WRAPPED;
}
defaultBinding = createBinding(soapBinding);
/*
* if clazz != portClass then there is an SEI. If there is an
* SEI, then all methods should be processed. However, if there is
* no SEI, and the implementation class uses at least one
* WebMethod annotation, then only methods with this annotation
* will be processed.
*/
/* if (clazz == portClass) {
WebMethod webMethod;
for (Method method : clazz.getMethods()) {
webMethod = getPrivMethodAnnotation(method, WebMethod.class);
if (webMethod != null &&
!webMethod.exclude()) {
usesWebMethod = true;
break;
}
}
}*/
for (Method method : clazz.getMethods()) {
if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods
if (method.getDeclaringClass() == Object.class) continue;
if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) { // legacy webMethod computation behaviour to be used
if (!isWebMethodBySpec(method, clazz))
continue;
} else {
if (!isWebMethod(method))
continue;
}
}
// TODO: binding can be null. We need to figure out how to post-process
// RuntimeModel to link to WSDLModel
processMethod(method);
}
//Add additional jaxb classes referenced by {@link XmlSeeAlso}
XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
if(xmlSeeAlso != null)
model.addAdditionalClasses(xmlSeeAlso.value());
}
void processClass(Class clazz) {
classUsesWebMethod = new HashSet<Class>();
determineWebMethodUse(clazz);
WebService webService = getAnnotation(clazz, WebService.class);
QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
// String portTypeLocalName = clazz.getSimpleName();
// if (webService.name().length() >0)
// portTypeLocalName = webService.name();
//
// targetNamespace = webService.targetNamespace();
packageName = "";
if (clazz.getPackage() != null)
packageName = clazz.getPackage().getName();
// if (targetNamespace.length() == 0) {
// targetNamespace = getNamespace(packageName);
// }
// model.setTargetNamespace(targetNamespace);
// QName portTypeName = new QName(targetNamespace, portTypeLocalName);
targetNamespace = portTypeName.getNamespaceURI();
model.setPortTypeName(portTypeName);
model.setTargetNamespace(targetNamespace);
model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
model.setWSDLLocation(webService.wsdlLocation());
SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
soapBinding, clazz);
}
isWrapped = soapBinding.parameterStyle()== WRAPPED;
}
defaultBinding = createBinding(soapBinding);
/*
* if clazz != portClass then there is an SEI. If there is an
* SEI, then all methods should be processed. However, if there is
* no SEI, and the implementation class uses at least one
* WebMethod annotation, then only methods with this annotation
* will be processed.
*/
/* if (clazz == portClass) {
WebMethod webMethod;
for (Method method : clazz.getMethods()) {
webMethod = getPrivMethodAnnotation(method, WebMethod.class);
if (webMethod != null &&
!webMethod.exclude()) {
usesWebMethod = true;
break;
}
}
}*/
for (Method method : clazz.getMethods()) {
if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods
if (method.getDeclaringClass() == Object.class) continue;
if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) { // legacy webMethod computation behaviour to be used
if (!isWebMethodBySpec(method, clazz))
continue;
} else {
if (!isWebMethod(method))
continue;
}
}
// TODO: binding can be null. We need to figure out how to post-process
// RuntimeModel to link to WSDLModel
processMethod(method);
}
//Add additional jaxb classes referenced by {@link XmlSeeAlso}
XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
if(xmlSeeAlso != null)
model.addAdditionalClasses(xmlSeeAlso.value());
}
void processClass(Class clazz) {
classUsesWebMethod = new HashSet<Class>();
determineWebMethodUse(clazz);
WebService webService = getAnnotation(clazz, WebService.class);
QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
// String portTypeLocalName = clazz.getSimpleName();
// if (webService.name().length() >0)
// portTypeLocalName = webService.name();
//
// targetNamespace = webService.targetNamespace();
packageName = "";
if (clazz.getPackage() != null)
packageName = clazz.getPackage().getName();
// if (targetNamespace.length() == 0) {
// targetNamespace = getNamespace(packageName);
// }
// model.setTargetNamespace(targetNamespace);
// QName portTypeName = new QName(targetNamespace, portTypeLocalName);
targetNamespace = portTypeName.getNamespaceURI();
model.setPortTypeName(portTypeName);
model.setTargetNamespace(targetNamespace);
model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
model.setWSDLLocation(webService.wsdlLocation());
SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
soapBinding, clazz);
}
isWrapped = soapBinding.parameterStyle()== WRAPPED;
}
defaultBinding = createBinding(soapBinding);
/*
* if clazz != portClass then there is an SEI. If there is an
* SEI, then all methods should be processed. However, if there is
* no SEI, and the implementation class uses at least one
* WebMethod annotation, then only methods with this annotation
* will be processed.
*/
/* if (clazz == portClass) {
WebMethod webMethod;
for (Method method : clazz.getMethods()) {
webMethod = getPrivMethodAnnotation(method, WebMethod.class);
if (webMethod != null &&
!webMethod.exclude()) {
usesWebMethod = true;
break;
}
}
}*/
for (Method method : clazz.getMethods()) {
if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods
if (method.getDeclaringClass() == Object.class) continue;
if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) { // legacy webMethod computation behaviour to be used
if (!isWebMethodBySpec(method, clazz))
continue;
} else {
if (!isWebMethod(method))
continue;
}
}
// TODO: binding can be null. We need to figure out how to post-process
// RuntimeModel to link to WSDLModel
processMethod(method);
}
//Add additional jaxb classes referenced by {@link XmlSeeAlso}
XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
if(xmlSeeAlso != null)
model.addAdditionalClasses(xmlSeeAlso.value());
}
void processClass(Class clazz) {
classUsesWebMethod = new HashSet<Class>();
determineWebMethodUse(clazz);
WebService webService = getAnnotation(clazz, WebService.class);
QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
// String portTypeLocalName = clazz.getSimpleName();
// if (webService.name().length() >0)
// portTypeLocalName = webService.name();
//
// targetNamespace = webService.targetNamespace();
packageName = "";
if (clazz.getPackage() != null)
packageName = clazz.getPackage().getName();
// if (targetNamespace.length() == 0) {
// targetNamespace = getNamespace(packageName);
// }
// model.setTargetNamespace(targetNamespace);
// QName portTypeName = new QName(targetNamespace, portTypeLocalName);
targetNamespace = portTypeName.getNamespaceURI();
model.setPortTypeName(portTypeName);
model.setTargetNamespace(targetNamespace);
model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
model.setWSDLLocation(webService.wsdlLocation());
SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
soapBinding, clazz);
}
isWrapped = soapBinding.parameterStyle()== WRAPPED;
}
defaultBinding = createBinding(soapBinding);
/*
* if clazz != portClass then there is an SEI. If there is an
* SEI, then all methods should be processed. However, if there is
* no SEI, and the implementation class uses at least one
* WebMethod annotation, then only methods with this annotation
* will be processed.
*/
/* if (clazz == portClass) {
WebMethod webMethod;
for (Method method : clazz.getMethods()) {
webMethod = getPrivMethodAnnotation(method, WebMethod.class);
if (webMethod != null &&
!webMethod.exclude()) {
usesWebMethod = true;
break;
}
}
}*/
for (Method method : clazz.getMethods()) {
if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods
if (method.getDeclaringClass() == Object.class) continue;
if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) { // legacy webMethod computation behaviour to be used
if (!isWebMethodBySpec(method, clazz))
continue;
} else {
if (!isWebMethod(method))
continue;
}
}
// TODO: binding can be null. We need to figure out how to post-process
// RuntimeModel to link to WSDLModel
processMethod(method);
}
//Add additional jaxb classes referenced by {@link XmlSeeAlso}
XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
if(xmlSeeAlso != null)
model.addAdditionalClasses(xmlSeeAlso.value());
}
void processClass(Class clazz) {
classUsesWebMethod = new HashSet<Class>();
determineWebMethodUse(clazz);
WebService webService = getAnnotation(clazz, WebService.class);
QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
// String portTypeLocalName = clazz.getSimpleName();
// if (webService.name().length() >0)
// portTypeLocalName = webService.name();
//
// targetNamespace = webService.targetNamespace();
packageName = "";
if (clazz.getPackage() != null)
packageName = clazz.getPackage().getName();
// if (targetNamespace.length() == 0) {
// targetNamespace = getNamespace(packageName);
// }
// model.setTargetNamespace(targetNamespace);
// QName portTypeName = new QName(targetNamespace, portTypeLocalName);
targetNamespace = portTypeName.getNamespaceURI();
model.setPortTypeName(portTypeName);
model.setTargetNamespace(targetNamespace);
model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
model.setWSDLLocation(webService.wsdlLocation());
SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
soapBinding, clazz);
}
isWrapped = soapBinding.parameterStyle()== WRAPPED;
}
defaultBinding = createBinding(soapBinding);
/*
* if clazz != portClass then there is an SEI. If there is an
* SEI, then all methods should be processed. However, if there is
* no SEI, and the implementation class uses at least one
* WebMethod annotation, then only methods with this annotation
* will be processed.
*/
/* if (clazz == portClass) {
WebMethod webMethod;
for (Method method : clazz.getMethods()) {
webMethod = getPrivMethodAnnotation(method, WebMethod.class);
if (webMethod != null &&
!webMethod.exclude()) {
usesWebMethod = true;
break;
}
}
}*/
for (Method method : clazz.getMethods()) {
if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods
if (method.getDeclaringClass() == Object.class) continue;
if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) { // legacy webMethod computation behaviour to be used
if (!isWebMethodBySpec(method, clazz))
continue;
} else {
if (!isWebMethod(method))
continue;
}
}
// TODO: binding can be null. We need to figure out how to post-process
// RuntimeModel to link to WSDLModel
processMethod(method);
}
//Add additional jaxb classes referenced by {@link XmlSeeAlso}
XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
if(xmlSeeAlso != null)
model.addAdditionalClasses(xmlSeeAlso.value());
}
void processClass(Class clazz) {
classUsesWebMethod = new HashSet<Class>();
determineWebMethodUse(clazz);
WebService webService = getAnnotation(clazz, WebService.class);
QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
// String portTypeLocalName = clazz.getSimpleName();
// if (webService.name().length() >0)
// portTypeLocalName = webService.name();
//
// targetNamespace = webService.targetNamespace();
packageName = "";
if (clazz.getPackage() != null)
packageName = clazz.getPackage().getName();
// if (targetNamespace.length() == 0) {
// targetNamespace = getNamespace(packageName);
// }
// model.setTargetNamespace(targetNamespace);
// QName portTypeName = new QName(targetNamespace, portTypeLocalName);
targetNamespace = portTypeName.getNamespaceURI();
model.setPortTypeName(portTypeName);
model.setTargetNamespace(targetNamespace);
model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
model.setWSDLLocation(webService.wsdlLocation());
SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
soapBinding, clazz);
}
isWrapped = soapBinding.parameterStyle()== WRAPPED;
}
defaultBinding = createBinding(soapBinding);
/*
* if clazz != portClass then there is an SEI. If there is an
* SEI, then all methods should be processed. However, if there is
* no SEI, and the implementation class uses at least one
* WebMethod annotation, then only methods with this annotation
* will be processed.
*/
/* if (clazz == portClass) {
WebMethod webMethod;
for (Method method : clazz.getMethods()) {
webMethod = getPrivMethodAnnotation(method, WebMethod.class);
if (webMethod != null &&
!webMethod.exclude()) {
usesWebMethod = true;
break;
}
}
}*/
for (Method method : clazz.getMethods()) {
if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods
if (method.getDeclaringClass() == Object.class) continue;
if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) { // legacy webMethod computation behaviour to be used
if (!isWebMethodBySpec(method, clazz))
continue;
} else {
if (!isWebMethod(method))
continue;
}
}
// TODO: binding can be null. We need to figure out how to post-process
// RuntimeModel to link to WSDLModel
processMethod(method);
}
//Add additional jaxb classes referenced by {@link XmlSeeAlso}
XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
if(xmlSeeAlso != null)
model.addAdditionalClasses(xmlSeeAlso.value());
}
void processClass(Class clazz) {
classUsesWebMethod = new HashSet<Class>();
determineWebMethodUse(clazz);
WebService webService = getAnnotation(clazz, WebService.class);
QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
// String portTypeLocalName = clazz.getSimpleName();
// if (webService.name().length() >0)
// portTypeLocalName = webService.name();
//
// targetNamespace = webService.targetNamespace();
packageName = "";
if (clazz.getPackage() != null)
packageName = clazz.getPackage().getName();
// if (targetNamespace.length() == 0) {
// targetNamespace = getNamespace(packageName);
// }
// model.setTargetNamespace(targetNamespace);
// QName portTypeName = new QName(targetNamespace, portTypeLocalName);
targetNamespace = portTypeName.getNamespaceURI();
model.setPortTypeName(portTypeName);
model.setTargetNamespace(targetNamespace);
model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
model.setWSDLLocation(webService.wsdlLocation());
SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
soapBinding, clazz);
}
isWrapped = soapBinding.parameterStyle()== WRAPPED;
}
defaultBinding = createBinding(soapBinding);
/*
* if clazz != portClass then there is an SEI. If there is an
* SEI, then all methods should be processed. However, if there is
* no SEI, and the implementation class uses at least one
* WebMethod annotation, then only methods with this annotation
* will be processed.
*/
/* if (clazz == portClass) {
WebMethod webMethod;
for (Method method : clazz.getMethods()) {
webMethod = getPrivMethodAnnotation(method, WebMethod.class);
if (webMethod != null &&
!webMethod.exclude()) {
usesWebMethod = true;
break;
}
}
}*/
for (Method method : clazz.getMethods()) {
if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods
if (method.getDeclaringClass() == Object.class) continue;
if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) { // legacy webMethod computation behaviour to be used
if (!isWebMethodBySpec(method, clazz))
continue;
} else {
if (!isWebMethod(method))
continue;
}
}
// TODO: binding can be null. We need to figure out how to post-process
// RuntimeModel to link to WSDLModel
processMethod(method);
}
//Add additional jaxb classes referenced by {@link XmlSeeAlso}
XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
if(xmlSeeAlso != null)
model.addAdditionalClasses(xmlSeeAlso.value());
}
void processClass(Class clazz) {
classUsesWebMethod = new HashSet<Class>();
determineWebMethodUse(clazz);
WebService webService = getAnnotation(clazz, WebService.class);
QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader);
// String portTypeLocalName = clazz.getSimpleName();
// if (webService.name().length() >0)
// portTypeLocalName = webService.name();
//
// targetNamespace = webService.targetNamespace();
packageName = "";
if (clazz.getPackage() != null)
packageName = clazz.getPackage().getName();
// if (targetNamespace.length() == 0) {
// targetNamespace = getNamespace(packageName);
// }
// model.setTargetNamespace(targetNamespace);
// QName portTypeName = new QName(targetNamespace, portTypeLocalName);
targetNamespace = portTypeName.getNamespaceURI();
model.setPortTypeName(portTypeName);
model.setTargetNamespace(targetNamespace);
model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix();
model.setWSDLLocation(webService.wsdlLocation());
SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class);
if (soapBinding != null) {
if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle",
soapBinding, clazz);
}
isWrapped = soapBinding.parameterStyle()== WRAPPED;
}
defaultBinding = createBinding(soapBinding);
/*
* if clazz != portClass then there is an SEI. If there is an
* SEI, then all methods should be processed. However, if there is
* no SEI, and the implementation class uses at least one
* WebMethod annotation, then only methods with this annotation
* will be processed.
*/
/* if (clazz == portClass) {
WebMethod webMethod;
for (Method method : clazz.getMethods()) {
webMethod = getPrivMethodAnnotation(method, WebMethod.class);
if (webMethod != null &&
!webMethod.exclude()) {
usesWebMethod = true;
break;
}
}
}*/
for (Method method : clazz.getMethods()) {
if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods
if (method.getDeclaringClass() == Object.class) continue;
if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) { // legacy webMethod computation behaviour to be used
if (!isWebMethodBySpec(method, clazz))
continue;
} else {
if (!isWebMethod(method))
continue;
}
}
// TODO: binding can be null. We need to figure out how to post-process
// RuntimeModel to link to WSDLModel
processMethod(method);
}
//Add additional jaxb classes referenced by {@link XmlSeeAlso}
XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class);
if(xmlSeeAlso != null)
model.addAdditionalClasses(xmlSeeAlso.value());
}
void addClass(Class<?> claz) {
if (Throwable.class.isAssignableFrom(claz)) {
if (!Throwable.class.equals(claz)
&& !Exception.class.equals(claz)) {
walkReferences(claz);
}
addClass(String.class);
} else if (claz.getName().startsWith("java.")
|| claz.getName().startsWith("javax.")) {
return;
} else {
Class<?> cls = JAXBUtils.getValidClass(claz);
if (cls == null
&& ReflectionUtil.getDeclaredConstructors(claz).length > 0
&& !Modifier.isAbstract(claz.getModifiers())) {
if (LOG.isLoggable(Level.INFO)) {
LOG.info("Class " + claz.getName() + " does not have a default constructor which JAXB requires.");
}
//there is no init(), but other constructors
Object factory = createFactory(claz, ReflectionUtil.getDeclaredConstructors(claz)[0]);
unmarshallerProperties.put("com.sun.xml.bind.ObjectFactory", factory);
cls = claz;
}
if (null != cls) {
if (classes.contains(cls)) {
return;
}
if (!cls.isInterface()) {
classes.add(cls);
}
XmlSeeAlso xsa = cls.getAnnotation(XmlSeeAlso.class);
if (xsa != null) {
for (Class<?> c : xsa.value()) {
addClass(c);
}
}
XmlJavaTypeAdapter xjta = cls.getAnnotation(XmlJavaTypeAdapter.class);
if (xjta != null) {
//has an adapter. We need to inspect the adapter and then
//return as the adapter will handle the superclass
//and interfaces and such
Type t = Utils.getTypeFromXmlAdapter(xjta);
if (t != null) {
addType(t);
}
return;
}
if (cls.getSuperclass() != null) {
//JAXB should do this, but it doesn't always.
//in particular, older versions of jaxb don't
addClass(cls.getSuperclass());
}
if (!cls.isInterface()) {
walkReferences(cls);
}
}
}
}