Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2013 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * http://glassfish.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package com.sun.tools.ws.wsdl.parser;
 
 
 import java.util.Map;


Author(s):
Vivek Pandey jaxws:bindings exension handler.
 
 
     // xml security enabled always, xpath used for parsing "part" attribute
     private static final XPathFactory xpf = XmlUtil.newXPathFactory(true);
     private final XPath xpath = .newXPath();
 
     public JAXWSBindingExtensionHandler(Map<StringAbstractExtensionHandlerextensionHandlerMap) {
         super(extensionHandlerMap);
     }
 
     /* (non-Javadoc)
      * @see AbstractExtensionHandler#getNamespaceURI()
      */
     @Override
     public String getNamespaceURI() {
         return .;
     }

    

Parameters:
context
parent
e
 
     private boolean parseGlobalJAXWSBindings(TWSDLParserContext contextTWSDLExtensible parentElement e) {
         context.push();
         context.registerNamespaces(e);
 
         JAXWSBinding jaxwsBinding =  getJAXWSExtension(parent);
         if(jaxwsBinding == null) {
             jaxwsBinding = new JAXWSBinding(context.getLocation(e));
         }
        if (attr != null) {
            jaxwsBinding.setWsdlLocation(attr);
        }
        attr = XmlUtil.getAttributeOrNull(e.);
        if (attr != null) {
            jaxwsBinding.setNode(attr);
        }
        attr = XmlUtil.getAttributeOrNull(e.);
        if (attr != null) {
            jaxwsBinding.setVersion(attr);
        }
        for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
            Element e2 = Util.nextElement(iter);
            if (e2 == null) {
                break;
            }
            if (XmlUtil.matchesTagNS(e2.)) {
                parsePackage(contextjaxwsBindinge2);
                if ((jaxwsBinding.getJaxwsPackage() != null) && (jaxwsBinding.getJaxwsPackage().getJavaDoc() != null)) {
                    ((Definitionsparent).setDocumentation(new Documentation(jaxwsBinding.getJaxwsPackage().getJavaDoc()));
                }
            } else if (XmlUtil.matchesTagNS(e2.)) {
                parseWrapperStyle(contextjaxwsBindinge2);
            } else if (XmlUtil.matchesTagNS(e2.)) {
                parseAsynMapping(contextjaxwsBindinge2);
            } //            else if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
            //                parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
            //            }
            else if (XmlUtil.matchesTagNS(e2.)) {
                parseMimeContent(contextjaxwsBindinge2);
            } else {
                Util.fail(
                        "parsing.invalidExtensionElement",
                        e2.getTagName(),
                        e2.getNamespaceURI());
                return false;
            }
        }
        parent.addExtension(jaxwsBinding);
        context.pop();
//        context.fireDoneParsingEntity(
//                JAXWSBindingsConstants.JAXWS_BINDINGS,
//                jaxwsBinding);
        return true;
    }
    private static JAXWSBinding getJAXWSExtension(TWSDLExtensible extensible) {
        for (TWSDLExtension extension:extensible.extensions()) {
            if (extension.getClass().equals(JAXWSBinding.class)) {
                return (JAXWSBinding)extension;
            }
        }
        return null;
    }

    

Parameters:
context
parent
e
    private void parseProvider(com.sun.tools.ws.api.wsdl.TWSDLParserContext contextJAXWSBinding parentElement e) {
        String val = e.getTextContent();
        if (val == null) {
            return;
        }
        if (val.equals("false") || val.equals("0")) {
            ((JAXWSBinding)parent).setProvider(.);
        } else if(val.equals("true") || val.equals("1")) {
            ((JAXWSBinding)parent).setProvider(.);
        }
    }

    

