Java Code Examples for com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil#nextElementContent()

The following examples show how to use com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil#nextElementContent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXBMessage.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public XMLStreamReader readPayload() throws XMLStreamException {
   try {
        if(infoset==null) {
                            if (rawContext != null) {
                    XMLStreamBufferResult sbr = new XMLStreamBufferResult();
                                    Marshaller m = rawContext.createMarshaller();
                                    m.setProperty("jaxb.fragment", Boolean.TRUE);
                                    m.marshal(jaxbObject, sbr);
                    infoset = sbr.getXMLStreamBuffer();
                            } else {
                                MutableXMLStreamBuffer buffer = new MutableXMLStreamBuffer();
                                writePayloadTo(buffer.createFromXMLStreamWriter());
                                infoset = buffer;
                            }
        }
        XMLStreamReader reader = infoset.readAsXMLStreamReader();
        if(reader.getEventType()== START_DOCUMENT)
            XMLStreamReaderUtil.nextElementContent(reader);
        return reader;
    } catch (JAXBException e) {
       // bug 6449684, spec 4.3.4
       throw new WebServiceException(e);
    }
}
 
Example 2
Source File: RuntimeWSDLParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void parseInputBinding(XMLStreamReader reader, EditableWSDLBoundOperation bindingOp) {
    boolean bodyFound = false;
    extensionFacade.bindingOperationInputAttributes(bindingOp, reader);
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        QName name = reader.getName();
        if ((SOAPConstants.QNAME_BODY.equals(name) || SOAPConstants.QNAME_SOAP12BODY.equals(name)) && !bodyFound) {
            bodyFound = true;
            bindingOp.setInputExplicitBodyParts(parseSOAPBodyBinding(reader, bindingOp, BindingMode.INPUT));
            goToEnd(reader);
        } else if ((SOAPConstants.QNAME_HEADER.equals(name) || SOAPConstants.QNAME_SOAP12HEADER.equals(name))) {
            parseSOAPHeaderBinding(reader, bindingOp.getInputParts());
        } else if (MIMEConstants.QNAME_MULTIPART_RELATED.equals(name)) {
            parseMimeMultipartBinding(reader, bindingOp, BindingMode.INPUT);
        } else {
            extensionFacade.bindingOperationInputElements(bindingOp, reader);
        }
    }
}
 
Example 3
Source File: WsimportOptions.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Exposing it as a public method to allow external tools such as NB to read from wsdl model and work on it.
 * TODO: WSDL model needs to be exposed - basically at tool time we need to use the runtimw wsdl model
 *
 * Binding files could be jaxws or jaxb. This method identifies jaxws and jaxb binding files and keeps them separately. jaxb binding files are given separately
 * to JAXB in {@link com.sun.tools.internal.ws.processor.modeler.wsdl.JAXBModelBuilder}
 *
 * @param receiver {@link ErrorReceiver}
 */
public final void parseBindings(ErrorReceiver receiver){
    for (InputSource is : bindingFiles) {
        XMLStreamReader reader =
                XMLStreamReaderFactory.create(is,true);
        XMLStreamReaderUtil.nextElementContent(reader);
        if (reader.getName().equals(JAXWSBindingsConstants.JAXWS_BINDINGS)) {
            jaxwsCustomBindings.add(new RereadInputSource(is));
        } else if (reader.getName().equals(JAXWSBindingsConstants.JAXB_BINDINGS) ||
                reader.getName().equals(new QName(SchemaConstants.NS_XSD, "schema"))) {
            jaxbCustomBindings.add(new RereadInputSource(is));
        } else {
            LocatorImpl locator = new LocatorImpl();
            locator.setSystemId(reader.getLocation().getSystemId());
            locator.setPublicId(reader.getLocation().getPublicId());
            locator.setLineNumber(reader.getLocation().getLineNumber());
            locator.setColumnNumber(reader.getLocation().getColumnNumber());
            receiver.warning(locator, ConfigurationMessages.CONFIGURATION_NOT_BINDING_FILE(is.getSystemId()));
        }
    }
}
 
