1 package org.jbpm.bpel.wsdl.xml; 2 3 import java.io.PrintWriter ; 4 import java.io.Serializable ; 5 6 import javax.wsdl.Definition; 7 import javax.wsdl.WSDLException; 8 import javax.wsdl.extensions.ExtensibilityElement; 9 import javax.wsdl.extensions.ExtensionDeserializer; 10 import javax.wsdl.extensions.ExtensionRegistry; 11 import javax.wsdl.extensions.ExtensionSerializer; 12 import javax.xml.namespace.QName ; 13 14 import org.w3c.dom.Element ; 15 16 import com.ibm.wsdl.Constants; 17 import com.ibm.wsdl.util.xml.DOMUtils; 18 19 import org.jbpm.bpel.wsdl.def.Property; 20 import org.jbpm.bpel.xml.BpelConstants; 21 import org.jbpm.bpel.xml.util.NodeUtil; 22 23 29 public class PropertySerializer implements ExtensionSerializer, 30 ExtensionDeserializer, Serializable { 31 32 private static final long serialVersionUID = 1L; 33 34 45 public ExtensibilityElement unmarshall(Class parentType, QName elementType, 46 Element elem, Definition def, ExtensionRegistry extReg) throws WSDLException { 47 Property property = (Property) extReg.createExtension(parentType, elementType); 48 49 String name = elem.getAttribute(WsdlConstants.ATTR_NAME); 51 property.setQName(new QName (def.getTargetNamespace(), name)); 52 53 String type = elem.getAttribute(WsdlConstants.ATTR_TYPE); 55 property.setType(NodeUtil.getQName(type, elem)); 56 57 String required = DOMUtils.getAttributeNS(elem, Constants.NS_URI_WSDL, 59 Constants.ATTR_REQUIRED); 60 if (required != null) { 61 property.setRequired(Boolean.valueOf(required)); 62 } 63 64 return property; 65 } 66 67 78 public void marshall(Class parentType, QName elementType, 79 ExtensibilityElement extension, PrintWriter pw, Definition def, 80 ExtensionRegistry extReg) throws WSDLException { 81 if (extension == null) 82 return; 83 84 Property property = (Property) extension; 85 86 String tagName = DOMUtils.getQualifiedValue(BpelConstants.NS_BPWS, 88 WsdlConstants.ELEM_PROPERTY, def); 89 pw.print(" <" + tagName); 90 91 DOMUtils.printAttribute(WsdlConstants.ATTR_NAME, 93 property.getQName().getLocalPart(), pw); 94 95 DOMUtils.printQualifiedAttribute(WsdlConstants.ATTR_TYPE, 97 property.getType(), def, pw); 98 99 Boolean required = property.getRequired(); 101 if (required != null) { 102 DOMUtils.printQualifiedAttribute(Constants.Q_ATTR_REQUIRED, 103 required.toString(), def, pw); 104 } 105 106 pw.println("/>"); 108 } 109 } 110 | Popular Tags |