1 57 58 package org.apache.wsif.wsdl.extensions.jms; 59 60 import java.io.Serializable ; 61 62 import javax.wsdl.Definition; 63 import javax.wsdl.WSDLException; 64 import javax.wsdl.extensions.ExtensibilityElement; 65 import javax.wsdl.extensions.ExtensionDeserializer; 66 import javax.wsdl.extensions.ExtensionRegistry; 67 import javax.wsdl.extensions.ExtensionSerializer; 68 import javax.xml.namespace.QName ; 69 70 import org.apache.wsif.logging.Trc; 71 import org.w3c.dom.Element ; 72 73 import com.ibm.wsdl.Constants; 74 import com.ibm.wsdl.util.xml.DOMUtils; 75 76 83 public class JMSOutputSerializer 84 implements ExtensionSerializer, ExtensionDeserializer, Serializable { 85 86 private static final long serialVersionUID = 1L; 87 88 91 public void marshall( 92 Class parentType, 93 QName elementType, 94 javax.wsdl.extensions.ExtensibilityElement extension, 95 java.io.PrintWriter pw, 96 javax.wsdl.Definition def, 97 javax.wsdl.extensions.ExtensionRegistry extReg) 98 throws javax.wsdl.WSDLException { 99 Trc.entry(this, parentType, elementType, extension, pw, def, extReg); 100 101 if (extension == null) { 102 Trc.exit(); 103 return; 104 } 105 106 JMSOutput jmsOutput = (JMSOutput) extension; 107 String tagName = 108 DOMUtils.getQualifiedValue(JMSConstants.NS_URI_JMS, "output", def); 109 pw.print(" <" + tagName); 110 111 114 if (jmsOutput.getParts() != null) { 115 DOMUtils.printAttribute( 116 JMSConstants.ATTR_PARTS, 117 com.ibm.wsdl.util.StringUtils.getNMTokens(jmsOutput.getParts()), 118 pw); 119 } 120 121 if (jmsOutput.getSchema() != null) { 122 DOMUtils.printAttribute(JMSConstants.ATTR_SCHEMA, jmsOutput.getSchema(), pw); 123 } 124 125 Boolean required = extension.getRequired(); 126 if (required != null) { 127 DOMUtils.printQualifiedAttribute( 128 Constants.Q_ATTR_REQUIRED, 129 required.toString(), 130 def, 131 pw); 132 } 133 134 pw.println("/>"); 135 Trc.exit(); 136 } 137 138 141 public void registerSerializer(ExtensionRegistry registry) { 142 Trc.entry(this, registry); 143 144 registry.registerSerializer( 145 javax.wsdl.BindingInput.class, 146 JMSConstants.Q_ELEM_JMS_OUTPUT, 147 this); 148 registry.registerDeserializer( 149 javax.wsdl.BindingInput.class, 150 JMSConstants.Q_ELEM_JMS_OUTPUT, 151 this); 152 registry.mapExtensionTypes( 153 javax.wsdl.BindingInput.class, 154 JMSConstants.Q_ELEM_JMS_OUTPUT, 155 JMSOutput.class); 156 157 registry.registerSerializer( 158 javax.wsdl.BindingOutput.class, 159 JMSConstants.Q_ELEM_JMS_OUTPUT, 160 this); 161 registry.registerDeserializer( 162 javax.wsdl.BindingOutput.class, 163 JMSConstants.Q_ELEM_JMS_OUTPUT, 164 this); 165 registry.mapExtensionTypes( 166 javax.wsdl.BindingOutput.class, 167 JMSConstants.Q_ELEM_JMS_OUTPUT, 168 JMSOutput.class); 169 Trc.exit(); 170 } 171 172 175 public ExtensibilityElement unmarshall( 176 Class parentType, 177 QName elementType, 178 Element el, 179 Definition def, 180 ExtensionRegistry extReg) 181 throws WSDLException { 182 Trc.entry(this, parentType, elementType, el, def, extReg); 183 184 JMSOutput jmsOutput = 185 (JMSOutput) extReg.createExtension(parentType, elementType); 186 String parts = DOMUtils.getAttribute(el, JMSConstants.ATTR_PARTS); 187 if (parts != null) { 188 jmsOutput.setParts(com.ibm.wsdl.util.StringUtils.parseNMTokens(parts)); 189 } 190 191 String schema = DOMUtils.getAttribute(el, JMSConstants.ATTR_SCHEMA); 192 if (schema != null) { 193 jmsOutput.setSchema(schema); 194 } 195 196 Trc.exit(jmsOutput); 197 return jmsOutput; 198 } 199 } | Popular Tags |