Example 4
Source File: RuntimeWSDLParser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void parseMessage(XMLStreamReader reader) {
    String msgName = ParserUtil.getMandatoryNonEmptyAttribute(reader, WSDLConstants.ATTR_NAME);
    EditableWSDLMessage msg = new WSDLMessageImpl(reader,new QName(targetNamespace, msgName));
    extensionFacade.messageAttributes(msg, reader);
    int partIndex = 0;
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        QName name = reader.getName();
        if (WSDLConstants.QNAME_PART.equals(name)) {
            String part = ParserUtil.getMandatoryNonEmptyAttribute(reader, WSDLConstants.ATTR_NAME);
            String desc = null;
            int index = reader.getAttributeCount();
            WSDLDescriptorKind kind = WSDLDescriptorKind.ELEMENT;
            for (int i = 0; i < index; i++) {
                QName descName = reader.getAttributeName(i);
                if (descName.getLocalPart().equals("element"))
                    kind = WSDLDescriptorKind.ELEMENT;
                else if (descName.getLocalPart().equals("type"))
                    kind = WSDLDescriptorKind.TYPE;

                if (descName.getLocalPart().equals("element") || descName.getLocalPart().equals("type")) {
                    desc = reader.getAttributeValue(i);
                    break;
                }
            }
            if (desc != null) {
                EditableWSDLPart wsdlPart = new WSDLPartImpl(reader, part, partIndex, new WSDLPartDescriptorImpl(reader,ParserUtil.getQName(reader, desc), kind));
                msg.add(wsdlPart);
            }
            if (reader.getEventType() != XMLStreamConstants.END_ELEMENT)
                goToEnd(reader);
        } else {
            extensionFacade.messageElements(msg, reader);
        }
    }
    wsdlDoc.addMessage(msg);
    if (reader.getEventType() != XMLStreamConstants.END_ELEMENT)
        goToEnd(reader);
}
 
Example 5
Source File: StreamMessage.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static XMLStreamBuffer cacheHeaders(XMLStreamReader reader,
        Map<String, String> namespaces, HeaderList headers,
        StreamHeaderDecoder headerDecoder) throws XMLStreamException {
    MutableXMLStreamBuffer buffer = createXMLStreamBuffer();
    StreamReaderBufferCreator creator = new StreamReaderBufferCreator();
    creator.setXMLStreamBuffer(buffer);

    // Reader is positioned at the first header block
    while(reader.getEventType() == javax.xml.stream.XMLStreamConstants.START_ELEMENT) {
        Map<String,String> headerBlockNamespaces = namespaces;

        // Collect namespaces on SOAP header block
        if (reader.getNamespaceCount() > 0) {
            headerBlockNamespaces = new HashMap<String,String>(namespaces);
            for (int i = 0; i < reader.getNamespaceCount(); i++) {
                headerBlockNamespaces.put(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
            }
        }

        // Mark
        XMLStreamBuffer mark = new XMLStreamBufferMark(headerBlockNamespaces, creator);
        // Create Header
        headers.add(headerDecoder.decodeHeader(reader, mark));


        // Cache the header block
        // After caching Reader will be positioned at next header block or
        // the end of the </soap:header>
        creator.createElementFragment(reader, false);
        if (reader.getEventType() != XMLStreamConstants.START_ELEMENT &&
                reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
            XMLStreamReaderUtil.nextElementContent(reader);
        }
    }

    return buffer;
}
 
Example 6
Source File: RuntimeWSDLParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void parseMimeMultipartBinding(XMLStreamReader reader, EditableWSDLBoundOperation op, BindingMode mode) {
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        QName name = reader.getName();
        if (MIMEConstants.QNAME_PART.equals(name)) {
            parseMIMEPart(reader, op, mode);
        } else {
            XMLStreamReaderUtil.skipElement(reader);
        }
    }
}
 
Example 7
Source File: ExternalMetadataReader.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static String documentRootNamespace(Source src, boolean disableXmlSecurity) throws XMLStreamException {
    XMLInputFactory factory;
    factory = XmlUtil.newXMLInputFactory(!disableXmlSecurity);
    XMLStreamReader streamReader = factory.createXMLStreamReader(src);
    XMLStreamReaderUtil.nextElementContent(streamReader);
    String namespaceURI = streamReader.getName().getNamespaceURI();
    XMLStreamReaderUtil.close(streamReader);
    return namespaceURI;
}
 
