1 57 58 package org.apache.wsif.wsdl.extensions.instance; 59 60 import java.io.PrintWriter ; 61 import java.io.Serializable ; 62 63 import javax.wsdl.Definition; 64 import javax.wsdl.WSDLException; 65 import javax.wsdl.extensions.ExtensibilityElement; 66 import javax.wsdl.extensions.ExtensionDeserializer; 67 import javax.wsdl.extensions.ExtensionRegistry; 68 import javax.wsdl.extensions.ExtensionSerializer; 69 import javax.xml.namespace.QName ; 70 71 import org.apache.wsif.logging.Trc; 72 import org.w3c.dom.Element ; 73 74 import com.ibm.wsdl.Constants; 75 import com.ibm.wsdl.util.xml.DOMUtils; 76 77 84 public class InstanceEstablishmentSerializer 85 implements ExtensionSerializer, ExtensionDeserializer, Serializable { 86 87 private static final long serialVersionUID = 1L; 88 89 public void marshall( 90 Class parentType, 91 QName elementType, 92 ExtensibilityElement extension, 93 PrintWriter pw, 94 Definition def, 95 ExtensionRegistry extReg) 96 throws WSDLException { 97 Trc.entry(this, parentType, elementType, extension, pw, def, extReg); 98 99 InstanceEstablishment instanceEstablishment = (InstanceEstablishment) extension; 100 101 if (instanceEstablishment != null) { 102 pw.print(" <instance:establishment"); 103 104 DOMUtils.printAttribute( 105 InstanceConstants.ATTR_OPERATION, 106 instanceEstablishment.getOperationName(), 107 pw); 108 109 Boolean required = instanceEstablishment.getRequired(); 110 111 if (required != null) { 112 DOMUtils.printQualifiedAttribute( 113 Constants.Q_ATTR_REQUIRED, 114 required.toString(), 115 def, 116 pw); 117 } 118 119 pw.println("/>"); 120 } 121 Trc.exit(); 122 } 123 124 public ExtensibilityElement unmarshall( 125 Class parentType, 126 QName elementType, 127 Element el, 128 Definition def, 129 ExtensionRegistry extReg) 130 throws WSDLException { 131 Trc.entry(this, parentType, elementType, el, def, extReg); 132 133 InstanceEstablishment instanceEstablishment = new InstanceEstablishment(); 134 String operationName = 135 DOMUtils.getAttribute(el, InstanceConstants.ATTR_OPERATION); 136 137 String requiredStr = 138 DOMUtils.getAttributeNS(el, Constants.NS_URI_WSDL, Constants.ATTR_REQUIRED); 139 140 if (operationName != null) { 141 instanceEstablishment.setOperationName(operationName); 142 } 143 144 148 if (requiredStr != null) { 149 instanceEstablishment.setRequired(new Boolean (requiredStr)); 150 } 151 152 Trc.exit(instanceEstablishment); 153 return instanceEstablishment; 154 } 155 } | Popular Tags |