Parameters:
context
parent
e
    private void parsePackage(com.sun.tools.ws.api.wsdl.TWSDLParserContext contextJAXWSBinding parentElement e) {
        //System.out.println("In handlePackageExtension: " + e.getNodeName());
        String packageName = XmlUtil.getAttributeOrNull(e.);
        JAXWSBinding binding = (JAXWSBinding)parent;
        binding.setJaxwsPackage(new CustomName(packageNamegetJavaDoc(e)));
    }

    

Parameters:
context
parent
e
    private void parseWrapperStyle(com.sun.tools.ws.api.wsdl.TWSDLParserContext contextJAXWSBinding parentElement e) {
        //System.out.println("In handleWrapperStyleExtension: " + e.getNodeName());
        String val = e.getTextContent();
        if (val == null) {
            return;
        }
        if (val.equals("false") || val.equals("0")) {
            ((JAXWSBindingparent).setEnableWrapperStyle(.);
        } else if (val.equals("true") || val.equals("1")) {
            ((JAXWSBindingparent).setEnableWrapperStyle(.);
        }
    }

    

Parameters:
context
parent
e
//    private void parseAdditionalSOAPHeaderMapping(TWSDLParserContextImpl context, TWSDLExtensible parent, Element e) {
//        //System.out.println("In handleAdditionalSOAPHeaderExtension: " + e.getNodeName());
//        String val = e.getTextContent();
//        if(val == null)
//            return;
//        if(val.equals("false") || val.equals("0")){
//            ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.FALSE);
//        }else if(val.equals("true") || val.equals("1")){
//            ((JAXWSBinding)parent).setEnableAdditionalHeaderMapping(Boolean.TRUE);
//        }
//    }

    

Parameters:
context
parent
e
    private void parseAsynMapping(com.sun.tools.ws.api.wsdl.TWSDLParserContext contextJAXWSBinding parentElement e) {
        //System.out.println("In handleAsynMappingExtension: " + e.getNodeName());
        String val = e.getTextContent();
        if (val == null) {
            return;
        }
        if (val.equals("false") || val.equals("0")) {
            ((JAXWSBindingparent).setEnableAsyncMapping(.);
        } else if (val.equals("true") || val.equals("1")) {
            ((JAXWSBindingparent).setEnableAsyncMapping(.);
        }
    }

    

Parameters:
context
parent
e
    private void parseMimeContent(com.sun.tools.ws.api.wsdl.TWSDLParserContext contextJAXWSBinding parentElement e) {
        //System.out.println("In handleMimeContentExtension: " + e.getNodeName());
        String val = e.getTextContent();
        if (val == null) {
            return;
        }
        if (val.equals("false") || val.equals("0")) {
            ((JAXWSBindingparent).setEnableMimeContentMapping(.);
        } else if (val.equals("true") || val.equals("1")) {
            ((JAXWSBindingparent).setEnableMimeContentMapping(.);
        }
    }

    

Parameters:
context
jaxwsBinding
e
    private void parseMethod(com.sun.tools.ws.api.wsdl.TWSDLParserContext contextJAXWSBinding jaxwsBindingElement e) {
        String methodName = XmlUtil.getAttributeOrNull(e.);
        String javaDoc = getJavaDoc(e);
        CustomName name = new CustomName(methodNamejavaDoc);
        jaxwsBinding.setMethodName(name);
    }

    

Parameters:
context
jaxwsBinding
e
    private void parseParameter(com.sun.tools.ws.api.wsdl.TWSDLParserContext contextJAXWSBinding jaxwsBindingElement e) {
        String part = XmlUtil.getAttributeOrNull(e.);
        Element msgPartElm = evaluateXPathNode(e.getOwnerDocument(), partnew NamespaceContextImpl(e));
        Node msgElm = msgPartElm.getParentNode();
        //MessagePart msgPart = new MessagePart();
        String partName = XmlUtil.getAttributeOrNull(msgPartElm"name");
        String msgName = XmlUtil.getAttributeOrNull((Element)msgElm"name");
        if ((partName == null) || (msgName == null)) {
            return;
        }
        String element = XmlUtil.getAttributeOrNull(e.);
        String name = XmlUtil.getAttributeOrNull(e.);
        QName elementName = null;
        if(element != null){
            String uri = e.lookupNamespaceURI(XmlUtil.getPrefix(element));
            elementName = (uri == null)?null:new QName(uri, XmlUtil.getLocalPart(element));
        }
        jaxwsBinding.addParameter(new Parameter(msgNamepartNameelementNamename));
    }
    private Element evaluateXPathNode(Node targetString expressionNamespaceContext namespaceContext) {
        NodeList nlst;
        try {
            .setNamespaceContext(namespaceContext);
            nlst = (NodeList).evaluate(expressiontarget.);
        } catch (XPathExpressionException e) {
            Util.fail("internalizer.XPathEvaluationError"e.getMessage());
            return null// abort processing this <jaxb:bindings>
        }
        ifnlst.getLength()==0 ) {
            Util.fail("internalizer.XPathEvaluatesToNoTarget"new Object[]{expression});
            return null// abort
        }
        ifnlst.getLength()!=1 ) {
            Util.fail("internalizer.XPathEvaulatesToTooManyTargets"new Object[]{expressionnlst.getLength()});
            return null// abort
        }
        Node rnode = nlst.item(0);
        if(!(rnode instanceof Element )) {
            Util.fail("internalizer.XPathEvaluatesToNonElement"new Object[]{expression});
            return null// abort
        }
        return (Element)rnode;
    }

    

Parameters:
context
jaxwsBinding
e
    private void parseClass(com.sun.tools.ws.api.wsdl.TWSDLParserContext contextJAXWSBinding jaxwsBindingElement e) {
        String className = XmlUtil.getAttributeOrNull(e.);
        String javaDoc = getJavaDoc(e);
        jaxwsBinding.setClassName(new CustomName(classNamejavaDoc));
    }
    @Override
    public boolean handleDefinitionsExtension(TWSDLParserContext contextTWSDLExtensible parentElement e) {
        return parseGlobalJAXWSBindings(contextparente);
    }
    @Override
    public boolean handlePortTypeExtension(TWSDLParserContext contextTWSDLExtensible parentElement e) {
        if(XmlUtil.matchesTagNS(e.)){
            context.push();
            context.registerNamespaces(e);
            JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
            for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
                Element e2 = Util.nextElement(iter);
                if (e2 == null) {
                    break;
                }
                if (XmlUtil.matchesTagNS(e2.)) {
                    parseWrapperStyle(contextjaxwsBindinge2);
                } else if (XmlUtil.matchesTagNS(e2.)) {
                    parseAsynMapping(contextjaxwsBindinge2);
                } else if (XmlUtil.matchesTagNS(e2.)) {
                    parseClass(contextjaxwsBindinge2);
                    if ((jaxwsBinding.getClassName() != null) && (jaxwsBinding.getClassName().getJavaDoc() != null) && (parent instanceof PortType)) {
                        ((PortTypeparent).setDocumentation(new Documentation(jaxwsBinding.getClassName().getJavaDoc()));
                    }
                } else {
                    Util.fail(
                            "parsing.invalidExtensionElement",
                            e2.getTagName(),
                            e2.getNamespaceURI());
                    return false;
                }
            }
            parent.addExtension(jaxwsBinding);
            context.pop();
//            context.fireDoneParsingEntity(
//                    JAXWSBindingsConstants.JAXWS_BINDINGS,
//                    jaxwsBinding);
            return true;
        }else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false;
        }
    }
    @Override
    public boolean handleOperationExtension(TWSDLParserContext contextTWSDLExtensible parentElement e) {
        if(XmlUtil.matchesTagNS(e.)){
            if(parent instanceof Operation){
                return handlePortTypeOperation(context, (Operation)parente);
            }else if(parent instanceof BindingOperation){
                return handleBindingOperation(context, (BindingOperation)parente);
            }
        }else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false;
        }
        return false;
    }
    private boolean handleBindingOperation(TWSDLParserContext contextBindingOperation operationElement e) {
        if(XmlUtil.matchesTagNS(e.)){
            context.push();
            context.registerNamespaces(e);
            JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
            for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
                Element e2 = Util.nextElement(iter);
                if (e2 == null) {
                    break;
                }
//                if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
//                    parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
//                }else
                if(XmlUtil.matchesTagNS(e2.)){
                    parseMimeContent(contextjaxwsBindinge2);
                }else if(XmlUtil.matchesTagNS(e2.)){
                    parseParameter(contextjaxwsBindinge2);
                }else{
                    Util.fail(
                        "parsing.invalidExtensionElement",
                        e2.getTagName(),
                        e2.getNamespaceURI());
                    return false;
                }
            }
            operation.addExtension(jaxwsBinding);
            context.pop();
//            context.fireDoneParsingEntity(
//                    JAXWSBindingsConstants.JAXWS_BINDINGS,
//                    jaxwsBinding);
            return true;
        }else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false;
        }
    }
    private boolean handlePortTypeOperation(TWSDLParserContext contextOperation parentElement e) {
        context.push();
        context.registerNamespaces(e);
        JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
        for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
            Element e2 = Util.nextElement(iter);
            if (e2 == null) {
                break;
            }
            if(XmlUtil.matchesTagNS(e2.)){
                parseWrapperStyle(contextjaxwsBindinge2);
            }else if(XmlUtil.matchesTagNS(e2.)){
                parseAsynMapping(contextjaxwsBindinge2);
            }else if(XmlUtil.matchesTagNS(e2.)){
                parseMethod(contextjaxwsBindinge2);
                if((jaxwsBinding.getMethodName() != null) && (jaxwsBinding.getMethodName().getJavaDoc() != null)){
                    parent.setDocumentation(new Documentation(jaxwsBinding.getMethodName().getJavaDoc()));
                }
            }else if(XmlUtil.matchesTagNS(e2.)){
                parseParameter(contextjaxwsBindinge2);
            }else{
                Util.fail(
                    "parsing.invalidExtensionElement",
                    e2.getTagName(),
                    e2.getNamespaceURI());
                return false;
            }
        }
        parent.addExtension(jaxwsBinding);
        context.pop();