Example 8
Source File: DeploymentDescriptorParser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected ExternalMetadataFeature configureExternalMetadataReader(XMLStreamReader reader) {

        ExternalMetadataFeature.Builder featureBuilder = null;
        while (QNAME_EXT_METADA.equals(reader.getName())) {

            if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
                Attributes attrs = XMLStreamReaderUtil.getAttributes(reader);
                String file = getAttribute(attrs, ATTR_FILE);
                if (file != null) {
                    if (featureBuilder == null) {
                        featureBuilder = ExternalMetadataFeature.builder();
                    }
                    featureBuilder.addFiles(new File(file));
                }

                String res = getAttribute(attrs, ATTR_RESOURCE);
                if (res != null) {
                    if (featureBuilder == null) {
                        featureBuilder = ExternalMetadataFeature.builder();
                    }
                    featureBuilder.addResources(res);
                }
            }

            XMLStreamReaderUtil.nextElementContent(reader);
        }

        return buildFeature(featureBuilder);
    }
 
Example 9
Source File: RuntimeWSDLParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void parsePortTypeOperationInput(XMLStreamReader reader, EditableWSDLOperation operation) {
    String msg = ParserUtil.getMandatoryNonEmptyAttribute(reader, "message");
    QName msgName = ParserUtil.getQName(reader, msg);
    String name = ParserUtil.getAttribute(reader, "name");
    EditableWSDLInput input = new WSDLInputImpl(reader, name, msgName, operation);
    operation.setInput(input);
    extensionFacade.portTypeOperationInputAttributes(input, reader);
    extensionFacade.portTypeOperationInput(operation, reader);
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        extensionFacade.portTypeOperationInputElements(input, reader);
    }
}
 
Example 10
Source File: RuntimeWSDLParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void parseMimeMultipartBinding(XMLStreamReader reader, EditableWSDLBoundOperation op, BindingMode mode) {
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        QName name = reader.getName();
        if (MIMEConstants.QNAME_PART.equals(name)) {
            parseMIMEPart(reader, op, mode);
        } else {
            XMLStreamReaderUtil.skipElement(reader);
        }
    }
}
 
Example 11
Source File: HandlerChainsModel.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static void skipInitParamElement(XMLStreamReader reader) {
    int state;
    do {
        state = XMLStreamReaderUtil.nextContent(reader);
    } while (state != XMLStreamReader.END_ELEMENT ||
            !reader.getName().equals(QNAME_HANDLER_PARAM));
    XMLStreamReaderUtil.nextElementContent(reader);
}
 
Example 12
Source File: RuntimeWSDLParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void parseMimeMultipartBinding(XMLStreamReader reader, EditableWSDLBoundOperation op, BindingMode mode) {
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        QName name = reader.getName();
        if (MIMEConstants.QNAME_PART.equals(name)) {
            parseMIMEPart(reader, op, mode);
        } else {
            XMLStreamReaderUtil.skipElement(reader);
        }
    }
}
 
Example 13
Source File: RuntimeWSDLParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void parsePortTypeOperationFault(XMLStreamReader reader, EditableWSDLOperation operation) {
    String msg = ParserUtil.getMandatoryNonEmptyAttribute(reader, "message");
    QName msgName = ParserUtil.getQName(reader, msg);
    String name = ParserUtil.getMandatoryNonEmptyAttribute(reader, "name");
    EditableWSDLFault fault = new WSDLFaultImpl(reader,name, msgName, operation);
    operation.addFault(fault);
    extensionFacade.portTypeOperationFaultAttributes(fault, reader);
    extensionFacade.portTypeOperationFault(operation, reader);
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        extensionFacade.portTypeOperationFaultElements(fault, reader);
    }
}
 
