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 import com.ibm.wsdl.util.xml.QNameUtils; 76 77 84 public class JMSAddressSerializer 85 implements ExtensionSerializer, ExtensionDeserializer, Serializable { 86 87 private static final long serialVersionUID = 1L; 88 89 JMSPropertyValueSerializer jmsPropertyValueSerializer; 90 91 private JMSPropertyValueSerializer getJMSPropertyValueSerializer() { 92 if (jmsPropertyValueSerializer == null) 93 jmsPropertyValueSerializer = new JMSPropertyValueSerializer(); 94 return jmsPropertyValueSerializer; 95 } 96 97 100 public void marshall( 101 Class parentType, 102 QName elementType, 103 javax.wsdl.extensions.ExtensibilityElement extension, 104 java.io.PrintWriter pw, 105 javax.wsdl.Definition def, 106 javax.wsdl.extensions.ExtensionRegistry extReg) 107 throws javax.wsdl.WSDLException { 108 Trc.entry(this, parentType, elementType, extension, pw, def, extReg); 109 110 JMSAddress jmsAddress = (JMSAddress) extension; 111 String tagName = 112 DOMUtils.getQualifiedValue(JMSConstants.NS_URI_JMS, "address", def); 113 114 if (jmsAddress != null) { 115 pw.print(" <" + tagName); 116 117 120 if (jmsAddress.getJmsVendorURI() != null) { 121 DOMUtils.printAttribute( 122 JMSConstants.ELEM_JMS_JMS_VENDOR_URI, 123 jmsAddress.getJmsVendorURI(), 124 pw); 125 } 126 127 if (jmsAddress.getInitCxtFact() != null) { 128 DOMUtils.printAttribute( 129 JMSConstants.ELEM_JMS_INIT_CXT_FACT, 130 jmsAddress.getInitCxtFact(), 131 pw); 132 } 133 134 if (jmsAddress.getJndiProvURL() != null) { 135 DOMUtils.printAttribute( 136 JMSConstants.ELEM_JMS_JNDI_PROV_URL, 137 jmsAddress.getJndiProvURL(), 138 pw); 139 } 140 141 if (jmsAddress.getDestStyle() != null) { 142 DOMUtils.printAttribute( 143 JMSConstants.ELEM_JMS_DEST_STYLE, 144 jmsAddress.getDestStyle(), 145 pw); 146 } 147 148 if (jmsAddress.getJndiConnFactName() != null) { 149 DOMUtils.printAttribute( 150 JMSConstants.ELEM_JMS_JNDI_CONN_FACT_NAME, 151 jmsAddress.getJndiConnFactName(), 152 pw); 153 } 154 155 if (jmsAddress.getJndiDestName() != null) { 156 DOMUtils.printAttribute( 157 JMSConstants.ELEM_JMS_JNDI_DEST_NAME, 158 jmsAddress.getJndiDestName(), 159 pw); 160 } 161 162 if (jmsAddress.getJmsProvDestName() != null) { 163 DOMUtils.printAttribute( 164 JMSConstants.ELEM_JMS_JMS_PROV_DEST_NAME, 165 jmsAddress.getJmsProvDestName(), 166 pw); 167 } 168 169 if (jmsAddress.getJmsImplSpecURI() != null) { 170 DOMUtils.printAttribute( 171 JMSConstants.ELEM_JMS_JMS_IMPL_SPEC_URI, 172 jmsAddress.getJmsImplSpecURI(), 173 pw); 174 } 175 176 pw.println(">"); 177 178 java.util.Iterator i = jmsAddress.getJMSPropertyValues().iterator(); 180 181 while (i.hasNext()) { 182 JMSPropertyValue ee = (JMSPropertyValue) i.next(); 183 getJMSPropertyValueSerializer().marshall( 184 JMSAddress.class, 185 JMSConstants.Q_ELEM_JMS_PROPERTY_VALUE, 186 ee, 187 pw, 188 def, 189 extReg); 190 } 191 192 Boolean required = extension.getRequired(); 193 if (required != null) { 194 DOMUtils.printQualifiedAttribute( 195 Constants.Q_ATTR_REQUIRED, 196 required.toString(), 197 def, 198 pw); 199 } 200 201 pw.println("</" + tagName + ">"); 202 } 203 Trc.exit(); 204 } 205 206 209 public void registerSerializer(ExtensionRegistry registry) { 210 Trc.entry(this, registry); 211 212 registry.registerSerializer( 213 javax.wsdl.Port.class, 214 JMSConstants.Q_ELEM_JMS_ADDRESS, 215 this); 216 registry.registerDeserializer( 217 javax.wsdl.Port.class, 218 JMSConstants.Q_ELEM_JMS_ADDRESS, 219 this); 220 registry.mapExtensionTypes( 221 javax.wsdl.Port.class, 222 JMSConstants.Q_ELEM_JMS_ADDRESS, 223 JMSAddress.class); 224 Trc.exit(); 225 } 226 227 230 public ExtensibilityElement unmarshall( 231 Class parentType, 232 QName elementType, 233 Element el, 234 Definition def, 235 ExtensionRegistry extReg) 236 throws WSDLException { 237 Trc.entry(this, parentType, elementType, el, def, extReg); 238 239 JMSAddress jmsAddress = 240 (JMSAddress) extReg.createExtension(parentType, elementType); 241 242 245 String jmsVendorURI = 246 DOMUtils.getAttribute(el, JMSConstants.ELEM_JMS_JMS_VENDOR_URI); 247 if (jmsVendorURI != null) { 248 jmsAddress.setJmsVendorURI(jmsVendorURI); 249 } 250 251 String jmsImplSpecURI = 252 DOMUtils.getAttribute(el, JMSConstants.ELEM_JMS_JMS_IMPL_SPEC_URI); 253 if (jmsImplSpecURI != null) { 254 jmsAddress.setJmsImplSpecURI(jmsImplSpecURI); 255 } 256 257 String initCxtFact = 258 DOMUtils.getAttribute(el, JMSConstants.ELEM_JMS_INIT_CXT_FACT); 259 if (initCxtFact != null) { 260 jmsAddress.setInitCxtFact(initCxtFact); 261 } 262 263 String jndiProvURL = 264 DOMUtils.getAttribute(el, JMSConstants.ELEM_JMS_JNDI_PROV_URL); 265 if (jndiProvURL != null) { 266 jmsAddress.setJndiProvURL(jndiProvURL); 267 } 268 269 String destStyle = 270 DOMUtils.getAttribute(el, JMSConstants.ELEM_JMS_DEST_STYLE); 271 if (destStyle != null) { 272 jmsAddress.setDestStyle(destStyle); 273 } 274 275 String jndiConnFactName = 276 DOMUtils.getAttribute( 277 el, 278 JMSConstants.ELEM_JMS_JNDI_CONN_FACT_NAME); 279 if (jndiConnFactName != null) { 280 jmsAddress.setJndiConnFactName(jndiConnFactName); 281 } 282 283 String jndiDestName = 284 DOMUtils.getAttribute(el, JMSConstants.ELEM_JMS_JNDI_DEST_NAME); 285 if (jndiDestName != null) { 286 jmsAddress.setJndiDestName(jndiDestName); 287 } 288 289 String jmsProvDestName = 290 DOMUtils.getAttribute(el, JMSConstants.ELEM_JMS_JMS_PROV_DEST_NAME); 291 if (jmsProvDestName != null) { 292 jmsAddress.setJmsProvDestName(jmsProvDestName); 293 } 294 295 Element tempEl = DOMUtils.getFirstChildElement(el); 297 298 while (tempEl != null) { 299 if (QNameUtils 300 .matches(JMSConstants.Q_ELEM_JMS_PROPERTY_VALUE, tempEl)) { 301 jmsAddress.addJMSPropertyValue( 302 (JMSPropertyValue) getJMSPropertyValueSerializer() 303 .unmarshall( 304 JMSAddress.class, 305 JMSConstants.Q_ELEM_JMS_PROPERTY_VALUE, 306 tempEl, 307 def, 308 extReg)); 309 } 310 311 tempEl = DOMUtils.getNextSiblingElement(tempEl); 312 } 313 314 Trc.exit(jmsAddress); 315 return jmsAddress; 316 } 317 } | Popular Tags |