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