Example 14
Source File: RuntimeWSDLParser.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void parseBindingOperation(XMLStreamReader reader, EditableWSDLBoundPortType binding) {
    String bindingOpName = ParserUtil.getMandatoryNonEmptyAttribute(reader, "name");
    if (bindingOpName == null) {
        //TODO: throw exception?
        //skip wsdl:binding element for now
        XMLStreamReaderUtil.skipElement(reader);
        return;
    }

    QName opName = new QName(binding.getPortTypeName().getNamespaceURI(), bindingOpName);
    EditableWSDLBoundOperation bindingOp = new WSDLBoundOperationImpl(reader,binding, opName);
    binding.put(opName, bindingOp);
    extensionFacade.bindingOperationAttributes(bindingOp, reader);

    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        QName name = reader.getName();
        String style = null;
        if (WSDLConstants.QNAME_INPUT.equals(name)) {
            parseInputBinding(reader, bindingOp);
        } else if (WSDLConstants.QNAME_OUTPUT.equals(name)) {
            parseOutputBinding(reader, bindingOp);
        } else if (WSDLConstants.QNAME_FAULT.equals(name)) {
            parseFaultBinding(reader, bindingOp);
        } else if (SOAPConstants.QNAME_OPERATION.equals(name) ||
                SOAPConstants.QNAME_SOAP12OPERATION.equals(name)) {
            style = reader.getAttributeValue(null, "style");
            String soapAction = reader.getAttributeValue(null, "soapAction");

            if (soapAction != null)
                bindingOp.setSoapAction(soapAction);

            goToEnd(reader);
        } else {
            extensionFacade.bindingOperationElements(bindingOp, reader);
        }
        /**
         *  If style attribute is present set it otherwise set the style as defined
         *  on the <soap:binding> element
         */
        if (style != null) {
            if (style.equals("rpc"))
                bindingOp.setStyle(Style.RPC);
            else
                bindingOp.setStyle(Style.DOCUMENT);
        } else {
            bindingOp.setStyle(binding.getStyle());
        }
    }
}
 
Example 15
Source File: RuntimeWSDLParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static void goToEnd(XMLStreamReader reader) {
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        XMLStreamReaderUtil.skipElement(reader);
    }
}
 
Example 16
Source File: DeploymentDescriptorParser.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private List<A> parseAdapters(XMLStreamReader reader) {
    if (!reader.getName().equals(QNAME_ENDPOINTS)) {
        failWithFullName("runtime.parser.invalidElement", reader);
    }

    List<A> adapters = new ArrayList<A>();

    Attributes attrs = XMLStreamReaderUtil.getAttributes(reader);
    String version = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_VERSION);
    if (!ATTRVALUE_SUPPORTED_VERSIONS.contains(version)) {
        failWithLocalName("runtime.parser.invalidVersionNumber", reader, version);
    }

    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {

        if (reader.getName().equals(QNAME_ENDPOINT)) {
            attrs = XMLStreamReaderUtil.getAttributes(reader);

            String name = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_NAME);
            if (!names.add(name)) {
                logger.warning(
                        WsservletMessages.SERVLET_WARNING_DUPLICATE_ENDPOINT_NAME(/*name*/));
            }

            String implementationName =
                    getMandatoryNonEmptyAttribute(reader, attrs, ATTR_IMPLEMENTATION);
            Class<?> implementorClass = getImplementorClass(implementationName, reader);

            MetadataReader metadataReader = null;
            ExternalMetadataFeature externalMetadataFeature = null;

            // parse subelements to instantiate externalMetadataReader, if necessary ...
            XMLStreamReaderUtil.nextElementContent(reader);
            if (reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
                externalMetadataFeature = configureExternalMetadataReader(reader);
                if (externalMetadataFeature != null) {
                    metadataReader = externalMetadataFeature.getMetadataReader(implementorClass.getClassLoader(), false);
                }
            }

            QName serviceName = getQNameAttribute(attrs, ATTR_SERVICE);
            if (serviceName == null) {
                serviceName = EndpointFactory.getDefaultServiceName(implementorClass, metadataReader);
            }

            QName portName = getQNameAttribute(attrs, ATTR_PORT);
            if (portName == null) {
                portName = EndpointFactory.getDefaultPortName(serviceName, implementorClass, metadataReader);
            }

            //get enable-mtom attribute value
            String enable_mtom = getAttribute(attrs, ATTR_ENABLE_MTOM);
            String mtomThreshold = getAttribute(attrs, ATTR_MTOM_THRESHOLD_VALUE);
            String dbMode = getAttribute(attrs, ATTR_DATABINDING);
            String bindingId = getAttribute(attrs, ATTR_BINDING);
            if (bindingId != null) {
                // Convert short-form tokens to API's binding ids
                bindingId = getBindingIdForToken(bindingId);
            }
            WSBinding binding = createBinding(bindingId, implementorClass, enable_mtom, mtomThreshold, dbMode);
            if (externalMetadataFeature != null) {
                    binding.getFeatures().mergeFeatures(new WebServiceFeature[]{externalMetadataFeature},
                    true);
            }

            String urlPattern = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_URL_PATTERN);

            // TODO use 'docs' as the metadata. If wsdl is non-null it's the primary.
            boolean handlersSetInDD = setHandlersAndRoles(binding, reader, serviceName, portName);

            EndpointFactory.verifyImplementorClass(implementorClass, metadataReader);
            SDDocumentSource primaryWSDL = getPrimaryWSDL(reader, attrs, implementorClass, metadataReader);

            WSEndpoint<?> endpoint = WSEndpoint.create(
                    implementorClass, !handlersSetInDD,
                    null,
                    serviceName, portName, container, binding,
                    primaryWSDL, docs.values(), createEntityResolver(), false
            );
            adapters.add(adapterFactory.createAdapter(name, urlPattern, endpoint));
        } else {
            failWithLocalName("runtime.parser.invalidElement", reader);
        }
    }
    return adapters;
}
 
