1 57 58 package org.apache.wsif.wsdl.extensions.java; 59 60 import java.io.Serializable ; 61 62 import javax.wsdl.extensions.ExtensionDeserializer; 63 import javax.wsdl.extensions.ExtensionRegistry; 64 import javax.wsdl.extensions.ExtensionSerializer; 65 import javax.xml.namespace.QName ; 66 67 import org.apache.wsif.logging.Trc; 68 69 import com.ibm.wsdl.Constants; 70 import com.ibm.wsdl.util.StringUtils; 71 import com.ibm.wsdl.util.xml.DOMUtils; 72 73 80 public class JavaBindingSerializer 81 implements ExtensionSerializer, ExtensionDeserializer, Serializable { 82 83 private static final long serialVersionUID = 1L; 84 85 public void marshall( 86 Class parentType, 87 QName elementType, 88 javax.wsdl.extensions.ExtensibilityElement extension, 89 java.io.PrintWriter pw, 90 javax.wsdl.Definition def, 91 javax.wsdl.extensions.ExtensionRegistry extReg) 92 throws javax.wsdl.WSDLException { 93 Trc.entry(this, parentType, elementType, extension, pw, def, extReg); 94 95 97 if (extension == null) { 98 Trc.exit(); 99 return; 100 } 101 102 if (extension instanceof JavaBinding) { 103 JavaBinding javaBinding = (JavaBinding) extension; 104 pw.print(" <java:binding"); 105 106 Boolean required = extension.getRequired(); 107 if (required != null) { 108 DOMUtils.printQualifiedAttribute( 109 Constants.Q_ATTR_REQUIRED, 110 required.toString(), 111 def, 112 pw); 113 } 114 115 pw.println("/>"); 116 } else if (extension instanceof JavaOperation) { 117 JavaOperation javaOperation = (JavaOperation) extension; 118 pw.print(" <java:operation"); 119 120 if (javaOperation.getMethodName() != null) { 121 DOMUtils.printAttribute("methodName", javaOperation.getMethodName(), pw); 122 } 123 124 if (javaOperation.getMethodType() != null) { 125 DOMUtils.printAttribute("methodType", javaOperation.getMethodType(), pw); 126 } 127 128 if (javaOperation.getParameterOrder() != null) { 129 DOMUtils.printAttribute( 130 "parameterOrder", 131 StringUtils.getNMTokens(javaOperation.getParameterOrder()), 132 pw); 133 } 134 135 if (javaOperation.getReturnPart() != null) { 136 DOMUtils.printAttribute("returnPart", javaOperation.getReturnPart(), pw); 137 } 138 139 Boolean required = extension.getRequired(); 140 if (required != null) { 141 DOMUtils.printQualifiedAttribute( 142 Constants.Q_ATTR_REQUIRED, 143 required.toString(), 144 def, 145 pw); 146 } 147 148 pw.println("/>"); 149 } else if (extension instanceof JavaAddress) { 150 JavaAddress javaAddress = (JavaAddress) extension; 151 pw.print(" <java:address"); 152 153 if (javaAddress.getClassName() != null) { 154 DOMUtils.printAttribute("className", javaAddress.getClassName(), pw); 155 } 156 157 if (javaAddress.getClassPath() != null) { 158 DOMUtils.printAttribute("classPath", javaAddress.getClassPath(), pw); 159 } 160 161 if (javaAddress.getClassLoader() != null) { 162 DOMUtils.printAttribute("classLoader", javaAddress.getClassLoader(), pw); 163 } 164 165 Boolean required = extension.getRequired(); 166 if (required != null) { 167 DOMUtils.printQualifiedAttribute( 168 Constants.Q_ATTR_REQUIRED, 169 required.toString(), 170 def, 171 pw); 172 } 173 174 pw.println("/>"); 175 } 176 Trc.exit(); 177 } 178 179 182 public void registerSerializer(ExtensionRegistry registry) { 183 Trc.entry(this, registry); 184 registry.registerSerializer( 186 javax.wsdl.Binding.class, 187 JavaBindingConstants.Q_ELEM_JAVA_BINDING, 188 this); 189 registry.registerDeserializer( 190 javax.wsdl.Binding.class, 191 JavaBindingConstants.Q_ELEM_JAVA_BINDING, 192 this); 193 registry.mapExtensionTypes( 194 javax.wsdl.Binding.class, 195 JavaBindingConstants.Q_ELEM_JAVA_BINDING, 196 JavaBinding.class); 197 198 registry.registerSerializer( 200 javax.wsdl.BindingOperation.class, 201 JavaBindingConstants.Q_ELEM_JAVA_OPERATION, 202 this); 203 registry.registerDeserializer( 204 javax.wsdl.BindingOperation.class, 205 JavaBindingConstants.Q_ELEM_JAVA_OPERATION, 206 this); 207 registry.mapExtensionTypes( 208 javax.wsdl.BindingOperation.class, 209 JavaBindingConstants.Q_ELEM_JAVA_OPERATION, 210 JavaOperation.class); 211 registry.registerSerializer( 213 javax.wsdl.Port.class, 214 JavaBindingConstants.Q_ELEM_JAVA_ADDRESS, 215 this); 216 registry.registerDeserializer( 217 javax.wsdl.Port.class, 218 JavaBindingConstants.Q_ELEM_JAVA_ADDRESS, 219 this); 220 registry.mapExtensionTypes( 221 javax.wsdl.Port.class, 222 JavaBindingConstants.Q_ELEM_JAVA_ADDRESS, 223 JavaAddress.class); 224 Trc.exit(); 225 } 226 227 public javax.wsdl.extensions.ExtensibilityElement unmarshall( 228 Class parentType, 229 javax.xml.namespace.QName elementType, 230 org.w3c.dom.Element el, 231 javax.wsdl.Definition def, 232 javax.wsdl.extensions.ExtensionRegistry extReg) 233 throws javax.wsdl.WSDLException { 234 Trc.entry(this, parentType, elementType, el, def, extReg); 235 236 238 javax.wsdl.extensions.ExtensibilityElement returnValue = null; 239 240 if (JavaBindingConstants.Q_ELEM_JAVA_BINDING.equals(elementType)) { 241 JavaBinding javaBinding = new JavaBinding(); 242 Trc.exit(javaBinding); 243 return javaBinding; 244 } else if (JavaBindingConstants.Q_ELEM_JAVA_OPERATION.equals(elementType)) { 245 JavaOperation javaOperation = new JavaOperation(); 246 247 String methodName = DOMUtils.getAttribute(el, "methodName"); 248 if (methodName != null) { 250 javaOperation.setMethodName(methodName); 251 } 252 253 String methodType = DOMUtils.getAttribute(el, "methodType"); 254 if (methodType != null) { 255 javaOperation.setMethodType(methodType); 256 } 257 258 String parameterOrder = DOMUtils.getAttribute(el, "parameterOrder"); 259 if (parameterOrder != null) { 260 javaOperation.setParameterOrder(parameterOrder); 261 } 262 263 String returnPart = DOMUtils.getAttribute(el, "returnPart"); 264 if (returnPart != null) { 265 javaOperation.setReturnPart(returnPart); 266 } 267 Trc.exit(javaOperation); 268 return javaOperation; 269 } else if (JavaBindingConstants.Q_ELEM_JAVA_ADDRESS.equals(elementType)) { 270 JavaAddress javaAddress = new JavaAddress(); 271 272 String className = DOMUtils.getAttribute(el, "className"); 273 if (className != null) { 274 javaAddress.setClassName(className); 275 } 276 277 String classPath = DOMUtils.getAttribute(el, "classPath"); 278 if (classPath != null) { 279 javaAddress.setClassPath(classPath); 280 } 281 282 String classLoader = DOMUtils.getAttribute(el, "classLoader"); 283 if (classLoader != null) { 284 javaAddress.setClassLoader(classLoader); 285 } 286 Trc.exit(javaAddress); 287 return javaAddress; 288 } 289 Trc.exit(returnValue); 290 return returnValue; 291 } 292 } | Popular Tags |