1 16 package org.objectweb.petals.component.common.wsdl; 17 18 import java.net.URI ; 19 20 import javax.jbi.messaging.MessageExchange.Role; 21 import javax.wsdl.Definition; 22 import javax.wsdl.WSDLException; 23 import javax.wsdl.extensions.ExtensibilityElement; 24 import javax.wsdl.extensions.ExtensionDeserializer; 25 import javax.wsdl.extensions.ExtensionRegistry; 26 import javax.xml.namespace.QName ; 27 28 import org.w3c.dom.Element ; 29 30 import com.ibm.wsdl.util.xml.DOMUtils; 31 32 public class JbiEndpointDeserializer implements ExtensionDeserializer { 33 34 public ExtensibilityElement unmarshall( 35 Class parentType, 36 QName elementType, 37 Element el, 38 Definition def, 39 ExtensionRegistry extReg) 40 throws WSDLException { 41 42 JbiEndpoint jbiEndpoint = (JbiEndpoint) extReg.createExtension(parentType, elementType); 43 44 String role = DOMUtils.getAttribute(el, JbiExtension.ROLE); 45 if (role == null) { 46 throw new WSDLException(WSDLException.OTHER_ERROR, "Role must be specified"); 47 } else if (JbiExtension.ROLE_CONSUMER.equals(role)) { 48 jbiEndpoint.setRole(Role.CONSUMER); 49 } else if (JbiExtension.ROLE_PROVIDER.equals(role)) { 50 jbiEndpoint.setRole(Role.PROVIDER); 51 } else { 52 throw new WSDLException(WSDLException.OTHER_ERROR, "Unrecognized role: " + role); 53 } 54 55 String defaultMep = DOMUtils.getAttribute(el, JbiExtension.DEFAULT_MEP); 56 if (defaultMep == null) { 57 defaultMep = JbiExtension.DEFAULT_MEP_IN_OUT; 58 } 59 if (JbiExtension.DEFAULT_MEP_IN_ONLY.equals(defaultMep) || 60 JbiExtension.DEFAULT_MEP_ROBUST_IN_ONLY.equals(defaultMep) || 61 JbiExtension.DEFAULT_MEP_IN_OUT.equals(defaultMep)) { 62 jbiEndpoint.setDefaultMep(URI.create(JbiExtension.WSDL2_NS + defaultMep)); 63 } 64 65 QName defaultOperation = DOMUtils.getQualifiedAttributeValue(el, JbiExtension.DEFAULT_OPERATION, null, false, def); 66 if (defaultOperation != null) { 67 jbiEndpoint.setDefaultOperation(defaultOperation); 68 } 69 70 return jbiEndpoint; 71 } 72 73 } 74 | Popular Tags |