Example 17
Source File: HandlerChainsModel.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static void skipTextElement(XMLStreamReader reader) {
    XMLStreamReaderUtil.nextContent(reader);
    XMLStreamReaderUtil.nextElementContent(reader);
    XMLStreamReaderUtil.nextElementContent(reader);
}
 
Example 18
Source File: DeploymentDescriptorParser.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private List<A> parseAdapters(XMLStreamReader reader) {
    if (!reader.getName().equals(QNAME_ENDPOINTS)) {
        failWithFullName("runtime.parser.invalidElement", reader);
    }

    List<A> adapters = new ArrayList<A>();

    Attributes attrs = XMLStreamReaderUtil.getAttributes(reader);
    String version = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_VERSION);
    if (!ATTRVALUE_SUPPORTED_VERSIONS.contains(version)) {
        failWithLocalName("runtime.parser.invalidVersionNumber", reader, version);
    }

    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {

        if (reader.getName().equals(QNAME_ENDPOINT)) {
            attrs = XMLStreamReaderUtil.getAttributes(reader);

            String name = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_NAME);
            if (!names.add(name)) {
                logger.warning(
                        WsservletMessages.SERVLET_WARNING_DUPLICATE_ENDPOINT_NAME(/*name*/));
            }

            String implementationName =
                    getMandatoryNonEmptyAttribute(reader, attrs, ATTR_IMPLEMENTATION);
            Class<?> implementorClass = getImplementorClass(implementationName, reader);

            MetadataReader metadataReader = null;
            ExternalMetadataFeature externalMetadataFeature = null;

            // parse subelements to instantiate externalMetadataReader, if necessary ...
            XMLStreamReaderUtil.nextElementContent(reader);
            if (reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
                externalMetadataFeature = configureExternalMetadataReader(reader);
                if (externalMetadataFeature != null) {
                    metadataReader = externalMetadataFeature.getMetadataReader(implementorClass.getClassLoader(), false);
                }
            }

            QName serviceName = getQNameAttribute(attrs, ATTR_SERVICE);
            if (serviceName == null) {
                serviceName = EndpointFactory.getDefaultServiceName(implementorClass, metadataReader);
            }

            QName portName = getQNameAttribute(attrs, ATTR_PORT);
            if (portName == null) {
                portName = EndpointFactory.getDefaultPortName(serviceName, implementorClass, metadataReader);
            }

            //get enable-mtom attribute value
            String enable_mtom = getAttribute(attrs, ATTR_ENABLE_MTOM);
            String mtomThreshold = getAttribute(attrs, ATTR_MTOM_THRESHOLD_VALUE);
            String dbMode = getAttribute(attrs, ATTR_DATABINDING);
            String bindingId = getAttribute(attrs, ATTR_BINDING);
            if (bindingId != null) {
                // Convert short-form tokens to API's binding ids
                bindingId = getBindingIdForToken(bindingId);
            }
            WSBinding binding = createBinding(bindingId, implementorClass, enable_mtom, mtomThreshold, dbMode);
            if (externalMetadataFeature != null) {
                    binding.getFeatures().mergeFeatures(new WebServiceFeature[]{externalMetadataFeature},
                    true);
            }

            String urlPattern = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_URL_PATTERN);

            // TODO use 'docs' as the metadata. If wsdl is non-null it's the primary.
            boolean handlersSetInDD = setHandlersAndRoles(binding, reader, serviceName, portName);

            EndpointFactory.verifyImplementorClass(implementorClass, metadataReader);
            SDDocumentSource primaryWSDL = getPrimaryWSDL(reader, attrs, implementorClass, metadataReader);

            WSEndpoint<?> endpoint = WSEndpoint.create(
                    implementorClass, !handlersSetInDD,
                    null,
                    serviceName, portName, container, binding,
                    primaryWSDL, docs.values(), createEntityResolver(), false
            );
            adapters.add(adapterFactory.createAdapter(name, urlPattern, endpoint));
        } else {
            failWithLocalName("runtime.parser.invalidElement", reader);
        }
    }
    return adapters;
}
 
