1 57 58 package org.apache.wsif.wsdl.extensions.ejb; 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 79 public class EJBBindingSerializer 80 implements ExtensionSerializer, ExtensionDeserializer, Serializable { 81 82 private static final long serialVersionUID = 1L; 83 84 public void marshall( 85 Class parentType, 86 QName elementType, 87 javax.wsdl.extensions.ExtensibilityElement extension, 88 java.io.PrintWriter pw, 89 javax.wsdl.Definition def, 90 javax.wsdl.extensions.ExtensionRegistry extReg) 91 throws javax.wsdl.WSDLException { 92 Trc.entry(this, parentType, elementType, extension, pw, def, extReg); 93 if (extension == null) { 94 Trc.exit(); 95 return; 96 } 97 98 if (extension instanceof EJBBinding) { 99 EJBBinding ejbBinding = (EJBBinding) extension; 100 pw.print(" <ejb:binding"); 101 102 Boolean required = extension.getRequired(); 103 if (required != null) { 104 DOMUtils.printQualifiedAttribute( 105 Constants.Q_ATTR_REQUIRED, 106 required.toString(), 107 def, 108 pw); 109 } 110 111 pw.println("/>"); 112 } else if (extension instanceof EJBOperation) { 113 EJBOperation ejbOperation = (EJBOperation) extension; 114 pw.print(" <ejb:operation"); 115 116 if (ejbOperation.getMethodName() != null) { 117 DOMUtils.printAttribute("methodName", ejbOperation.getMethodName(), pw); 118 } 119 120 if (ejbOperation.getEjbInterface() != null) { 121 DOMUtils.printAttribute("interface", ejbOperation.getEjbInterface(), pw); 122 } 123 124 if (ejbOperation.getParameterOrder() != null) { 125 DOMUtils.printAttribute( 126 "parameterOrder", 127 StringUtils.getNMTokens(ejbOperation.getParameterOrder()), 128 pw); 129 } 130 131 if (ejbOperation.getReturnPart() != null) { 132 DOMUtils.printAttribute("returnPart", ejbOperation.getReturnPart(), pw); 133 } 134 135 Boolean required = extension.getRequired(); 136 if (required != null) { 137 DOMUtils.printQualifiedAttribute( 138 Constants.Q_ATTR_REQUIRED, 139 required.toString(), 140 def, 141 pw); 142 } 143 144 pw.println("/>"); 145 } else if (extension instanceof EJBAddress) { 146 EJBAddress ejbAddress = (EJBAddress) extension; 147 pw.print(" <ejb:address"); 148 149 if (ejbAddress.getClassName() != null) { 150 DOMUtils.printAttribute("className", ejbAddress.getClassName(), pw); 151 } 152 153 if (ejbAddress.getArchive() != null) { 154 DOMUtils.printAttribute("archive", ejbAddress.getArchive(), pw); 155 } 156 157 if (ejbAddress.getClassLoader() != null) { 158 DOMUtils.printAttribute("classLoader", ejbAddress.getClassLoader(), pw); 159 } 160 161 if (ejbAddress.getJndiName() != null) { 162 DOMUtils.printAttribute("jndiName", ejbAddress.getJndiName(), pw); 163 } 164 165 if (ejbAddress.getJndiProviderURL() != null) { 166 DOMUtils.printAttribute("jndiProviderURL", ejbAddress.getJndiProviderURL(), pw); 167 } 168 169 if (ejbAddress.getInitialContextFactory() != null) { 170 DOMUtils.printAttribute( 171 "initialContextFactory", 172 ejbAddress.getInitialContextFactory(), 173 pw); 174 } 175 176 Boolean required = extension.getRequired(); 177 if (required != null) { 178 DOMUtils.printQualifiedAttribute( 179 Constants.Q_ATTR_REQUIRED, 180 required.toString(), 181 def, 182 pw); 183 } 184 185 pw.println("/>"); 186 } 187 Trc.exit(); 188 } 189 190 193 public void registerSerializer(ExtensionRegistry registry) { 194 Trc.entry(this, registry); 195 registry.registerSerializer( 197 javax.wsdl.Binding.class, 198 EJBBindingConstants.Q_ELEM_EJB_BINDING, 199 this); 200 registry.registerDeserializer( 201 javax.wsdl.Binding.class, 202 EJBBindingConstants.Q_ELEM_EJB_BINDING, 203 this); 204 registry.mapExtensionTypes( 205 javax.wsdl.Binding.class, 206 EJBBindingConstants.Q_ELEM_EJB_BINDING, 207 EJBBinding.class); 208 209 registry.registerSerializer( 211 javax.wsdl.BindingOperation.class, 212 EJBBindingConstants.Q_ELEM_EJB_OPERATION, 213 this); 214 registry.registerDeserializer( 215 javax.wsdl.BindingOperation.class, 216 EJBBindingConstants.Q_ELEM_EJB_OPERATION, 217 this); 218 registry.mapExtensionTypes( 219 javax.wsdl.BindingOperation.class, 220 EJBBindingConstants.Q_ELEM_EJB_OPERATION, 221 EJBOperation.class); 222 223 registry.registerSerializer( 225 javax.wsdl.Port.class, 226 EJBBindingConstants.Q_ELEM_EJB_ADDRESS, 227 this); 228 registry.registerDeserializer( 229 javax.wsdl.Port.class, 230 EJBBindingConstants.Q_ELEM_EJB_ADDRESS, 231 this); 232 registry.mapExtensionTypes( 233 javax.wsdl.Port.class, 234 EJBBindingConstants.Q_ELEM_EJB_ADDRESS, 235 EJBAddress.class); 236 Trc.exit(); 237 } 238 239 public javax.wsdl.extensions.ExtensibilityElement unmarshall( 240 Class parentType, 241 javax.xml.namespace.QName elementType, 242 org.w3c.dom.Element el, 243 javax.wsdl.Definition def, 244 javax.wsdl.extensions.ExtensionRegistry extReg) 245 throws javax.wsdl.WSDLException { 246 Trc.entry(this, parentType, elementType, el, def, extReg); 247 248 javax.wsdl.extensions.ExtensibilityElement returnValue = null; 249 250 if (EJBBindingConstants.Q_ELEM_EJB_BINDING.equals(elementType)) { 251 EJBBinding ejbBinding = new EJBBinding(); 252 Trc.exit(ejbBinding); 253 return ejbBinding; 254 } else if (EJBBindingConstants.Q_ELEM_EJB_OPERATION.equals(elementType)) { 255 EJBOperation ejbOperation = new EJBOperation(); 256 257 String methodName = DOMUtils.getAttribute(el, "methodName"); 258 259 if (methodName != null) { 260 ejbOperation.setMethodName(methodName); 261 } 262 263 String ejbInterface = DOMUtils.getAttribute(el, "interface"); 264 if (ejbInterface != null) { 265 ejbOperation.setEjbInterface(ejbInterface); 266 } 267 268 String parameterOrder = DOMUtils.getAttribute(el, "parameterOrder"); 269 if (parameterOrder != null) { 270 ejbOperation.setParameterOrder(parameterOrder); 271 } 272 273 String returnPart = DOMUtils.getAttribute(el, "returnPart"); 274 if (returnPart != null) { 275 ejbOperation.setReturnPart(returnPart); 276 } 277 Trc.exit(ejbOperation); 278 return ejbOperation; 279 } else if (EJBBindingConstants.Q_ELEM_EJB_ADDRESS.equals(elementType)) { 280 EJBAddress ejbAddress = new EJBAddress(); 281 282 String className = DOMUtils.getAttribute(el, "className"); 283 if (className != null) { 284 ejbAddress.setClassName(className); 285 } 286 287 String archive = DOMUtils.getAttribute(el, "archive"); 288 if (archive != null) { 289 ejbAddress.setArchive(archive); 290 } 291 292 String classLoader = DOMUtils.getAttribute(el, "classLoader"); 293 if (classLoader != null) { 294 ejbAddress.setClassLoader(classLoader); 295 } 296 297 String jndiName = DOMUtils.getAttribute(el, "jndiName"); 298 if (jndiName != null) { 299 ejbAddress.setJndiName(jndiName); 300 } 301 302 String jndiProviderURL = DOMUtils.getAttribute(el, "jndiProviderURL"); 303 if (jndiProviderURL != null) { 304 ejbAddress.setJndiProviderURL(jndiProviderURL); 305 } 306 307 String icf = DOMUtils.getAttribute(el, "initialContextFactory"); 308 if (icf != null) { 309 ejbAddress.setInitialContextFactory(icf); 310 } 311 Trc.exit(ejbAddress); 312 return ejbAddress; 313 } 314 Trc.exit(returnValue); 315 return returnValue; 316 } 317 } | Popular Tags |