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 JMSBindingSerializer 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 JMSBinding jmsBinding = (JMSBinding) extension; 107 String tagName = 108 DOMUtils.getQualifiedValue(JMSConstants.NS_URI_JMS, "binding", def); 109 pw.print(" <" + tagName); 110 111 114 if (jmsBinding.getJmsMessageType() != JMSConstants.MESSAGE_TYPE_NOTSET) { 115 DOMUtils.printAttribute( 116 "type", 117 JMSBinding.JmsMessageTypeAsString(jmsBinding.getJmsMessageType()), 118 pw); 119 } 120 121 Boolean required = extension.getRequired(); 122 if (required != null) { 123 DOMUtils.printQualifiedAttribute( 124 Constants.Q_ATTR_REQUIRED, 125 required.toString(), 126 def, 127 pw); 128 } 129 130 pw.println("/>"); 131 Trc.exit(); 132 133 } 134 135 138 public void registerSerializer(ExtensionRegistry registry) { 139 Trc.entry(this, registry); 140 141 registry.registerSerializer( 142 javax.wsdl.Binding.class, 143 JMSConstants.Q_ELEM_JMS_BINDING, 144 this); 145 registry.registerDeserializer( 146 javax.wsdl.Binding.class, 147 JMSConstants.Q_ELEM_JMS_BINDING, 148 this); 149 registry.mapExtensionTypes( 150 javax.wsdl.Binding.class, 151 JMSConstants.Q_ELEM_JMS_BINDING, 152 JMSBinding.class); 153 154 Trc.exit(); 155 } 156 157 160 public ExtensibilityElement unmarshall( 161 Class parentType, 162 QName elementType, 163 Element el, 164 Definition def, 165 ExtensionRegistry extReg) 166 throws WSDLException { 167 Trc.entry(this, parentType, elementType, el, def, extReg); 168 169 JMSBinding jmsBinding = 170 (JMSBinding) extReg.createExtension(parentType, elementType); 171 172 String msgType = DOMUtils.getAttribute(el, JMSConstants.ATTR_MESSAGE_TYPE); 173 174 if (msgType.equals("ByteMessage")) { 175 jmsBinding.setJmsMessageType(JMSConstants.MESSAGE_TYPE_BYTEMESSAGE); 176 } else if (msgType.equals("MapMessage")) { 177 jmsBinding.setJmsMessageType(JMSConstants.MESSAGE_TYPE_MAPMESSAGE); 178 } else if (msgType.equals("ObjectMessage")) { 179 jmsBinding.setJmsMessageType(JMSConstants.MESSAGE_TYPE_OBJECTMESSAGE); 180 } else if (msgType.equals("StreamMessage")) { 181 jmsBinding.setJmsMessageType(JMSConstants.MESSAGE_TYPE_STREAMMESSAGE); 182 } else if (msgType.equals("TextMessage")) { 183 jmsBinding.setJmsMessageType(JMSConstants.MESSAGE_TYPE_TEXTMESSAGE); 184 } else { 185 jmsBinding.setJmsMessageType(JMSConstants.MESSAGE_TYPE_NOTSET); 186 } 187 188 Trc.exit(jmsBinding); 189 return jmsBinding; 190 } 191 } | Popular Tags |