Example 19
Source File: HandlerChainsModel.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * reader should be on <handler-chains> element
 */
public static HandlerChainsModel parseHandlerConfigFile(Class annotatedClass, XMLStreamReader reader) {
    ensureProperName(reader,QNAME_HANDLER_CHAINS);
    HandlerChainsModel handlerModel = new HandlerChainsModel(annotatedClass);
    List<HandlerChainType> hChains = handlerModel.getHandlerChain();
    XMLStreamReaderUtil.nextElementContent(reader);

    while (reader.getName().equals(QNAME_HANDLER_CHAIN)) {
        HandlerChainType hChain = new HandlerChainType();
        XMLStreamReaderUtil.nextElementContent(reader);

        if (reader.getName().equals(QNAME_CHAIN_PORT_PATTERN)) {
            QName portNamePattern = XMLStreamReaderUtil.getElementQName(reader);
            hChain.setPortNamePattern(portNamePattern);
            XMLStreamReaderUtil.nextElementContent(reader);
        } else if (reader.getName().equals(QNAME_CHAIN_PROTOCOL_BINDING)) {
            String bindingList = XMLStreamReaderUtil.getElementText(reader);
            StringTokenizer stk = new StringTokenizer(bindingList);
            while(stk.hasMoreTokens()) {
                String token = stk.nextToken();
                // This will convert tokens into Binding URI
                hChain.addProtocolBinding(token);
            }
            XMLStreamReaderUtil.nextElementContent(reader);
        } else if (reader.getName().equals(QNAME_CHAIN_SERVICE_PATTERN)) {
            QName serviceNamepattern = XMLStreamReaderUtil.getElementQName(reader);
            hChain.setServiceNamePattern(serviceNamepattern);
            XMLStreamReaderUtil.nextElementContent(reader);
        }
        List<HandlerType> handlers = hChain.getHandlers();
        // process all <handler> elements
        while (reader.getName().equals(QNAME_HANDLER)) {
            HandlerType handler = new HandlerType();

            XMLStreamReaderUtil.nextContent(reader);
            if (reader.getName().equals(QNAME_HANDLER_NAME)) {
                String handlerName =
                        XMLStreamReaderUtil.getElementText(reader).trim();
                handler.setHandlerName(handlerName);
                XMLStreamReaderUtil.nextContent(reader);
            }

            // handler class
            ensureProperName(reader, QNAME_HANDLER_CLASS);
            String handlerClass =
                    XMLStreamReaderUtil.getElementText(reader).trim();
            handler.setHandlerClass(handlerClass);
            XMLStreamReaderUtil.nextContent(reader);

            // init params (ignored)
            while (reader.getName().equals(QNAME_HANDLER_PARAM)) {
                skipInitParamElement(reader);
            }

            // headers (ignored)
            while (reader.getName().equals(QNAME_HANDLER_HEADER)) {
                skipTextElement(reader);
            }

            // roles (not stored per handler)
            while (reader.getName().equals(QNAME_HANDLER_ROLE)) {
                List<String> soapRoles = handler.getSoapRoles();
                soapRoles.add(XMLStreamReaderUtil.getElementText(reader));
                XMLStreamReaderUtil.nextContent(reader);
            }

            handlers.add(handler);

            // move past </handler>
            ensureProperName(reader, QNAME_HANDLER);
            XMLStreamReaderUtil.nextContent(reader);
        }

        // move past </handler-chain>
        ensureProperName(reader, QNAME_HANDLER_CHAIN);
        hChains.add(hChain);
        XMLStreamReaderUtil.nextContent(reader);
    }

    return handlerModel;
}
 
Example 20
Source File: RuntimeWSDLParser.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static boolean hasWSDLDefinitions(XMLStreamReader reader) {
    XMLStreamReaderUtil.nextElementContent(reader);
    return reader.getName().equals(WSDLConstants.QNAME_DEFINITIONS);
}