//        context.fireDoneParsingEntity(
//                JAXWSBindingsConstants.JAXWS_BINDINGS,
//                jaxwsBinding);
        return true;
    }
    @Override
    public boolean handleBindingExtension(TWSDLParserContext contextTWSDLExtensible parentElement e) {
        if(XmlUtil.matchesTagNS(e.)){
            context.push();
            context.registerNamespaces(e);
            JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
            for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
                Element e2 = Util.nextElement(iter);
                if (e2 == null) {
                    break;
                }
//                if(XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){
//                    parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2);
//                }else
                if(XmlUtil.matchesTagNS(e2.)){
                    parseMimeContent(contextjaxwsBindinge2);
                }else{
                    Util.fail(
                        "parsing.invalidExtensionElement",
                        e2.getTagName(),
                        e2.getNamespaceURI());
                    return false;
                }
            }
            parent.addExtension(jaxwsBinding);
            context.pop();
//            context.fireDoneParsingEntity(
//                    JAXWSBindingsConstants.JAXWS_BINDINGS,
//                    jaxwsBinding);
            return true;
        }else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false;
        }
    }
    /* (non-Javadoc)
     * @see ExtensionHandlerBase#handleFaultExtension(TWSDLParserContextImpl, TWSDLExtensible, org.w3c.dom.Element)
     */
    @Override
    public boolean handleFaultExtension(TWSDLParserContext contextTWSDLExtensible parentElement e) {
        if(XmlUtil.matchesTagNS(e.)){
            context.push();
            context.registerNamespaces(e);
            JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
            for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
                Element e2 = Util.nextElement(iter);
                if (e2 == null) {
                    break;
                }
                if(XmlUtil.matchesTagNS(e2.)){
                    parseClass(contextjaxwsBindinge2);
                    if((jaxwsBinding.getClassName() != null) && (jaxwsBinding.getClassName().getJavaDoc() != null)){
                        ((Fault)parent).setDocumentation(new Documentation(jaxwsBinding.getClassName().getJavaDoc()));
                    }
                }else{
                    Util.fail(
                        "parsing.invalidExtensionElement",
                        e2.getTagName(),
                        e2.getNamespaceURI());
                    return false;
                }
            }
            parent.addExtension(jaxwsBinding);
            context.pop();
//            context.fireDoneParsingEntity(
//                    JAXWSBindingsConstants.JAXWS_BINDINGS,
//                    jaxwsBinding);
            return true;
        }else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false;
        }
    }
    @Override
    public boolean handleServiceExtension(TWSDLParserContext contextTWSDLExtensible parentElement e) {
        if(XmlUtil.matchesTagNS(e.)){
            context.push();
            context.registerNamespaces(e);
            JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
            for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
                Element e2 = Util.nextElement(iter);
                if (e2 == null) {
                    break;
                }
                if(XmlUtil.matchesTagNS(e2.)){
                    parseClass(contextjaxwsBindinge2);
                    if((jaxwsBinding.getClassName() != null) && (jaxwsBinding.getClassName().getJavaDoc() != null)){
                        ((Service)parent).setDocumentation(new Documentation(jaxwsBinding.getClassName().getJavaDoc()));
                    }
                }else{
                    Util.fail(
                        "parsing.invalidExtensionElement",
                        e2.getTagName(),
                        e2.getNamespaceURI());
                    return false;
                }
            }
            parent.addExtension(jaxwsBinding);
            context.pop();
//            context.fireDoneParsingEntity(
//                    JAXWSBindingsConstants.JAXWS_BINDINGS,
//                    jaxwsBinding);
            return true;
        }else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false;
        }
    }
    @Override
    public boolean handlePortExtension(TWSDLParserContext contextTWSDLExtensible parentElement e) {
        if(XmlUtil.matchesTagNS(e.)){
            context.push();
            context.registerNamespaces(e);
            JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e));
            for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
                Element e2 = Util.nextElement(iter);
                if (e2 == null) {
                    break;
                }
                if(XmlUtil.matchesTagNS(e2.)){
                    parseProvider(contextjaxwsBindinge2);
                }else if(XmlUtil.matchesTagNS(e2.)){
                    parseMethod(contextjaxwsBindinge2);
                    if((jaxwsBinding.getMethodName() != null) && (jaxwsBinding.getMethodName().getJavaDoc() != null)){
                        ((Port)parent).setDocumentation(new Documentation(jaxwsBinding.getMethodName().getJavaDoc()));
                    }
                }else{
                    Util.fail(
                        "parsing.invalidExtensionElement",
                        e2.getTagName(),
                        e2.getNamespaceURI());
                    return false;
                }
            }
            parent.addExtension(jaxwsBinding);
            context.pop();
//            context.fireDoneParsingEntity(
//                    JAXWSBindingsConstants.JAXWS_BINDINGS,
//                    jaxwsBinding);
            return true;
        }else {
            Util.fail(
                "parsing.invalidExtensionElement",
                e.getTagName(),
                e.getNamespaceURI());
            return false;
        }
    }
    private String getJavaDoc(Element e){
        for(Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();){
            Element e2 = Util.nextElement(iter);
            if (e2 == null) {
                break;
            }
            if(XmlUtil.matchesTagNS(e2.)){
                return XmlUtil.getTextForNode(e2);
            }
        }
        return null;
    }
New to GrepCode? Check out our FAQ X